The per-line cost of CLAUDE.md, and why it is the only number worth editing on
The whole-file per-turn number is a headline. You can't edit a headline. You edit lines. So the cost question that actually matters is what one line of CLAUDE.md costs, scaled out to turns, engineers, and a year of use.
One line's per-turn cost is chars / 4 x rate / 1,000,000. On Opus 4.7 at $5 per million input tokens, a 60-character line is roughly 15 tokens and costs $0.000075 per turn, $0.0023 per 30-turn session, and $17.55 per year across a 5-engineer team running 30 sessions per engineer per week. Scale linearly with line length and team size.
Rates from platform.claude.com/docs/en/about-claude/pricing. Formula from src/lib/analyzer.ts line 37 and line 264.
Why per-line, not per-file
The whole-file per-turn cost is famously a flat number: your CLAUDE.md fires in full on every API call, so per-turn dollars are token_count x rate / 1M. That is a number to be aware of. It is not a number you act on, because there is no button labeled "delete some bytes" in the middle of a file.
What you act on is one line at a time. So the useful unit is what that one line costs while it sits in the file. Total cost is the sum of per-line costs; if you cut a line, its tokens leave the sum on every turn, every session, from now until the line goes back in. The per-line dollar is the lever; the per-file dollar is the dial it moves.
Concretely: same chars/4 estimator, same input rate, scoped to one line:
The per-line ladder, on a real 35-line CLAUDE.md
Below is the actual sample file the analyzer ships with (lines 288-322 of src/lib/analyzer.ts), one row per non-blank line, ranked by cost. Numbers use chars/4, Opus 4.7 input rate $5/M, 30-turn session, and a team of 5 engineers running 30 sessions per engineer per week (so the per-team-year column is per-turn x 234,000).
| # | Line | Tok | $/turn | $/session | $/team-week | $/team-year |
|---|---|---|---|---|---|---|
| 308 | We use Next.js, Postgres on Neon, Stripe for payments, Resend for transactional email, PostHog for analytics, and we deploy to Vercel from the main branch with preview deploys on every PR which means we have to be careful about migrations and we use a separate staging DB for that purpose so do not run destructive migrations without confirming first OK? 47-word run-on. analyzer.ts:150 flags as bloat (kind: bloat). | 85 | $0.000425 | $0.01275 | $1.91 | $99.45 |
| 321 | Today is 2026-05-17 and we are mid-sprint on the subscriptions rewrite. Cache-bust at idx<20. analyzer.ts:194 kind: cache_bust. Every turn pays uncached rate, so the real bill on this one is ~10x the cached-line column. | 18 | $0.000090 | $0.00270 | $0.41 | $21.06 |
| 315 | Follow our existing style. Look at neighbouring files. Be consistent. Vague ("existing", "be consistent"). analyzer.ts:124 kind: vague. | 18 | $0.000090 | $0.00270 | $0.41 | $21.06 |
| 298 | - Always use the most modern and best practice for the framework. Aspirational + vague. analyzer.ts:130 kind: aspirational; analyzer.ts:124 kind: vague ("best practice"). | 17 | $0.000085 | $0.00255 | $0.38 | $19.89 |
| 294 | - Always write clean, well-structured code with good naming. Vague ("clean", "good naming"). Also appears on line 316 - see duplicate row. | 15 | $0.000075 | $0.00225 | $0.34 | $17.55 |
| 316 | Always write clean, well-structured code with good naming. Duplicate of line 294. analyzer.ts:207 kind: duplicate. Pure waste; cutting this one saves all of these dollars and changes nothing. | 15 | $0.000075 | $0.00225 | $0.34 | $17.55 |
| 295 | - Always make sure to handle edge cases appropriately. Vague ("appropriately") + aspirational ("always"). 2 findings on 1 line. | 14 | $0.000070 | $0.00210 | $0.32 | $16.38 |
| 320 | When working on a feature, please read the relevant context, then make your plan. | 21 | $0.000105 | $0.00315 | $0.47 | $24.57 |
| 296 | - Always add comprehensive tests for everything. Aspirational ("always"). analyzer.ts:130. | 12 | $0.000060 | $0.00180 | $0.27 | $14.04 |
| 297 | - Always think carefully before making changes. Vague ("carefully") + aspirational. 2 findings. | 12 | $0.000060 | $0.00180 | $0.27 | $14.04 |
| 290 | You are an expert TypeScript engineer. | 10 | $0.000050 | $0.00150 | $0.23 | $11.70 |
| 304 | - Do not refactor unrelated code. Missing why. analyzer.ts:227 kind: missing_why. | 9 | $0.000045 | $0.00135 | $0.20 | $10.53 |
| 303 | - Never commit secrets. | 6 | $0.000030 | $0.00090 | $0.14 | $7.02 |
| 288 | # Project: payments-api | 6 | $0.000030 | $0.00090 | $0.14 | $7.02 |
| 302 | - Never use `any`. | 5 | $0.000025 | $0.00075 | $0.11 | $5.85 |
| 319 | ## Workflow | 3 | $0.000015 | $0.00045 | $0.07 | $3.51 |
| 292 | ## Always | 3 | $0.000015 | $0.00045 | $0.07 | $3.51 |
| 300 | ## Never | 2 | $0.000010 | $0.00030 | $0.05 | $2.34 |
| 306 | ## Stack | 2 | $0.000010 | $0.00030 | $0.05 | $2.34 |
| 313 | ## Style | 2 | $0.000010 | $0.00030 | $0.05 | $2.34 |
Total per-team-year for the visible 20 rows: about $322. That is the cost of this sample CLAUDE.md continuing to exist, unedited, across one year of one 5-engineer team. The whole-file per-turn cost says "your CLAUDE.md costs X per session." The per-line ladder says where X comes from.
“The 47-word stack paragraph on line 308 alone bills $99.45 per year. The duplicate one-liner on line 316 bills $17.55 per year on top of the original on line 294. Cutting the duplicate is a free $17.55 with zero behavioral change.”
Computed from SAMPLE_CLAUDE_MD lines 308 and 316, Opus 4.7 $5/M, 5 eng x 30 sessions/wk x 52 wk.
The 425x cost spread, in one file
The cheapest line in the sample (## Never, line 300) costs $0.00001 per turn. The most expensive (the run-on on line 308) costs $0.000425. Same file, same firing model, same rate, 42.5x cost spread on per-turn basis. Scale to per-team-year and the spread is the difference between $2.34 and $99.45 per year.
The lesson is not that headers are free. Headers are almost free, which is fine. The lesson is that the long lines pay for everything else. Three or four sentences like the stack run-on at line 308 will outweigh the entire rest of the file. When you audit a CLAUDE.md for cost, you are looking for those three lines.
What our analyzer does is rank exactly this: each line goes through the chars/4 estimator, gets a per-turn token count, and gets cross-checked against seven deadweight categories (bloat, vague, aspirational, missing_why, duplicate, conflict, cache_bust) so the ranked list also tells you which of the expensive lines are doing real work and which aren't.
The cut-order rule
With per-line numbers in hand, the cut order is mechanical. Read each row top-to-bottom in the ladder and apply this filter:
- If the line is flagged duplicate, cut it. The rule still exists on its first appearance; you cannot regress behavior by removing a second copy. In the sample above, line 316 is the cheapest cut in the entire file.
- If the line is flagged cache_bust and is in the first 20 lines, fix it. Either move the volatile string below idx 20 or delete it. This is the one finding that costs you ~10x the listed per-line dollar across the whole file, not just the line itself.
- If the line is over 28 words (bloat), split it. Same word count, half the lines, no token saving. But the model treats each line as one signal, so splitting raises the chance the back half actually fires.
- If the line is vague or aspirational with no "unless" and no "why", rewrite or cut. A line that the agent silently ignores still pays per turn. The team-year column tells you which of these are worth the rewrite effort and which to just delete.
- Move the expensive lines that survive (1)-(4) into a skill.A rule that fires only when its description matches stops counting against per-turn cost entirely. That is how the per-line ladder shrinks even when nothing got "cut."
Each step reduces the sum the per-turn cost is computed from. The order matters because step 1 is risk-free, step 2 is the largest per-edit return, and step 5 keeps content alive while taking it off the every-turn surface.
The sample file, so you can verify any row
Every row in the ladder above comes from the file below, which lives at src/lib/analyzer.ts lines 288-322. To verify any row: count the line's characters, divide by 4, multiply by 5, divide by 1,000,000 for $/turn. The token column rounds up by Math.ceil, which is also what analyzer.ts:38 does.
cost spread between the cheapest and most expensive line in one 35-line sample.
per team-year for one 60-character line; the duplicate at line 316 is a free cut.
multiplier from $/turn to $/team-year (30 turns x 5 eng x 30 sessions x 52 weeks).
What the per-line number does not include
Three honest qualifiers, because the ladder above is the floor, not the ceiling:
- Opus 4.7's new tokenizer is heavier than chars/4 by up to 35% on code, punctuation, and non-English text. So the per-line tokens are a low estimate. A line the ladder calls 15 tokens may bill closer to 20 on Opus 4.7. The relative ranking is correct; the absolute dollars are a floor.
- Output tokens are billed separately and are not part of the per-line cost. The per-line ladder is input-only, which is what CLAUDE.md is. Output cost depends on what the agent ends up doing in that turn, not on the configuration.
- The per-line ladder ignores layered files. If your project loads both
~/.claude/CLAUDE.md(global) and./CLAUDE.md(project), the per-turn cost is the sum of both files' per-line costs.
None of these change the cut-order rule. The most expensive lines are still the most expensive lines, and cutting them still saves the same proportion of the bill.
Want a per-line ladder for your own CLAUDE.md?
Paste it on ccmd.dev for the free in-browser scan, or book 20 minutes and we will read it line by line with you and rank the cuts by per-team-year dollars.
Frequently asked questions
How much does one line of CLAUDE.md cost?
One line's per-turn cost is its character count divided by 4, multiplied by your model's input rate per million tokens. At Opus 4.7's $5 per million input rate, a 60-character line is roughly 15 tokens, which is $0.000075 per turn. Across a 30-turn session: $0.0023. Across a 5-engineer team running 30 sessions per engineer per week, that one 60-character line costs about $0.34 per week, or $17.55 per year. Scale linearly: a 240-character paragraph is 4x; an 8-character header is roughly 7x cheaper. The formula is the same one the analyzer uses for the whole file at src/lib/analyzer.ts line 37, just scoped to one line.
Why does the per-line view matter when CLAUDE.md is billed as one prefix?
Because per-turn cost is a sum, and the sum is exactly where you can subtract. The analyzer at src/lib/analyzer.ts line 264 sets estimatedTokensFireEveryTurn equal to totalTokens, which is the sum across all lines. If you delete one line, its tokens leave the sum on every turn, every session, from now on. So the per-line view is the unit you actually act on. You don't cut a file, you cut lines. The team-year column tells you which lines are worth the deliberation cost of editing and which ones aren't.
Why does the same per-line dollar appear at radically different per-team-year scales?
The multiplier. A line that costs $0.000075 per turn looks rounding-error small. Hold the line fixed and multiply by 30 turns per session, 5 engineers, 30 sessions per engineer per week, 52 weeks per year: 30 x 5 x 30 x 52 = 234,000. That same $0.000075 becomes $17.55. The per-turn number is the cost of the line existing on one API call. The per-team-year number is the cost of the line existing in your repo for a year while everyone uses it. Pages that quote per-turn only are showing you the number too small to act on.
Does the duplicate line on line 316 really cost the same as the original on line 294?
Yes. The whole file is concatenated into one system-prompt prefix and shipped as bytes; the model has no way to deduplicate. Both copies of "Always write clean, well-structured code with good naming." are 15 tokens each, billed independently on every turn. analyzer.ts:207 detects this and emits a Finding with kind: duplicate. Cutting line 316 saves the full $17.55 per team-year. It is the cheapest line to remove in the whole file because removing it cannot change behavior; the rule still appears on line 294.
How do I read the per-line cost for my own file without a calculator?
Three steps. (1) Count the line's characters and divide by 4 for tokens. (2) Multiply by 5 if you're on Opus 4.7, 3 for Sonnet 4.6, 1 for Haiku 4.5, then divide by 1,000,000. That is the per-turn cost in dollars. (3) Multiply by 30 for a 30-turn session. To go to team-year, multiply by your eng count, by your sessions per engineer per week, and by 52. If you'd rather skip the arithmetic: paste your file on ccmd.dev. The analyzer reports tokens per line and the per-line findings array; you can see which lines drive the bill.
Does prompt caching collapse this whole math?
It cuts the bill by 10x on the cached portion, not the math. Anthropic's prompt cache reads bill at 10% of the base input rate, so on Opus 4.7 a cached line costs $0.50 per million instead of $5. Every cell in the ladder above shrinks by 10x if your prefix is byte-stable and you hit the cache. The catch is that any line near the top of the file containing an ISO date, "today", "this session", or any other turn-varying string forces the whole prefix to miss cache, every turn. analyzer.ts:194 (idx < 20) flags this as kind: cache_bust because that one bad line costs the whole file ~10x more than the cached column suggests.
Does AGENTS.md, .cursorrules, or .grokrules have the same per-line math?
Same math, different price per token depending on host model. All four formats are injected into the host model's system prompt and re-sent on every turn. The chars/4 estimator and the per-turn formula are identical; only the rate constant changes. Codex AGENTS.md runs on whatever model the user configures. Cursor's .cursorrules ride the Cursor model selection. Grok Build's .grokrules pay xAI's input rate. Substitute the host's $/M into the formula and the ladder still works.
Related guides
- CLAUDE.md per-turn token cost: the lookup table by file size — the whole-file headline number per-line cost sums to.
- CLAUDE.md token waste per turn — the seven kinds of deadweight bytes that show up in the ladder above as red flags.
- CLAUDE.md line firing audit — which of those flagged lines the model actually ignores.
- CLAUDE.md token cost audit — cold vs cached vs cache-busted, on a real file.
Comments (••)
Leave a comment to see what others are saying.Public and anonymous. No signup.