mdmudassirahmed/scrooge

Counts every token so you do not have to. Reads your Claude Code transcripts, shows where the tokens went, fixes what moves the bill.

Python

1

6 commits

updated Oct 3, 2026

See the code

See what people are saying

SourceMessageScoreDate

I read my Claude Code transcripts to find where the tokens went. Caveman would have saved 1%. The real leak was 4 things nobody talks about. (r/ClaudeAI)

Everyone says "shorter prompts" or "install caveman". I did the boring thing instead: Claude Code keeps every call's token usage in \~/.claude/projects/\*.jsonl. I wrote a script to add them up.…

0

Oct 4, 2026

README

scrooge: counts every token so you do not have to

MIT Python 3.8+ stdlib only no network Claude Code plugin stars

🧾 scrooge

Counts every token so you do not have to.

Claude Code writes down every call you make: the context size, the model, every tool result. scrooge reads that ledger and tells you where the money went. Then it fixes the things that actually move the bill. Nothing leaves your machine.


🔍 What It Does

Reads ~/.claude/projects/**/*.jsonl, the transcripts Claude Code already keeps. Adds up the tokens per call. Finds the four leaks that terse-mode plugins cannot see:

  • Context that never shrinks. Every call re-reads the whole conversation. At 900k that is the bill.
  • Agents on the wrong model. No model: pinned, so every subagent inherits Opus. Nobody chose that.
  • Config that never loaded. Session started one folder above the repo. CLAUDE.md and your agents silently ignored.
  • Files read over and over. The same 145 KB file, 44 times.

The four leaks

Then it caps the context with a hook that restores exact state from disk after compaction, blocks whole-file reads of big files, lists the agents with no model, and measures the result a week later.


⚡ Install

/plugin marketplace add mdmudassirahmed/scrooge
/plugin install scrooge@scrooge

Or copy one folder:

git clone https://github.com/mdmudassirahmed/scrooge
cp -r scrooge/skills/scrooge ~/.claude/skills/

Python 3.8+, standard library only. Windows, macOS, Linux.


🗣️ Trigger Phrases

  • /scrooge
  • where are my tokens going
  • why is my usage so high
  • cut my Claude Code cost
  • audit my sessions

🧰 Commands

CommandWhat happens
/scroogeReport for every project on this machine
/scrooge --project <path>One project (the folder you start Claude from)
/scrooge --since 7Last 7 days only
/scrooge --json before.jsonSave a snapshot
/scrooge --compare before.jsonBefore and after table
/scrooge applyGlobal fixes. Dry run first, backup, then write
/scrooge scaffold <repo>Repo side: CLAUDE.md rules, post-compaction hook, agent model check

📊 Quick Example

One week, one lead session, a dozen subagents. This is what scrooge said:

avg context per call        443,000 tokens     (lead session)
calls above 300k            29%                a 300k cap avoids 27% of all re-reads
agent dispatches            219 of 331         inherited the parent model (Opus / Fable)
sessions started in         C:\Users\Hp        9 of 10   CLAUDE.md: no   .claude/agents: no
files read 3+ times         84                 pipeline.ts read whole 44 times
visible text                < 5% of output     a terse plugin tops out near 1%

1. Cap the auto-compact window at 300k and re-inject state from disk after compaction.
2. Pin model: in .claude/agents frontmatter; pass model in Workflow agent() calls.
3. Start sessions inside the repo. Nine of ten could not load the project config.
4. Install the read guard; split files over 60 KB.

Two days after applying it, same project, measured by /scrooge --since 2 --compare before.json:

Measured two days after apply

Same work, 40% cheaper per call: context per call -38%, calls over 300k 29%→8%, Sonnet share 8%→41%, subagent spend -77%, repeated file reads -43%.

beforeafter
avg context per call237k148k
calls over 300k29%8%
calls on Sonnet8%41%
agent runs with inherited model66%48%
files read 3+ times8448
API-$ per call0.1000.059

