How Much Does Claude Code Cost Per PR? (2026)

Quick Verdict

A typical Claude Code-assisted pull request costs $1.50-$8.00 on Sonnet 4.6, depending on complexity. Bug fix PRs average $1.50-$3.00. Feature PRs average $3.00-$6.00. Refactoring PRs with tests average $5.00-$8.00. These numbers assume basic optimization (CLAUDE.md, model routing). Without optimization, costs run 2-3x higher. With full optimization (skills, structured errors, /compact), costs drop to $0.80-$4.00.

Pricing Breakdown

A PR typically involves multiple Claude Code sessions:

PR Phase Sessions Average Tokens Per Session
Implementation 1-3 50K-150K per session
Testing 1 30K-80K
Code review fixes 0-2 20K-50K per session
Documentation 0-1 15K-30K

Total tokens per PR: 30K-380K, with a median around 120K-200K.

Model Cost for 150K Token PR Cost for 300K Token PR
Haiku 4.5 $0.30 $0.59
Sonnet 4.6 $1.50 $3.00
Opus 4.6 $7.50 $15.00

Feature-by-Feature Cost Analysis

Bug Fix PR (1-2 files changed)

Typical session:
- Read error/bug report: ~500 tokens
- Locate relevant file(s): 5K-15K tokens
- Read file(s): 3K-6K tokens
- Implement fix: 2K-5K tokens
- Run tests: 1K-3K tokens
- Total: 11K-30K tokens
Including context overhead (CLAUDE.md, tool calls):
Input: 25K tokens, Output: 7K tokens
Cost (Sonnet): $0.075 + $0.105 = $0.18 per session
Average sessions per bug fix PR: 1.5
PR total: $0.27

Wait – that seems low. The raw calculation misses context accumulation. Each turn re-reads the entire context:

Realistic bug fix PR (10-turn session):
Turn 1: 5K context -> 5K billed
Turn 2: 12K context -> 12K billed
Turn 3: 20K context -> 20K billed
...
Turn 10: 55K context -> 55K billed
Total input billed: ~280K tokens (sum of context per turn)
Output: ~30K tokens
Cost (Sonnet): $0.84 + $0.45 = $1.29
Average sessions: 1.5 -> $1.94 per PR

Real-world bug fix PR cost: $1.50-$3.00 on Sonnet 4.6.

Feature PR (3-5 files changed)

Session 1 (implementation, 20 turns):
- Cumulative input: ~800K tokens
- Output: ~80K tokens
- Cost: $2.40 + $1.20 = $3.60
Session 2 (tests, 10 turns):
- Cumulative input: ~250K tokens
- Output: ~40K tokens
- Cost: $0.75 + $0.60 = $1.35
Session 3 (review fixes, 5 turns):
- Cumulative input: ~80K tokens
- Output: ~15K tokens
- Cost: $0.24 + $0.23 = $0.47
Total: $5.42

Real-world feature PR cost: $3.00-$6.00 on Sonnet 4.6.

Refactoring PR (5-10 files changed)

Session 1 (refactoring, 25 turns):
- Cumulative input: ~1.2M tokens
- Output: ~120K tokens
- Cost: $3.60 + $1.80 = $5.40
Session 2 (test updates, 15 turns):
- Cumulative input: ~400K tokens
- Output: ~60K tokens
- Cost: $1.20 + $0.90 = $2.10
Total: $7.50

Real-world refactoring PR cost: $5.00-$8.00 on Sonnet 4.6.

PR Review (Claude Code reviewing someone else’s PR)

Typical review session (5-8 turns):
- Read diff: 5K-20K tokens
- Read related files for context: 10K-30K tokens
- Generate review comments: 3K-8K tokens
- Cumulative input: ~100K tokens
- Output: ~20K tokens
- Cost (Sonnet): $0.30 + $0.30 = $0.60

PR review cost: $0.40-$1.00 on Sonnet 4.6. Averaging 30K-80K tokens total.

Real-World Monthly Estimates

Light User (~2 PRs/day)

PR Type Mix Monthly PRs Monthly Cost (Sonnet)
60% bug fix, 30% feature, 10% refactor 44 $127

Heavy User (~4 PRs/day)

PR Type Mix Monthly PRs Monthly Cost (Sonnet)
40% bug fix, 40% feature, 20% refactor 88 $308

Hidden Costs

Context accumulation tax: The biggest hidden cost. A 20-turn session does not cost 20x the first-turn cost. It costs approximately 190x the first-turn context (sum of arithmetic series). This is why /compact mid-session is critical.

Retry loop tax: A single retry loop in a PR session can add $1.50-$5.00 to the PR cost. PRs with failing CI are 2-3x more expensive than PRs that pass on first push.

Scope creep tax: “While you are at it, also fix X” adds 30-50% to the PR cost because the additional context from the first task persists. Start a new session for unrelated fixes.

Review round-trip cost: Each round of code review feedback followed by fixes costs $0.50-$2.00. Minimizing review cycles (through better CLAUDE.md rules and code conventions) reduces total PR cost.

Recommendation

Optimize per-PR cost with this stack:

