Skip to main content

Track active coding time with Claude Code and nudge yourself to take breaks

Project description

Garlic 🧄 — the AI Vampire 🧛 Warding Tool

Garlic is used to ward off vampires. According to Steve Yegge, AI tools have a vampiric effect on us, draining us of energy and making us tired and exhausted. Not because they are not good at coding, or do not make us much more productive, but simply because we get dopamine for getting stuff done quicker, leading us to work longer and think harder. In short, we need to touch grass. Instead of going hard for 12 hours straight with our coding agent of choice and burning ourselves out to only create value for our employer, we should be mindful of the $/hr formula and consider a new balance. He estimates there are no more than 3-4 hours of good work that we can do in a day with all this uplift without burning our own candles a little too brightly. As someone quite sensitive to the effects of extended dopamine release on the mind and body, I tend to agree with him. So I created garlic, a CLI tool that helps you keep the draining to a minimum and maintain your own energy levels so we can continue to be healthy little worker bees for years to come.

The idea came from this article by Steve Yegge.

How does it work?

garlic hooks into Claude Code using its hooks system. It tracks three events:

  • Session start — when you open a new Claude Code session
  • Prompt submit — when you send a message to Claude
  • Stop — when Claude finishes responding

From these events, garlic estimates how much time you have spent actively coding each day. It works across multiple concurrent Claude Code sessions by sharing a single state file with file locking.

The time model counts your full engagement cycle: the time Claude spends generating a response (always counted in full, no matter how long), plus the time you spend reading it and thinking before your next prompt. If your thinking time exceeds 40 minutes (configurable), garlic assumes you stepped away and counts nothing for that gap. Gaps within the limit are counted in full. The limit is intentionally generous: it covers the time you spend reading docs, answering a Slack message, checking email, or getting back into context — adjacent work that's still part of your coding session.

As you approach configurable thresholds (every 30 minutes up to 4 hours by default), garlic asks Claude to gently nudge you to consider taking a break. You choose how it nudges — gentle, firm, or spicy. Each threshold only fires once, so you won't be nagged on every prompt. The final threshold delivers a more definitive "session over" message.

If you're still coding in the hour before the daily reset (1 AM by default, when reset_hour is 2), garlic sends a bedtime nudge — a distinct "wrap up and get some sleep" message that fires once per night.

Compatibility

  • Python 3.11+
  • macOS, Linux, and WSL
  • Not supported on native Windows (fcntl is unavailable)

Setup

Install garlic with uv:

uv tool install garlic-cli

Run setup to install the Claude Code hooks:

garlic setup

Setup interactively prompts for key preferences (nudge interval, max prompt gap, reset hour, nudge style) with sensible defaults — just press Enter to accept them all. To skip prompts entirely and use defaults, pass -y:

garlic setup -y

This does two things:

  1. Creates ~/.garlic/config.toml (with your chosen settings or sensible defaults)
  2. Adds garlic's hooks to ~/.claude/settings.json so they run across all your projects

To reset your config to the latest built-in defaults (useful after upgrading):

garlic setup --defaults

Setup is idempotent — safe to run again if you need to repair or update hooks.

Upgrading

uv tool install garlic-cli --upgrade

Then re-run garlic setup to update your hooks if the release notes mention hook changes.

Usage

# Check your installed version
garlic version

# See how long you have been Clauding today
garlic status

# Disable nudging for the rest of the day (tracking continues)
garlic ignore

Configuration

Edit ~/.garlic/config.toml to customize:

# Max thinking time (minutes) between Claude stopping and your next
# prompt that still counts as active coding. If you take longer than
# this, garlic assumes you stepped away and counts nothing for that gap.
# Claude's generation time is always counted in full regardless of this.
max_prompt_gap_minutes = 40

# Hour of day (0-23) when the daily timer resets.
reset_hour = 2

# Accumulated minutes at which garlic will nudge you.
# Each threshold fires only once per day. The final threshold uses
# a more definitive "session over" message.
nudge_thresholds_minutes = [30, 60, 90, 120, 150, 180, 210, 240]

# Nudge personality: "gentle", "firm", or "spicy".
nudge_style = "gentle"

Things I should know?

No prompt injection risk. The nudge messages output by garlic's hooks are hardcoded in the project. There is no mechanism for external input to influence what gets sent to your agent. You can audit every possible message in src/garlic/nudges.py.

No third-party dependencies. Garlic uses only the Python standard library. This is an intentional choice — it runs on every prompt you send, so the supply chain should be as small and auditable as possible.

No data leaves your machine. All state lives in ~/.garlic/ and is never transmitted anywhere.

Built with Claude. This project was built with Claude Code, which is fitting given what it does.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

garlic_cli-0.1.7.tar.gz (95.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

garlic_cli-0.1.7-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file garlic_cli-0.1.7.tar.gz.

File metadata

  • Download URL: garlic_cli-0.1.7.tar.gz
  • Upload date:
  • Size: 95.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for garlic_cli-0.1.7.tar.gz
Algorithm Hash digest
SHA256 b2ba324fc026d9f0742f2fd1d6eaff15bb503c938ccd418ebdf8e621b07aa506
MD5 99aa114a6c3572cb475996a33547df9f
BLAKE2b-256 0f35e1d052fd53c71f21a0639e5eb6dd25084f84310c96469dda13327b14b3fb

See more details on using hashes here.

File details

Details for the file garlic_cli-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: garlic_cli-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for garlic_cli-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 68becae78efa0f27f11aadf03bc710d9bd4b575661f973e140e361c3cc8115fd
MD5 e0031e3d2f88c7c2539aac92d20c7b4b
BLAKE2b-256 3f7ce80eaa6c6b59fef529f07f4e270a1bce2306af83d5a4f168668aae477bb2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page