🪨 Why Not Caveman or Graphify

Both are good. Both work on a slice scrooge measures first.

shrinksceiling in the case above
cavemanoutput tokens (how the model talks)~1% (visible text was under 5% of output)
graphifyinput tokens for code lookups~0% (code reads were a small slice; it had never indexed the repo)
scroogecache-read tokens, model price, config that never loadedabout half the spend

Run scrooge first. If it says your output tokens dominate, install caveman and it will tell you so. In most multi-agent sessions it will not.


🔧 The Fixes

FixWhatUndo
Context capCLAUDE_CODE_AUTO_COMPACT_WINDOW=300000 plus a SessionStart compact hook that prints tracker, newest hand-off section and git state from diskdelete the env line
Read guardPreToolUse hook. Whole-file Read over 40 KB denied, asks for offset/limit or Grep. Images and PDFs exemptremove the hook entry
Tiered agentsLists every .claude/agents file without model:, with a suggested tier table. You choosenothing to undo
Token disciplineA CLAUDE.md section: start in the repo, named agents only, spec files, bounded tasks, logs to files, 300-word hand-backsdelete the section
RetentioncleanupPeriodDays to 30 if it was under 7, so your ledger stops vanishingrestore the backup

apply backs up settings.json with a timestamp and prints before and after. New sessions pick it up. scaffold never commits.


🚧 Boundaries

  • No network. No git commits. No deletions. No edits outside ~/.claude and the repo you name.
  • Dollar figures are API list prices used as a relative proxy. Plans meter differently; the ratios are what matter.
  • Worktree clean-up and model choices are reported, never performed.

📁 Files

skills/scrooge/SKILL.md loaded by Claude at runtime. scripts/audit.py the report. scripts/apply.py the fixes. scripts/read_guard.py the hook. templates/ the post-compaction hook, CLAUDE.md section and agent tier table that scaffold installs.

MIT.

agent-skills
claude-code
claude-code-plugin
developer-tools
llmops
token-cost

mdmudassirahmed/scrooge

Counts every token so you do not have to. Reads your Claude Code transcripts, shows where the tokens went, fixes what moves the bill.

Python

1

6 commits

updated Oct 3, 2026

See the code

See what people are saying

SourceMessageScoreDate

I read my Claude Code transcripts to find where the tokens went. Caveman would have saved 1%. The real leak was 4 things nobody talks about. (r/ClaudeAI)

Everyone says "shorter prompts" or "install caveman". I did the boring thing instead: Claude Code keeps every call's token usage in \~/.claude/projects/\*.jsonl. I wrote a script to add them up.…

0

Oct 4, 2026

README

scrooge: counts every token so you do not have to

MIT Python 3.8+ stdlib only no network Claude Code plugin stars

🧾 scrooge

Counts every token so you do not have to.

Claude Code writes down every call you make: the context size, the model, every tool result. scrooge reads that ledger and tells you where the money went. Then it fixes the things that actually move the bill. Nothing leaves your machine.


🔍 What It Does

Reads ~/.claude/projects/**/*.jsonl, the transcripts Claude Code already keeps. Adds up the tokens per call. Finds the four leaks that terse-mode plugins cannot see:

  • Context that never shrinks. Every call re-reads the whole conversation. At 900k that is the bill.
  • Agents on the wrong model. No model: pinned, so every subagent inherits Opus. Nobody chose that.
  • Config that never loaded. Session started one folder above the repo. CLAUDE.md and your agents silently ignored.
  • Files read over and over. The same 145 KB file, 44 times.

The four leaks

Then it caps the context with a hook that restores exact state from disk after compaction, blocks whole-file reads of big files, lists the agents with no model, and measures the result a week later.


⚡ Install

/plugin marketplace add mdmudassirahmed/scrooge
/plugin install scrooge@scrooge

Or copy one folder:

git clone https://github.com/mdmudassirahmed/scrooge
cp -r scrooge/skills/scrooge ~/.claude/skills/

