Skip to content

About

Cut Claude Code costs with sourced levers -- prompt caching, model routing, Batch -- plus an installable skill, CLI tools, a cost calculator and 12 deep-dive guides

Topics

Resources

Contributing

Security policy

Stars

44 stars

Watchers

1 watching

Forks

Latest commit

 

History

119 Commits

Folders and files

Repository files navigation

Claude Cost Optimizer

Claude Cost Optimizer

GitHub stars GitHub forks License Last Commit

Cut Claude Code costs with sourced levers: cache reads bill at 5% of input on Opus 5.5 and Sonnet 5.5, Haiku 5.5 costs 1/40 of Opus 5.5 per token (prompts up to 100K tokens), and Batch is 50% off (Anthropic pricing) -- with an installable skill, CLI tools, and 12 deep-dive guides.

No one has published a typical saving for a mixed Claude Code workload, so this repo does not quote one. What is measured: prompt caching cut cost by a factor of 4.8 to 7.2 on a research agent and by 83% to 86% on a small triage agent (Anthropic's cost guide, read 2026-11-01); Anthropic's cost-optimization cookbook stacked model choice, effort and caching on one agent for a 13x lower cost per task ($0.2906 to $0.0223, 10/10 tasks passed both ways); and the cost guide's search over effort and model on tau2-bench retail cut cost per task 61% ($0.142 to $0.055) within a 2-point pass-rate band. See How far can you actually go?, and price your own sessions with /usage or claude-rate.

Live site: sagargupta.online/claude-cost-optimizer -- Repo Analyzer | Cost Calculator | Badge Checker. How the pieces fit: How It Is Built.

Repo Analyzer report for this repo: grade A, 88 of 100, with the per-category score breakdown Cost Calculator at its defaults: Opus 5.5, 30 turns, $48.97 a month, with the per-category breakdown
Repo Analyzer: paste a public repo, get a grade and the fixes Cost Calculator: cache-aware monthly spend and where it goes

Home page on a phone Cost Calculator monthly estimate on a phone Repo Analyzer grade on a phone

Screenshots come from scripts/capture-screenshots.py (Playwright against a local build, 1440x900 and 390x844), which also renders the site's 1200x630 social preview image.

Install

Claude Code (official plugin system):

/plugin marketplace add Sagargupta16/claude-cost-optimizer
/plugin install cost-mode@claude-cost-optimizer

Multi-agent (Cursor, Cline, Codex, 40+ agents):

npx skills add Sagargupta16/claude-cost-optimizer

Then activate in any session:

/cost-mode              # Standard: concise fragments OK
/cost-mode lite         # Professional brevity, full sentences
/cost-mode strict       # Telegraphic, max brevity
/cost-mode off          # Resume normal behavior

What cost-mode Does

Feature How It Saves Tokens
Strips filler Drops pleasantries, hedging, restating your question, trailing summaries
Suggests cheaper models "Haiku handles this -- /model haiku" for simple tasks
Suggests CLI tools "Use prettier/eslint --fix directly" instead of burning LLM tokens
Session awareness Reminds to /compact after 20+ turns, fresh sessions for new tasks
Minimal code gen Diffs over rewrites, no obvious comments, no speculative error handling
Auto-deactivates Full clarity for security warnings, destructive ops, and when you're confused

Technical accuracy is never sacrificed. Code in commits and PRs is written normally.

Full skill documentation


Rate your setup

Locally, one command (recommended)

claude-rate runs on your filesystem -- no signup, no install, no GitHub upload. The only requirement is Python 3.10 or later (preinstalled on most Linux distributions; on macOS it comes with the Xcode Command Line Tools). The command streams the script straight into Python, so nothing is installed or written to disk. Run it in your project directory:

Windows PowerShell:

irm https://raw.githubusercontent.com/Sagargupta16/claude-cost-optimizer/main/tools/claude-rate/rate.py | python - . --user --usage --fix

macOS, Linux, Git Bash, or Windows cmd (on Windows, python instead of python3):

curl -sSL https://raw.githubusercontent.com/Sagargupta16/claude-cost-optimizer/main/tools/claude-rate/rate.py | python3 - . --user --usage --fix

It grades the project, your user-level setup in ~/.claude and your last 30 days of Claude Code usage, then prints the fixes. Drop --user --usage to grade only the project. To keep a claude-rate command on macOS or Linux, run curl -sSL https://raw.githubusercontent.com/Sagargupta16/claude-cost-optimizer/main/tools/claude-rate/install.sh | sh -s -- --install.

--fix prints copy-pasteable fix commands; add --strict to fail CI when the grade drops below B, or --json for machine-readable output. See tools/claude-rate/README.md for the full breakdown.

--user and --usage grade your user-level setup -- global instructions, skill listing, user MCP servers, user settings -- and your measured usage from local Claude Code transcripts: cache hit rate, context size, and list-price spend per model (last 30 days by default). All of it is read locally; nothing leaves your machine.

From claude-rate 0.4.0, --usage also shows where the spend went: cache breaks with their likely cause and what each re-write cost above a warm read, spend by token class, main thread against subagents, the top sessions and the limits you hit. More local modes: --by session (or project, day, week, skill, MCP server and more) splits the spend, --what-if haiku reprices your recorded tokens on another model (modeled, quality not tested), --tools audits which tool results fill context, --max-context-tokens N fails CI when the always-loaded instructions pass N tokens, --statusline puts cache time left, context and limit pace in Claude Code's status line, and --burn is a live terminal view. See usage reports and live modes.

The local rater works on private and uncommitted repos and inspects things the web analyzer can't reach: settings.local.json, whether your Read(...) deny rules cover the lock files actually on disk, and secrets in your working tree. The web analyzer applies the same 7-category rubric (CLAUDE.md, file-read exclusions, settings, MCP, hooks, security, skills/agents/commands) to any public repo.

Public repos -- web tools

Tool What It Does
Repo Analyzer Paste a GitHub URL to get a cost audit, grade (A+ to F), and recommendations
Cost Calculator Estimate monthly spend with interactive charts: per-turn cost curve, savings breakdown, model comparison
Badge Checker Score your setup and get a shields.io badge for your repo

How It Is Built

How the toolkit fits together, in three rows. Top row, what the tools read: any public repo, your repo (CLAUDE.md and .claude/) and ~/.claude (settings, skills and transcripts). Middle row, where each tool runs. On GitHub: the Cost Audit Action, a composite action that a pull request in your repo runs and that can fail on a token budget for the always-loaded instructions, and the Repo Analyzer, Badge Checker and Cost Calculator on GitHub Pages; the Repo Analyzer reads any public repo through the GitHub REST API. On your machine: claude-rate, one stdlib Python file that reads your repo and, with --user --usage, ~/.claude, and that the hooks and the status line also run inside a session, and the VS Code extension, which reads your repo and is not on the Marketplace yet. In a Claude Code session: the hooks and status line (budget caps, cache guard, status line), the opt-in hooks (output trim and handoff loader), the MCP cost server over stdio and the cost-mode skill. Bottom row, what you get back: the Cost Audit Action, Repo Analyzer, Badge Checker and claude-rate give a grade from A+ to F with fixes and a shields.io badge; claude-rate, the Cost Calculator, the VS Code extension, the MCP cost server and the hooks and status line give a cost estimate; the cost-mode skill and the hooks give in-session nudges (model hints, budget and cache warnings); the opt-in hooks give a leaner context (trimmed build output and handoff notes).

The spec behind the picture is docs/diagrams/toolkit.yaml, rendered with orrery.

One pricing reference feeds every surface: the skill, the web tools, the CLI graders, the MCP server and the VS Code extension. Each carries its own copy of the rates, because each has to run on its own (claude-rate streams into python - with no install). CI fails a pull request when any rate value in the six code copies (344 values on 2026-10-18) disagrees with rate.py, when a file's verified-date stamp disagrees with the canonical one, or when a file still calls a passed retirement date upcoming. Each implementation of the cost math has a test suite pinned to the worked example below. Once a week, and on demand, the pricing-drift workflow runs scripts/check-live-pricing.py against Anthropic's live pricing page and opens or updates one "Live pricing drift" issue when the page and rate.py differ.

How it is built and shipped. docs/pricing-data.md is the pricing source of truth, and its sync checklist lists every file to update by hand when a rate changes: the cost-mode skill, which carries its rates as prose in SKILL.md, and the code copies of the rates, which are claude-rate (rate.py, the canonical copy), the MCP cost server (TypeScript over stdio), the hooks (cost-logger.sh), the token estimator (estimate.py, rates and tokenizer factor), the VS Code extension (not on the Marketplace) and the web tools (site/src/utils/pricing.ts). Each reaches users its own way: claude-rate as a raw file from the main branch of the GitHub repo, streamed into python -; the MCP cost server, the VS Code extension, the token estimator and the hooks from a clone of the repo (the server built with pnpm, the extension packaged as a VSIX, the estimator run as a script, the hooks wired into settings.json); the web tools on GitHub Pages, deployed by deploy-site.yml on every push to main; and the skill through the Claude Code plugin in .claude-plugin/, the Codex plugin in .agents/plugins/, whose copy of the skill in plugins/ is also kept by hand, and npx skills add for Cursor, Cline, Codex and other agents. On every pull request CI runs check-pricing-sync.py, which reads the stamps and retirement wording in every file and compares each stamp with the date in rate.py; check-links.py, which reads every relative link and heading anchor in the markdown; check-rate-values.py, which compares every rate value in the code copies with rate.py; and eval-output-filter.py, which replays the output-trim hook on captured runs. Once a week, not on pull requests, check-live-pricing.py (the pricing-drift.yml workflow) compares the rates in rate.py with the tables on Anthropic's pricing page and opens an issue when they differ.

The spec behind the picture is docs/diagrams/build.yaml, rendered with orrery.

Decision Why
Web tools run entirely in the browser The Repo Analyzer calls the GitHub REST API directly, so there is no server to host and no token to store; repo data comes from api.github.com and the grade badge from img.shields.io. The cost is GitHub's unauthenticated rate limit.
claude-rate is one stdlib Python file It streams into python - from curl or irm with no install step, and it can read what the web tool cannot: settings.local.json, lock files on disk, and your local Claude Code transcripts for real cache hit rate and spend.
Session math is cache-aware Every estimator bills a turn the way Claude Code caches a conversation: turn 1 writes the whole prompt, every later turn reads the previous request and writes only the new exchange. The old flat-hit-rate model overstated a 30-turn Opus 5.5 session about 4.6x (see CHANGELOG 1.16.0).
Every saving needs a source or a formula The repo's product is being a trustworthy pricing reference, so a claim without a link or a computed formula is treated as a bug, and check-pricing-sync.py turns the drift failures that shipped before into CI errors.
Each tool route gets a real index.html GitHub Pages would otherwise answer /calculator with HTTP 404 behind the SPA fallback; site/scripts/spa-404.mjs writes one per route with its own canonical URL so search engines index each tool.

Run it locally:

# repo gates CI runs, from the repo root
python scripts/check-pricing-sync.py .
python scripts/check-rate-values.py .
python scripts/check-links.py .
python -m unittest discover -s tools/claude-rate/tests
python -m unittest discover -s scripts/tests
python scripts/eval-output-filter.py --strict
python tools/claude-rate/rate.py . --json

# web tools (Node 24)
cd site
npm ci --legacy-peer-deps
npm test
npm run dev

Before vs After

Worked example: a 30-turn session on Opus 5.5 ($4/$20 per 1M; 5-minute cache writes $5, cache reads $0.20), one 2,000-token file read, about 1,500 tokens of new conversation and 500 output tokens per turn. It is billed the way Claude Code caches a conversation (prompt caching docs): turn 1 writes the whole prompt to the cache, and every later turn reads the previous request back and writes only the new exchange. The figures are arithmetic from the posted rates (the same model as the calculator), not a metered bill. The MCP share assumes tool search is off (full schemas up front); with the default tool search on, the "before" prefix is smaller to start with:

BEFORE (no optimization):                 AFTER (5 minutes of setup):
  CLAUDE.md:        6,200 chars             CLAUDE.md:        2,800 chars
  Read deny rules:  none                    Read deny rules:  12 patterns
  MCP servers:      6 active                MCP servers:      2 active
  Prefix:           ~15,000 tokens          Prefix:           ~5,500 tokens
  Session cost:     $0.82                   Session cost:     $0.72
  Monthly (3x/day): $54.31                  Monthly (3x/day): $47.54

  Savings: $6.77/month (12%)

The setup cleanup saves 12%, not more, because the prefix is a cache read on 29 of the 30 turns. Output is the bigger share: 500 tokens a turn is $0.30 of the $0.8229 (36%), so halving output saves $0.15 a session, more than the whole cleanup. Without caching the same session would cost $4.95, and the cleanup would save 23%. The Read deny rules are not in these figures: what they save depends on which files your sessions would otherwise read.


How Far Can You Actually Go?

Short answer: there is no published typical figure for a whole Claude Code workload. Each lever below is measured or priced by Anthropic, and each applies only to its own slice of spend. Anthropic has published two stacked measurements, both on earlier models. In its cookbook agent, moving from Opus 5 at high effort to Sonnet 5 at medium with explicit cache breakpoints cut cost per task 13x ($0.2906 to $0.0223) at the same 10/10 pass rate. In its cost guide, a search over effort and model on tau2-bench retail went from Opus 5 at default effort ($0.142 a task, 76.0% passed) to Sonnet 5 at low ($0.055, 74.3%), 61% cheaper within a 2-point pass-rate band (read 2026-11-01).

Lever Published savings Applies to Source
Prompt caching up to 90% cost (95% on Opus 5.5 and Sonnet 5.5, 97.5% on Fable 5.2 and Fable 5.1), 85% latency; cost cut by a factor of 4.8 to 7.2 on a research agent and by 83% to 86% on a small triage agent (cost guide, read 2026-11-01) cached input only (0.1x input price; 0.05x on Opus 5.5 / Sonnet 5.5; 0.025x on Fable 5.2 / Mythos 5.2 / Fable 5.1 / Mythos 5.1) Anthropic: Prompt caching, pricing docs, cost and intelligence guide
Batch API flat 50% off input and output, stacks with caching any async (24h) work Anthropic: Message Batches API, batch docs
Model routing up to 97.5% per token (Opus 5.5->Haiku 5.5 is 40x at <=100K prompt tokens, 8x above; legacy Haiku 4.5 was 4x); measured per correct answer on GPQA Diamond, Haiku 5.5 cost about 1/20 of Opus 5.5 and about 1/10 of Sonnet 5.5, at 85% accuracy vs 91% for each (read 2026-11-01); RouteLLM reports cost cuts of over 85% on MT Bench, 45% on MMLU and 35% on GSM8K against GPT-4 only, at 95% of GPT-4 quality; its controller routes on the last message only (routellm/controller.py:108-110) and its paper assumes short single-turn prompts when costing (read 2026-11-03), so none of the three figures comes from a multi-turn tool session like Claude Code's tasks a cheaper model handles well cost and intelligence guide, LMSYS RouteLLM post (2024-07-01, the source of the 85% / 45% / 35% figures; the RouteLLM paper, arXiv 2406.18665, says costs fall "by over 2 times in certain cases")
Context management 84% fewer tokens in a 100-turn eval long agentic sessions Anthropic: Context management
Subscription vs API about 95% for one heavy user (n=1): over $15,000 of API-equivalent usage for about $800 of Max subscription (author's tracker, post dated 2026-02-23; computed: 1 - 800 / 15,000 = 94.7%). Plans are now Pro $20, Max $100 and Ultra $200 (formerly Max 20x) a month, flat. The monthly API credits on Max ($100) and Ultra ($200) do not cover interactive Claude Code; they cover claude -p and the Agent SDK run with an API key from the linked Console org (read 2026-11-01) power users vs pay-as-you-go ksred cost tracker (n=1), Claude pricing, monthly API credits

The honest read

  • Each lever's number applies to its own slice. Cache-read pricing applies to cached input only. The 40x routing ratio applies only to tasks Haiku 5.5 completes: Anthropic measured Haiku 5.5 at about 1/20 of Opus 5.5's cost per correct GPQA Diamond answer, at 85% accuracy vs 91% (cost and intelligence guide, read 2026-11-01). The two stacked measurements are the cookbook's 13x on one agent and the cost guide's 61% on tau2-bench retail, both on earlier models.
  • The stacked total has no source. Each lever above is individually sourced; the combined figure is not, and this repo holds no controlled multi-lever measurement. For a number that applies to your workload, run claude-rate on your own repo and price only the levers you can apply.
  • The cost-mode skill has not been benchmarked. It trims visible output and suggests model routing. Its effect on cost is the output cut times the output share of your spend: in the token mix of Anthropic's own /usage example, priced at Opus 5.5 rates, output is 19% of the bill, so a 40% output cut saves about 8% (computed: 0.40 x 19.3%). Thinking bills as output and brevity rules do not shrink it; /effort does. See when cost-mode saves nothing.
  • Caching and batch are the firmest floors (first-party Anthropic pricing; batch is a documented flat 50% that provably stacks with caching). Routing and subscription savings are the most workload-sensitive.

Prices verified against the pricing reference below (2026-11-10). Cache hit = 0.1x base input on every model except Fable 5.2, Mythos 5.2, Fable 5.1 and Mythos 5.1 (0.025x) and Opus 5.5 and Sonnet 5.5 (0.05x); Batch = 50% off both input and output.


Quick Start (5 Minutes, No Skill Needed)

Even without installing the skill, these 5 changes cut costs immediately:

# Strategy Savings Guide
1 Keep CLAUDE.md under 200 lines -- it loads in full every session; Anthropic's guidance is that longer files "consume more context and reduce adherence". Move workflow-specific instructions into skills or path-scoped .claude/rules/ No published figure Context Optimization
2 Use Haiku for simple tasks (--model haiku) -- Haiku 5.5 is $0.10/$0.50 up to 100K prompt tokens, $0.50/$2.50 above: 40x cheaper per token than Opus 5.5 below 100K, 8x above 1/40 of Opus 5.5 per moved task (per token) Model Selection
3 Use Plan Mode before coding (Shift+Tab) -- prevents wasted iterative cycles No published figure Workflow Patterns
4 Add Read(...) deny rules to permissions.deny in .claude/settings.json -- keep Claude's file tools out of node_modules, dist, lock files (the permissions docs say a .claudeignore file has no effect) No published figure Context Optimization
5 Delegate to subagents -- isolate expensive searches from main context No Claude Code figure; cookbook subagent pattern: 78% cheaper on one agent loop Workflow Patterns

Full walkthrough: Getting Started in 5 Minutes


Skills Roadmap

cost-mode is the first skill. More are planned:

Skill Status What It Does Cost Impact
cost-mode Live Concise responses, model routing suggestions, session awareness Not benchmarked (Anthropic: asking for shorter answers cut output tokens 39%, cost 13%, read 2026-11-01)
deny-rules-gen Planned Generates permissions.deny Read(...) rules for your project's tech stack. Detection exists already: claude-rate --fix (0.4.0 or later) prints the Read deny block detected for the project; the skill is not built No published figure
context-compress Planned Rewrites your CLAUDE.md to be shorter while keeping all essential info About 5% of a 30-turn session for 500 to 150 lines (computed with this repo's cache-aware calculator at 10 tokens per line: $0.7851 to $0.7473 on Opus 5.5), plus adherence
cache-optimizer Planned Detects cache-busting patterns and suggests fixes to maximize prompt cache hits. Detection exists already: claude-rate --usage (0.4.0 or later) lists the cache breaks in your transcripts with their cause and cost, and --fix the fix per cause; the skill is not built Anthropic: one cache-busting 25-token prefix made a run 7.2x dearer ($4.24 vs $0.59)
budget-guard Planned Per-session and per-day spending limits with warnings before you blow past them. The caps exist already as an opt-in hook: hooks/budget-tracker.sh with BUDGET_SESSION_USD, BUDGET_DAY_USD and BUDGET_TURN_USD warns as spend nears a cap and asks before the next tool call once it is reached, priced at list price by claude-rate; the skill is not built Prevents overspend

Want to build one? Skills are just SKILL.md files -- see CONTRIBUTING.md and the skills/cost-mode/ directory for the pattern.


Guides

12 deep-dive guides covering every optimization area:

Guide What You'll Learn
00 - Getting Started Zero to optimized in 5 minutes -- the essential setup
01 - Understanding Costs How billing works, what costs the most, where money goes
02 - Context Optimization Reduce input tokens: CLAUDE.md, Read deny rules, file reads
03 - Model Selection When to use Opus vs Sonnet vs Haiku (with decision tree)
04 - Workflow Patterns Plan mode, subagents, commands, batch operations
05 - Team Budgeting Per-developer budgets, cost tracking, ROI calculation
06 - Access Methods & Pricing Compare API vs Bedrock vs Google Cloud (Google managed, formerly Vertex AI) vs Claude Code pricing
07 - MCP & Agent Cost Impact MCP server overhead, subagent costs, Agent SDK patterns
08 - Prompt Caching Deep Dive Cache mechanics, TTL economics, maximizing hit rates, ROI math
09 - Subscription Plan Value Choose the right plan, maximize allowance, upgrade/downgrade signals
10 - Three-Tier Task Routing Skip the LLM for Tier 0 tasks, route cheap tasks to Haiku, save Opus for complex work
11 - Speed vs Cost Make Claude faster without burning money -- free latency levers first, Fast Mode economics last

Also: Visual Diagrams (Mermaid flowcharts) | One-Page Cheatsheet


Templates

Copy-paste configs that are already optimized:

CLAUDE.md: Minimal | Standard | Comprehensive | Monorepo

By Stack: React+Vite | Next.js | FastAPI | MERN | Terraform | Go | Rust | Django | Rails | Spring Boot

Settings: Cost-Conscious | Balanced | Performance-First | Status line (claude-rate --statusline) | Team telemetry (OpenTelemetry export, managed settings only)

Commands: /cost-check | /budget-mode | /quick-fix | /handoff | /optimize

Subagents: templates/agents/ -- a read-only scout, a reviewer and an implementer, each with its model and tools pinned (an agent file with no model: runs on CLAUDE_CODE_SUBAGENT_MODEL if set, else your main model)


CLI Tools

The 8 tools in tools/, plus the budget hooks in hooks/. Full tools documentation

Tool What It Does
claude-rate Grade your local setup on the 7-category rubric (recommended entry point). --usage prices your local transcripts; from claude-rate 0.4.0, --by session (or project, day, week) splits that spend, --statusline shows cache, context and limit pace in Claude Code's status line, and --burn is a live terminal view
Token Estimator Estimate token count and cost for any file
Usage Analyzer Retired. It read the older transcript layout and found no sessions in current Claude Code transcripts, which nest usage under message; it now prints a pointer to claude-rate --usage --by session and exits 1
Badge Generator Grade your project config (A+ to F) from the CLI
MCP Cost Server In-session cost estimation via MCP
VS Code Extension Token count and cost in the status bar
GitHub Action Automated cost audit on PRs
/optimize Command Claude Code custom command that audits the current project
Budget Hooks Track tool calls, log costs, warn at thresholds; budget-tracker.sh takes per-session, per-day and per-turn dollar caps (BUDGET_SESSION_USD, BUDGET_DAY_USD, BUDGET_TURN_USD) priced from the transcript by claude-rate; opt-in extras price a /model switch or a stale resume before the cache re-write (cache-guard.sh), reload a handoff after /clear (handoff-loader.sh) and trim long Bash output (output-trim.sh)

Pricing Reference

Current models plus legacy Fable 5.1, per 1M tokens, verified 2026-11-10 against Anthropic's pricing page. Fable 5.2 (released 2026-11-09) is the most capable widely released model, at 2x Opus 5.5 and 20% below Fable 5.1 on every rate; Anthropic still says to start with Opus 5.5 for most workloads (models overview, read 2026-11-10). Legacy snapshots, Batch and Fast Mode rates, subscriptions, the sonnet/haiku alias gotcha, migration notes for Opus 5.5, Sonnet 5.5, Haiku 5.5 and Opus 5, and retired models are in docs/pricing-reference.md.

Model Input Output Cache hit 5m cache write Min cacheable prompt
Fable 5.2 (highest capability) $8.00 $40.00 $0.20 $10.00 512
Fable 5.1 (legacy) $10.00 $50.00 $0.25 $12.50 512
Opus 5.5 (recommended default) $4.00 $20.00 $0.20 $5.00 512
Sonnet 5.5 $2.00 $10.00 $0.10 $2.50 512
Haiku 5.5 (prompt <= 100K tokens) $0.10 $0.50 $0.01 $0.125 512
Haiku 5.5 (prompt > 100K tokens, whole request) $0.50 $2.50 $0.05 $0.625 512

Batch is 50% off input and output and stacks with caching. A prompt under the minimum cacheable length is silently not cached.


Benchmarks & Case Studies

  • Task Comparison -- same task, optimized vs not
  • Model Comparison -- Opus vs Sonnet vs Haiku
  • Context Size Impact -- how CLAUDE.md size affects cost
  • Community Leaderboard -- crowdsourced cost-per-task data
  • Compact Flags -- characters git prints with and without its compact flags, measured on this repo; not a session saving
  • Delegation Break-Even -- when reading in a subagent costs less than reading on the main thread, computed from the posted rates
  • Method -- the rules every measured number in this repo follows, written before any run
  • cost-mode eval harness -- the runner for the first measured cost-mode benchmark; built, not run, no results yet
  • Case Studies -- submission template and format; no stories published yet, contributions welcome

Community

Complementary Projects

Stars read on GitHub 2026-11-03 (gh api repos/<owner>/<repo>). The savings column is each project's own claim and the method it names, not something this repo has measured; -- means the project publishes no savings figure. Telemetry notes are from each project's own docs.

Project Stars What It Does Savings (project's own claim and method)
caveman 117.0k caveman 4.0: brevity voice skill plus input compression (Read less), per-ask model and effort routing (Auto) and reusable scripts (Blocks); its CLI sends usage telemetry by default Its GitHub description claims "cuts 65% of tokens"; its own honest-numbers page says earlier releases applied a fixed 65% ratio without a committed reviewed result, measures /caveman at 3% and /ultracave at 35% fewer output tokens than an "Answer concisely." control (median, ten questions, Opus 5.5, one run), and lists the cut against verbose replies as "Not published"
claude-mem 111.1k Persistent compressed context across sessions, for Claude Code and several other agents; anonymous usage analytics on by default (opt out with npx claude-mem telemetry disable or DO_NOT_TRACK) Its Smart Explore benchmark: 17.8x fewer tokens than the Explore agent for cross-file discovery (five queries on its own src/, Opus 4.6, counting the Explore agent's total_tokens against its own tools' self-reported output)
rtk 85.4k CLI proxy that compresses common dev-command output before Claude reads it Claims "60-90%" on common dev commands (GitHub description; its README says "up to 90% smaller"), and adds this "is not the same as cutting your bill by the same amount"
headroom 78.7k Local proxy, library and MCP server that compresses tool output, logs and JSON before the model sees it; an anonymous beacon is on by default (HEADROOM_BEACON=off or DO_NOT_TRACK=1) Its GitHub description claims 20% fewer tokens for coding agents; its seeded, offline proof table shows 41% fewer tokens (178,024 to 104,261) over four scenarios built from MCP output formats; the results file names a tiktoken counter
codebase-memory-mcp 48.0k Indexes a repo into a local code graph served as MCP tools Its preprint reports 10x fewer tokens and 2.1x fewer tool calls than file-by-file exploration across 31 repositories, at 83% answer quality against 92% for the file-exploration agent
claude-code-router 38.0k Local control plane that routes Claude Code and other agent CLIs across models --
context-mode 33.3k MCP server and hooks that run analysis in a subprocess so only printed results reach the context, and index large output for search; Elastic License 2.0 (source-available) Its BENCHMARK.md: 96% less (376 KB raw to 16.5 KB in context) over 21 scenarios on committed fixtures, measured in bytes of single tool outputs, not tokens or dollars
ccusage 19.3k npx ccusage usage and cost reports from your local logs --
ccstatusline 13.5k Customizable Claude Code status line with cost, context and prompt-cache widgets --
Claude-Code-Usage-Monitor 8.8k Real-time usage monitor with predictions (no push since 2026-07-05) --
claude-code-hooks 572 Hook marketplace, mostly safety guards, plus a cold-cache cost guard and status line (cache-tax) and native-setting presets --
claudetop 212 htop-style cost and cache monitor --

This repo's own live views are claude-rate --statusline (cache time left, the list-price re-cache if it goes cold, context fill and 5-hour/7-day pace in Claude Code's status line) and claude-rate --burn (a terminal view), both in claude-rate 0.4.0 or later; see tools/claude-rate/.


FAQ

How much does Claude Code actually cost?

With Pro ($20/mo, or $200/yr with annual billing: $16.67/mo, 17% off; computed: 200 / 12 and 1 - 200 / 240), Max ($100/mo, 5x Pro usage) or Ultra ($200/mo, formerly Max 20x; 10x Pro usage a week and no 5-hour limit for verified accounts), you get included usage (Claude pricing, Ultra plan, read 2026-11-01). Past the limits, usage credits (formerly extra usage) bill at API rates, and usage bundles prepay them at a discount: $45 for $50 of usage, $200 for $250, $700 for $1,000 (read 2026-11-01). For enterprise deployments, Anthropic's own average is about $13 per developer per active day and $150-250 per developer per month, with 90% of users under $30 per active day (Claude Code costs docs); run /usage in Claude Code to see your own session cost. Claude Console and Enterprise organizations can pull token usage and cost by model, workspace, API key or user from the Usage and Cost Analytics API (beta since 2026-10-29; the older Usage and Cost API is now legacy). Opus 5, 4.8, 4.7, and 4.6 at $5/$25 are 3x cheaper per token than Opus 4.1 ($15/$75), and Opus 5.5 at $4/$20 is cheaper still -- but the tokenizer introduced with Opus 4.7 (shared by Opus 5.5) produces about 30% more tokens for the same text (Anthropic's pricing page), so per task the gap for the $5/$25 models is about 2.3x (computed: 3 / 1.3).

Does this apply to the Claude API too?

Context optimization, model selection, and prompt engineering apply to both. The skill and commands are Claude Code-specific.

Will optimization reduce output quality?

No. These strategies eliminate waste (duplicate context, unnecessary file reads, expensive models for simple tasks). Quality stays the same or improves -- less noise means better reasoning.

What's the biggest single change I can make?

Switch routine work to Haiku 5.5 (/model haiku, or model: haiku on subagents): each task you move costs 1/40 of Opus 5.5 per token while prompts stay under 100K tokens (Anthropic pricing). If routine work is 30% of your Opus 5.5 spend, that is 29% off the bill (computed: 0.30 x 0.975). Then install cost-mode (npx skills add Sagargupta16/claude-cost-optimizer) for shorter answers.


Star History

If this repo helped you save money, consider giving it a star!

Star History Chart

More AI Developer Tools

If you found this useful, check out my other AI/Claude tools:

Project Description
claude-code-recipes 47 copy-paste recipes for Claude Code - commands, subagents, hooks, skills
claude-skills Custom Claude Code plugin marketplace with dev-workflow, FARM stack, and more
agent-recipes AI agent workflows for real-world dev tasks - code review, testing, security
ai-git-hooks AI-powered git hooks - auto-review diffs, generate commit messages, security scanning
mcp-toolkit Production-ready middleware for MCP servers - auth, caching, rate limiting

License

MIT - use these strategies, templates, and tools however you want.

About

Cut Claude Code costs with sourced levers -- prompt caching, model routing, Batch -- plus an installable skill, CLI tools, a cost calculator and 12 deep-dive guides

Topics

Resources

Contributing

Security policy

Stars

44 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages