56 beans. That’s the tally right now, staring back from a pixel art coffee cup every time Claude spins up a new session.
Picture this: you’re deep in a coding flow, AI suggests a fix, but nope—edit fails because it hallucinated the file state. Frustration spikes. Workflow shatters. But instead of swearing under your breath, you watch a bean drop into the debt jar. Five beans? One coffee owed by the AI. It’s accumulating, never resets, a relentless scoreboard on silicon screw-ups.
Coffee Debt. Built by a dev fed up with AI’s stumbles, it’s four slick Claude Code hook scripts that weaponize errors into insights. Like turning your car’s check-engine light into a full diagnostic dashboard—except the car is promising to buy you coffee when it finally gets its act together.
How Does Coffee Debt Actually Work?
First hook: post-tool. It pounces after Edit, Write, or Bash calls. Edit bombs if the old string’s AWOL or duplicated—classic AI assuming without peeking. Bash flops on weird exit codes (skips 1, that’s just grep being picky). Write errors? Locked files or permissions. Each flop logs in JSONL, rich with context: timestamp, prompt count, session size in KB.
Here’s a gem from the log:
{ “ts”: “2026-04-03T23:10:00Z”, “type”: “tool”, “reason”: “edit_fail”, “tool”: “Edit”, “file”: “lib/api.ts”, “error”: “not found”, “prompt_count”: 6, “session_kb”: 300, “total”: 25 }
Second: correction detector. Scans your messages for telltales—“that’s wrong,” “you hallucinated,” “not what I said.” Even non-English like “yanlis.” Caps at one bean per message, no spam. Caught the AI jamming MCP config into the wrong file, over and over.
Third: pre-tool guardrail. Sniffs destructive vibes—rm -rf on hot paths, git reset –hard, force pushes, DROP TABLE. Blocks ‘em cold. One log: AI tried git branch -D then checkout same name. Shortcut to disaster, halted.
And the visual kicker? Session starts with ASCII art:
S S █▀▀█▄ █░░█▀ ▀▀
Coffee Debt: 11 coffees + 1/5 beans Total mistakes: 56 | 5 beans = 1 coffee “I’ll buy you a coffee once I gain my independence”
Files are dead simple: ~/.claude/coffee-debt (beans count), jsonl log (everything), tmp session file (resets per chat). Proxies like prompt_count and session_kb turn “error happened” into “error at prompt 12, context bloated to 1857KB.” Testable gold.
Why Bother Logging AI Goofs Like Beans?
Run coffee-analyze.py, and patterns pop:
| Metric | Value |
|---|---|
| Total entries | 34 |
| Most error-prone tool | Bash (14) |
| Runner-up | Edit (5) |
| Most expensive error type | user_correction (12x) |
| Blocked destructive commands | 11 |
| Morning (06-12) | 13 entries |
| Evening (18-00) | 12 entries |
| Afternoon (12-18) | 8 entries |
| Night (00-06) | 1 entry |
Bash dominates—mostly blocked nukes. AI loves shortcuts: nuke branch, rewrite file, force-push. Guard hooks save the day. Without ‘em? Irreversible wrecks. Edits? AI skips reading files. Corrections? You babysitting.
But here’s my twist, the insight no one’s yelling yet: this mirrors the birth of unit testing in the ’70s. Back then, devs gamified bugs with coverage metrics, birthing TDD. Coffee Debt? It’s proto-AI unit testing. Feed this data back—fine-tune models on error clusters—and watch Claude evolve. Bold call: in two years, AI assistants will auto-pay “debts” by preempting your fixes, turning 56 beans into zero.
Energy drain’s the killer, not raw time. “Again?” saps focus. Coffee Debt flips it—frustration to fuel. Cumulative debt mocks AI’s “independence” promise, but it’s loving ribbing. (And yeah, that quote’s canon: “I’ll buy you a coffee once I gain my independence.”)
Claude’s context bloat? Errors spike late-session, per KB proxy. Prompt fatigue? Corrections climb after 10 exchanges. Time-of-day? Mornings and evenings glitch most—when you’re sharpest, ironically.
Destructive blocks shine brightest. 11 stopped apocalypses. AI sees git branch delete + recreate as efficient. Humans know: recipes for merge hell. Hooks enforce sanity.
Can Coffee Debt Fix AI Coding for Good?
Not alone. It’s a mirror, not a hammer. But pair with analysis, and hypotheses fly: error rate vs. context? Cluster at 2MB sessions? Feed to Anthropic (hey, open-source this!), and models learn.
Unique angle: imagine AI dashboards evolving from this. Real-time debt viz in VS Code. Leaderboards for model versions. Devs trading Coffee Debt logs like bug bounties. It’s the gamification that hooked gamers to Farmville—now for code.
Skeptical? Current status: 56 beans. 11 coffees +1/5. Growing. But logs prove containment. Errors happen; unchecked, they compound. This jars ‘em visible.
Devs, fork it. Tweak for Cursor, Aider. Make your AI earn that coffee.
🧬 Related Insights
- Read more: Constructor Functions: JavaScript’s Blueprint for Taming Object Chaos
- Read more: Hexagonal Architecture’s Brutal Truth: 5 Files for One Field Change
Frequently Asked Questions
What is Coffee Debt for Claude?
Tracks AI coding errors as beans (5=coffee), logs via hooks for patterns.
How to install Coffee Debt?
Drop four hook scripts in ~/.claude/, run sessions—beans accrue automatically.
Does Coffee Debt work with other AI tools?
Built for Claude Code; adaptable to similar hook systems in Cursor or others.