What a coding task costs in Claude Code

I priced every API call in my Claude Code session logs at Anthropic's published rates and matched the cost to the pull requests each session opened: 466 merged PRs across 52 repos, most of them from October and November 2026.

Median cost per merged PR
$9.35

Half of them cost $4 to $20.

Median in sessions with 3 PRs or fewer
$18.86

Whole sessions, so no splitting calls between PRs.

Tokens spent re-reading the conversation
98%

Those re-reads were 59% of the cost.

What one merged PR costs

Claude Code's plan prices tell you what a month costs. I wanted to know what one finished piece of work costs, so I measured it from the logs Claude Code keeps on my Mac.

Every call to the model records how many tokens it read and wrote. I priced each call at the published API rate for its model, added up the calls behind each PR, and looked at the 466 PRs that merged. The most expensive one cost about $630, and the 8 PRs over $100 each pull the average up to about twice the median.

8 in 10 merged PRs cost between $2 and $50

Cost of the Claude Code calls behind each merged PR, at Anthropic's published API prices.

See data
Merged PRs by cost band
$0-$1 35
$1-$2 29
$2-$5 82
$5-$10 98
$10-$20 104
$20-$50 82
$50-$100 28
$100-$200 4
$200+ 4
Embed

Paste this where you want the chart. It links back here and keeps its source line.

Optional: add this once per page and the frame grows to fit the chart.

CSV Prasad Subrahmanya

9 in 10 merged PRs came from sessions that opened 4 or more, so their cost depends on how I split each session's calls between its PRs. The 42 PRs from smaller sessions need no split, and their median is about twice the overall one. They are also different tasks, so I can't tell how much of the gap comes from the split and how much from the work. That is why I give both numbers.

I pay a flat monthly Max plan, so these are what the same tokens would cost on the API. They are the numbers to use if you run Claude Code on an API key, and a way to see what a plan is worth.

Cost by task type

I sorted each PR into a task type by its title, branch name and the files it changed. Feature PRs cost about $13 at the median, against about $8 for a bug fix. The median feature PR also changed about 900 lines of code, where a bug fix changed 50.

Feature PRs cost more than bug fixes at the median

Dot: median. Bar: the middle half of PRs. Merged PRs in brackets.

See data
Cost per merged PR by task type
Task type Merged PRs Median 25th pct 75th pct 90th pct Median lines changed
Bug fix 55 $7.82 $3.97 $14.69 $31.77 50
Feature 249 $12.88 $5.69 $22.04 $47.01 872
Refactor 13 $6.60 $5.41 $16.72 $36.32 488
Tests 8 $5.05 $1.54 $9.35 $11.68 648
Docs and content 97 $5.10 $1.92 $13.83 $30.96 159
CI, deps and config 44 $10.10 $3.54 $16.35 $26.96 656
Embed

Paste this where you want the chart. It links back here and keeps its source line.

Optional: add this once per page and the frame grows to fit the chart.

CSV Prasad Subrahmanya

Docs and content PRs, such as a README rewrite or a blog post, cost about $5 at the median. The refactor and tests groups have under 30 PRs each, too few to compare. I write tests inside the feature or fix PR that needs them, so only 8 merged PRs were mainly tests.

Re-reading the conversation is most of the bill

A model keeps no memory between calls. Each time Claude Code asks it for the next step, it sends the whole conversation again: the instructions, every file it read and every command output so far.

Prompt caching makes that affordable. The provider keeps the start of the conversation it has already seen and bills a re-read, a cache read, at a fraction of the normal input price. On Opus 5.5 a cache read costs 5% of a fresh input token. Writing new context into the cache costs more than a fresh token, 1.25 to 2 times as much.

Cache writes were 2% of the tokens and 26% of the cost

All Claude Code calls in sessions that opened a PR: 24 billion tokens.

Tokens
98%
Cost
59% 26% 14%
See data
Share of tokens and share of cost by token type
Tokens 23,817,994,787 378,729,211 68,859,386 5,103,517
Cost 5,873.14 2,596.11 1,389.7 27
Embed

Paste this where you want the chart. It links back here and keeps its source line.

Optional: add this once per page and the frame grows to fit the chart.

CSV Prasad Subrahmanya

Everything the model writes, code and reasoning included, was under 1% of the tokens and 14% of the cost. So the cost of a task follows how much context the agent carries, and for how many steps.

Calls late in a session cost more

To compare like with like, I took only the main conversation of each coding session, left out subagents, which keep a separate context, and kept Opus 5.5 calls so the price per token stays the same.

  • The first call writes the whole starting context into the cache, so it costs the most, about 33 cents at the median.
  • Calls 2 to 50 cost about 7 cents at the median, re-reading about 175,000 tokens.
  • Calls 201 to 1,000 cost about 13 cents, re-reading about 520,000 tokens.
  • Past call 1,000 the median falls back to about 11 cents and the prompt to about 415,000 tokens. I read that as Claude Code compacting the longest sessions.

A call deep in a session costs about twice as much as an early one

Median cost in US cents of main-thread Opus 5.5 calls in my coding sessions, subagents left out, at Anthropic's published API prices.

See data
Median cost of one call by position in the session, in cents
Call 1 32.7 cents
Calls 2 to 50 6.7 cents
Calls 51 to 200 10.0 cents
Calls 201 to 1,000 13.1 cents
Call 1,001+ 11.4 cents
Embed

Paste this where you want the chart. It links back here and keeps its source line.