# CLAUDE.md -- PR Cost Optimization
## PR Protocol
1. One concern per PR (do not combine fixes)
2. Run /compact after implementation, before writing tests
3. Start new session for review fixes (do not accumulate old context)
4. Maximum 3 sessions per PR -- if more needed, decompose the PR
## Session Budget per PR Phase
- Implementation: 150K tokens max
- Tests: 80K tokens max
- Review fixes: 50K tokens max per round
- Total PR budget: 300K tokens

With optimization, per-PR costs drop approximately 40%:

PR Type Unoptimized Optimized Savings
Bug fix $2.50 $1.50 40%
Feature $5.00 $3.00 40%
Refactor $7.50 $4.50 40%

Cost Calculator

PR cost = sum of session costs
Session cost = (sum of per-turn context) x input_rate + total_output x output_rate
Quick estimate:
Bug fix PR: turns x 3K avg context growth x (turns+1)/2 x rate
Feature PR: turns x 5K avg context growth x (turns+1)/2 x rate
Example (feature, 20 turns, Sonnet):
Input: 20 x 5K x 10.5 = 1.05M tokens x $3/MTok = $3.15
Output: ~80K tokens x $15/MTok = $1.20
Total: $4.35

Reducing Per-PR Costs

The highest-impact optimization for per-PR cost is session segmentation. Breaking a PR workflow into separate sessions prevents context accumulation across phases.

Optimal PR Workflow

# Session 1: Implementation only
claude "Implement the user preferences API endpoint in src/routes/preferences.ts.
Add the Prisma model, route handler, and service layer."
# End session after implementation. /cost target: under 100K tokens.
# Session 2: Tests only (fresh context)
claude "Write tests for src/routes/preferences.ts.
The implementation is already done -- read the file and write matching tests."
# End session after tests. /cost target: under 60K tokens.
# Session 3: Review fixes (fresh context, if needed)
claude "Fix the review feedback on the preferences endpoint:
1. Add input validation for the 'theme' field (must be 'light' or 'dark')
2. Add pagination to the GET endpoint"
# End session. /cost target: under 40K tokens.

Segmented total: ~200K tokens ($1.50 Sonnet) Single-session total: ~400K tokens ($3.00 Sonnet) Savings: 50%

PR Cost Optimization Checklist

  • One concern per PR (do not combine unrelated changes)
  • Start new session for each PR phase (implement, test, fix)
  • Run /compact between major phases if staying in one session
  • Use targeted test commands, not full test suite
  • Keep PR scope under 5 files changed (decompose larger changes)
  • Document the PR purpose in the first prompt (avoids exploration)

Tracking Per-PR Costs Over Time

# Create a simple PR cost tracker
echo "date,pr-number,type,sessions,total-tokens,total-cost" > ~/pr-costs.csv
# After each PR, add a line:
echo "2026-04-22,#142,feature,3,180000,1.35" >> ~/pr-costs.csv
# Monthly analysis:
# Average cost per PR
awk -F',' 'NR>1{sum+=$6;count++}END{printf "Avg: $%.2f/PR\n",sum/count}' ~/pr-costs.csv
# Cost by PR type
awk -F',' 'NR>1{type[$3]+=$6;count[$3]++}END{for(t in type)printf "%s: $%.2f avg (%d PRs)\n",t,type[t]/count[t],count[t]}' ~/pr-costs.csv

Tracking per-PR costs reveals trends: if average costs are rising, the codebase is likely growing without corresponding CLAUDE.md/skills updates. If certain PR types are consistently expensive, those workflows need specific optimization.

PR Cost by Language and Framework

Different tech stacks produce different per-PR costs due to varying verbosity, type systems, and build output:

Tech Stack Bug Fix PR Feature PR Notes
TypeScript + React $1.50-$3.00 $3.00-$6.00 Type errors add retry cost
Python + Django $1.00-$2.50 $2.50-$5.00 Less verbose, fewer retries
Go $1.20-$2.80 $3.00-$5.50 Strict typing, but concise errors
Rust $2.00-$4.00 $4.00-$8.00 Complex compiler errors increase retry cost
Ruby on Rails $1.00-$2.00 $2.00-$4.00 Convention-heavy, predictable patterns

Rust PRs are the most expensive due to verbose compiler error messages. Adding structured error wrappers for cargo build reduces Rust PR costs by 30-40%.

Team PR Cost Benchmarks

For engineering managers setting budgets, these benchmarks represent achievable targets for teams with basic optimization in place:

Team Size PRs/Week Target Cost/PR Weekly Budget Monthly Budget
3 devs 10-15 $3.00 $30-$45 $130-$195
5 devs 15-25 $3.00 $45-$75 $195-$330
10 devs 30-50 $2.50 $75-$125 $330-$550

These targets assume Sonnet 4.6 as the default model with occasional Opus escalation. If actual costs consistently exceed these benchmarks by more than 50%, investigate the top 10% most expensive PRs for optimization opportunities – those outliers typically contain retry loops, unscoped exploration, or unnecessary Opus usage.

Which model? → Take the 5-question quiz in our Model Selector.

Try it: Estimate your monthly spend with our Cost Calculator.

See Also