Python 3.8+, standard library only. Windows, macOS, Linux.


🗣️ Trigger Phrases

  • /scrooge
  • where are my tokens going
  • why is my usage so high
  • cut my Claude Code cost
  • audit my sessions

🧰 Commands

CommandWhat happens
/scroogeReport for every project on this machine
/scrooge --project <path>One project (the folder you start Claude from)
/scrooge --since 7Last 7 days only
/scrooge --json before.jsonSave a snapshot
/scrooge --compare before.jsonBefore and after table
/scrooge applyGlobal fixes. Dry run first, backup, then write
/scrooge scaffold <repo>Repo side: CLAUDE.md rules, post-compaction hook, agent model check

📊 Quick Example

One week, one lead session, a dozen subagents. This is what scrooge said:

avg context per call        443,000 tokens     (lead session)
calls above 300k            29%                a 300k cap avoids 27% of all re-reads
agent dispatches            219 of 331         inherited the parent model (Opus / Fable)
sessions started in         C:\Users\Hp        9 of 10   CLAUDE.md: no   .claude/agents: no
files read 3+ times         84                 pipeline.ts read whole 44 times
visible text                < 5% of output     a terse plugin tops out near 1%

1. Cap the auto-compact window at 300k and re-inject state from disk after compaction.
2. Pin model: in .claude/agents frontmatter; pass model in Workflow agent() calls.
3. Start sessions inside the repo. Nine of ten could not load the project config.
4. Install the read guard; split files over 60 KB.

Two days after applying it, same project, measured by /scrooge --since 2 --compare before.json:

Measured two days after apply

Same work, 40% cheaper per call: context per call -38%, calls over 300k 29%→8%, Sonnet share 8%→41%, subagent spend -77%, repeated file reads -43%.

beforeafter
avg context per call237k148k
calls over 300k29%8%
calls on Sonnet8%41%
agent runs with inherited model66%48%
files read 3+ times8448
API-$ per call0.1000.059

🪨 Why Not Caveman or Graphify

Both are good. Both work on a slice scrooge measures first.

shrinksceiling in the case above
cavemanoutput tokens (how the model talks)~1% (visible text was under 5% of output)
graphifyinput tokens for code lookups~0% (code reads were a small slice; it had never indexed the repo)
scroogecache-read tokens, model price, config that never loadedabout half the spend

Run scrooge first. If it says your output tokens dominate, install caveman and it will tell you so. In most multi-agent sessions it will not.


🔧 The Fixes

FixWhatUndo
Context capCLAUDE_CODE_AUTO_COMPACT_WINDOW=300000 plus a SessionStart compact hook that prints tracker, newest hand-off section and git state from diskdelete the env line
Read guardPreToolUse hook. Whole-file Read over 40 KB denied, asks for offset/limit or Grep. Images and PDFs exemptremove the hook entry
Tiered agentsLists every .claude/agents file without model:, with a suggested tier table. You choosenothing to undo
Token disciplineA CLAUDE.md section: start in the repo, named agents only, spec files, bounded tasks, logs to files, 300-word hand-backsdelete the section
RetentioncleanupPeriodDays to 30 if it was under 7, so your ledger stops vanishingrestore the backup

apply backs up settings.json with a timestamp and prints before and after. New sessions pick it up. scaffold never commits.


🚧 Boundaries

  • No network. No git commits. No deletions. No edits outside ~/.claude and the repo you name.
  • Dollar figures are API list prices used as a relative proxy. Plans meter differently; the ratios are what matter.
  • Worktree clean-up and model choices are reported, never performed.

📁 Files

skills/scrooge/SKILL.md loaded by Claude at runtime. scripts/audit.py the report. scripts/apply.py the fixes. scripts/read_guard.py the hook. templates/ the post-compaction hook, CLAUDE.md section and agent tier table that scaffold installs.

MIT.

agent-skills
claude-code
claude-code-plugin
developer-tools
llmops
token-cost

Languages

Python

100.0%