Optional: add this once per page and the frame grows to fit the chart.

CSV Prasad Subrahmanya

Cost by model

Each session runs on the model I pick. Opus 4.8 ran my sessions in June and July, and Opus 5.5 from October. Sonnet 5.5 ran almost all of its calls in subagents, the helpers a session starts for searches and reviews.

Opus 5.5 handled 84% of the tokens and 69% of the cost

All Claude Code calls in sessions that opened a PR.

See data
Share of cost by model
Opus 5.5 68.7%
Opus 4.8 20.8%
Fable 5 8.4%
Sonnet 5.5 2.1%
Embed

Paste this where you want the chart. It links back here and keeps its source line.

Optional: add this once per page and the frame grows to fit the chart.

CSV Prasad Subrahmanya

To see what the model choice changes, I priced the same tokens as if every call had gone to one model. The median merged PR would cost about $9 on Opus 5.5, $4 on Sonnet 5.5 and $2 on Haiku 5.5. This compares prices only. A different model would take a different number of steps and land a different share of PRs.

My read

$9 to $19 for a merged PR is less than I expected.

Counting the PRs I closed or left open too, the average comes to about $21 per merged PR. At that average, a dev merging 20 PRs a week would spend about $420 a week at API prices.

What I do with this:

  • One task per session. I start a fresh session for each PR, or hand the task to a side session, so each call re-reads only what that task needs.
  • A short CLAUDE.md. It rides along on every call. The first call of a session carries about 94,000 tokens at the median: the system prompt, tool definitions, CLAUDE.md files and my first message.
  • Smaller models for mechanical work. Renames, data refreshes and copy edits run fine on Sonnet 5.5, at 50% of the price per token of Opus 5.5.

I will rerun this each quarter with the same script, so the numbers move with new models and prices. The 3 changes I measured in April, a code graph, tool-output compression and prompt caching, attack the same cache-read share from different sides.

Method

  1. Data. The session logs Claude Code writes on my Mac, one file per session plus its subagents: 350 sessions with model calls between June 28, 2026 and November 26, 2026, 86,651 calls in all. Claude Code had already cleared older logs. A resumed session repeats earlier calls in its file, so I count each API response once by its message ID.
  2. Price. Each call's uncached input, 5-minute and 1-hour cache writes, cache reads and output tokens, at the rates on Anthropic's pricing page on November 26, 2026. Haiku 5.5 prompts over 100,000 tokens use its higher rate. No call in the logs used fast mode, US-only inference or web search billing. As a check, my total for the 340 sessions where Claude Code stores a cost estimate came 1.4% above that estimate. Claude Code logs some responses in more than 1 line, the early ones with partial usage, so I keep the line with the most output tokens.
  3. PRs. Claude Code records each PR a session creates or links. A PR belongs to the first session that linked it within 2 hours of it opening; 501 of 518 linked PRs had one, and I leave out the 1 with no calls before it. In each session, a call counts toward the next PR the session opened after it, and calls after its last PR count toward that last PR, which covers review fixes and the merge.
  4. Task types. Rules on the PR title, branch and the share of changed lines in test, docs and config files. On a random sample of 60 merged PRs, each labeled from its title, the rules matched the label on 54. 3 of the 6 misses were copy edits counted as features.
  5. All-in. Every call in a session that opened at least 1 PR, divided by the merged PRs. Since every call already counts toward some PR, this adds only the $1,085 spent on the 16 closed and 18 still-open PRs.

The numbers I left out, and the limits:

  • 266 of the 350 sessions edited no files and opened no PR: research, writing and one-off scripted calls. They cost $124. Another 23 sessions edited files but opened no PR; their $912 is outside every per-PR number. A memory plugin that summarizes sessions in the background is left out too.
  • The logs cover only my work, across Rust libraries, an iOS app, a static site, data collectors and fonts. Inside a task I start review agents and side sessions, and their cost counts toward the PR.
  • Splitting a long session's calls between its PRs is approximate: a review fix for one PR can land on the next. That is why I give the per-session median next to it.
  • Prices are list prices. A plan, batch discounts or a negotiated rate change what you pay; the token counts stay the same.

The script that produces every number here is scripts/claude-code-cost.mjs. It reads the logs on the machine it runs on and writes only the totals below, with no prompts, repo names or file paths. Run it on your logs with node scripts/claude-code-cost.mjs; it needs the GitHub CLI to look up your PRs.

API prices used, USD per million tokens, November 26, 2026
Model Input 5 min cache write 1 hour cache write Cache read Output
Opus 5.5 $4 $5 $8 $0.2 $20
Opus 4.8 $5 $6.25 $10 $0.5 $25
Fable 5 $10 $12.5 $20 $1 $50
Sonnet 5.5 $2 $2.5 $4 $0.1 $10
Haiku 4.5 $1 $1.25 $2 $0.1 $5
Haiku 5.5 $0.1 $0.125 $0.2 $0.01 $0.5

Download the data

The aggregate numbers as CSV, free to reuse with credit (CC BY 4.0).

Sources and licenses (3)

Logs and prices

  • Claude Code Session logs on my own machine Token usage of every API call in my sessions, and the PRs each session opened
  • Anthropic API pricing Price per token type and model, read on 2026-11-26
  • GitHub Pull request metadata State, title, branch and changed files of each PR, read with the GitHub CLI

Get the next study by email

I publish a data study when the numbers are in, with its method and raw data. One email per study.

Send me

I send an email when something new goes up. Unsubscribe with a click. Privacy.