What does an agentic Claude Code PR cost?
What does an agentic Claude Code PR actually cost? Per-PR data for Sonnet and Opus, how prompt caching cuts spend 40-60%, and how to track it per developer.
Pranav Lakhani
CTO, CloudByte AI
- Median Sonnet cost per PR
- $0.85
- Agentic vs inline cost
- 30-100x
- Savings from prompt caching
- 40-60%
- Spend from top 10% sessions
- 45-55%
TL;DR
- An agentic Claude Code PR run processes 150-450k tokens versus 2-5k for an inline suggestion, a 30-100x jump in cost.
- A merged PR typically costs $0.30-$3.50 on Claude Sonnet and $1.50-$18.00 on Claude Opus, with a median of $0.85 on Sonnet.
- Scope discipline matters more than model choice: teams that scope tasks in CLAUDE.md see 3-4x lower median costs than teams running open-ended agents.
- Prompt caching cuts agentic session cost by 40-60%, so track all four token types separately instead of total tokens.
- The top 10% of sessions drive 45-55% of agentic spend, so set a per-session alert at 3x the team median and track cost per merged PR.
Inline Claude Code suggestions cost a few cents per completion. Agentic PR runs — where Claude reads the repo, edits files, runs tests, and fixes failures without developer input — cost something else entirely.
Most teams discover this on their first month's invoice.
The shift from inline suggestions to agentic workflows is not gradual: it is a step change in token consumption. An inline suggestion processes 2–5k tokens. An agentic PR run that reads five files, edits three, and survives two test-fix cycles processes 150–450k tokens. The cost difference is 30–100×.
Here is what that actually looks like in practice, and how to set team targets before the bill arrives.
How much does an agentic Claude Code session actually cost per PR?
A typical agentic Claude Code session costs $0.30–$3.50 per merged PR using Claude Sonnet, and $1.50–$18.00 per merged PR using Claude Opus.
Across engineering teams in the CloudByte AI dataset, the median agentic session on Claude Sonnet runs $0.85 per merged PR. The top decile runs $4.20. The range is wide because cost is driven by three variables that differ sharply across tasks:
- Context size — how many tokens the agent reads before making any edits
- Tool call cycles — how many read → edit → test → fix loops the task requires
- Cache hit rate — whether the project context (CLAUDE.md, repo structure, test output) is reused from prior calls or repriced from scratch
Teams at the low end ($0.30–$0.80 per PR) tend to have: focused task scope, clear CLAUDE.md instructions that orient the agent quickly, and stable project context that caches well across sessions. Teams at the high end ($3–$10+ per PR) tend to have: open-ended task descriptions, large monorepos without scoping instructions, and fresh-context runs with no caching benefit.
What drives token consumption in an agentic run
A mid-complexity agentic PR — one feature file edited, three tests updated, one test failure fixed — has roughly this token profile:
| Phase | Input tokens | Output tokens | Notes |
|---|---|---|---|
| Initial context read | 60–120k | 2–5k | Repo structure, relevant files, CLAUDE.md |
| Planning + first edit | 80–140k | 4–8k | Full context re-read + edit generation |
| Test run + diagnosis | 20–40k | 2–4k | Test output parsed, failure identified |
| Fix cycle (×1–2) | 80–140k each | 3–6k each | Context re-read for each fix pass |
| Total (1 fix cycle) | 240–440k | 11–23k | Mid-complexity, scoped task |
At Sonnet pricing ($3/M input, $15/M output), that mid-complexity run costs $0.88–$1.67 without caching — or $0.40–$0.80 with cache hits on the stable context portions.
Cache type matters for cost attribution. Anthropic charges four token types at different rates: standard input ($3/M), cache write ($3.75/M), cache read ($0.30/M), and output ($15/M). An agentic run that re-reads the same CLAUDE.md and file tree across three tool calls pays full price on the first read and 10× less on subsequent reads. Tracking all four types separately — not just "total tokens" — is the only way to know whether your caching is working.
Why does cost per PR vary so much between teams?
Agentic cost variance is driven by scope discipline more than model selection — teams that define task scope explicitly in their CLAUDE.md see 3–4× lower median costs than teams that run open-ended agents.
The three highest-cost patterns in our data:
1. Large-context codebases without scoping instructions. An agent told to "fix the billing bug" on a 400k-token codebase will read a large fraction of that codebase before narrowing to relevant files. An agent told to "fix the billing bug — the relevant code is in src/billing/ and the failing test is test/billing/charge_test.ts" reads a fraction of the tokens. Same task, 4–6× lower cost.
2. High fix-cycle counts. Each test failure that requires a fix cycle re-reads most of the context. A task requiring 2 cycles costs 2× one requiring 1. A task requiring 6 cycles because of vague initial instructions costs 6×. The fix is better task instructions, not a faster model.
3. Unintentional Opus selection. Teams that allow developers to freely switch models often find Opus selected for routine tasks where Sonnet performs equivalently. A Sonnet run costing $0.85 costs $4.25 in Opus for the same output. Model selection should be a team policy, not a per-developer preference left to whoever opens the config.
How do agentic Claude Code costs compare to other AI coding approaches?
| Approach | Typical cost per PR | Cost driver | Cache benefit |
|---|---|---|---|
| Claude Code inline suggestions | $0.03–$0.20 | Short completions, low context | Minimal |
| Claude Code agentic (Sonnet) | $0.30–$3.50 | Multi-file context + tool calls | High (40–60% reduction) |
| Claude Code agentic (Opus) | $1.50–$18.00 | Same context × 5× pricing | High (40–60% reduction) |
| GitHub Copilot (per-seat, $19/month) | $0 per PR | Fixed seat fee, usage-based costs hidden | N/A |
| Self-hosted LLM (GPU infra) | $0.05–$0.80 | Compute + infra, no per-token fee | N/A |
The comparison with GitHub Copilot is worth unpacking. Copilot is billed per seat — there is no per-PR cost signal. That makes it look cheaper per PR at low usage, but it also makes usage invisible: you cannot tell which developers generate the most value from their seat, because there is no cost tied to output.
Agentic Claude Code sessions create a cost signal per task that Copilot does not. That signal is an asset — it is the data you need to answer whether your AI investment is producing proportionally more output.
How do you track agentic AI costs at the team level?
Track cost per PR — not cost per session or cost per token — and set team-level targets before individual developer spending diverges.
The Anthropic Analytics API gives you aggregate token counts per model per day. It does not give you per-developer, per-PR, or per-project data. To get team-level agentic cost tracking you need:
-
Session-level capture. A sync agent that records developer identity, project context, and all four token types (input, output, cache_creation_input, cache_read_input) for each Claude Code session.
-
PR linkage. Match each agentic session to the PR it produced, using the branch name and commit author recorded at session start.
-
Team aggregation. Sum session costs by developer and by project, then divide by PRs merged in the same period to get cost per PR per developer.
-
Alert thresholds. Set a per-session cost alert at 3× the team's median session cost. When a single session exceeds that threshold, investigate before it becomes a weekly pattern.
What cost-per-PR data tells you that token counts alone don't
Cost per PR combines the spend signal with the output signal. A developer running $3 agentic sessions that each produce a shipped feature is generating ROI. A developer running $3 sessions that each fail to produce a mergeable PR is a signal worth investigating — the task scope may be wrong, the CLAUDE.md may be missing critical context, or the model may need switching.
CloudByte AI tracks agentic AI cost per developer, per session, and per project — mapped to git output so you can see whether agentic spend correlates with shipped work.
What is a reasonable cost-per-PR budget for agentic AI?
A $1–$3 target per merged PR is achievable for most teams using Claude Sonnet with prompt caching and scoped tasks, and breaks even against developer time saved at a comfortable margin.
At a fully-loaded developer cost of $100–$150/hour, a 30-minute task saved by an agentic run is worth $50–$75. An agentic session that merges the PR for $1.50 has a 30–50× return on the session cost.
The ROI concern is not average cost but outlier sessions. In our data, the top 10% of agentic sessions by cost account for 45–55% of total agentic spend. These outliers are usually identifiable: high token counts, more than four fix cycles, and tasks that were underspecified or hit unexpected codebase structure.
Setting per-session cost alerts — not just monthly budget alerts — catches outliers before they accumulate. A threshold of 3× the team's median session cost fires on the sessions that need investigation without generating noise on normal usage.
For a team of 20 developers, each running 3 agentic sessions per day at a median $0.85 per session, monthly agentic spend runs ~$1,530. That is approximately one hour of fully-loaded engineering time per month. The productivity return only needs to exceed one engineer-hour to be net positive — the real question is whether the spend is distributed efficiently across the team, not whether the total is large.
Conclusion
Agentic Claude Code PRs are cheap relative to the engineering time they save, but only when task scope, caching and model choice are under control. A $1-$3 target per merged PR on Sonnet is realistic, and at $100-$150 per developer hour a single saved 30-minute task covers the cost of dozens of sessions.
Start by measuring cost per merged PR per developer and project, using all four token types and linking each session to the PR it produced. Then make Sonnet the team default, add scoping instructions to CLAUDE.md, and alert on any session above 3x the team median so outliers get investigated before they become a weekly pattern.
Frequently asked questions
A typical agentic Claude Code session that reads context, edits files, runs tests, and fixes failures costs $0.30–$3.50 per merged PR using Claude Sonnet, and $1.50–$18.00 using Claude Opus. The range is wide because cost scales with codebase context size, the number of edit-test-fix cycles, and whether prompt caching is active. Teams with stable project context and well-defined CLAUDE.md instructions sit at the lower end; teams running fresh-context agents on large codebases sit at the upper end.
Agentic cost variance is driven by three factors: context size (a 500k-token codebase read costs 10x more than a 50k-token read), tool call cycles (each edit-test-fix loop reprocesses the full context), and model selection (Opus costs 5x more per token than Sonnet). A well-scoped task in a small, focused codebase with clear CLAUDE.md instructions can complete for $0.30. An open-ended refactor in a 200k-token monorepo without scoping instructions can exceed $10 before the agent finishes.
Anthropic's prompt caching reprices repeated context reads at approximately $0.30/M tokens vs $3/M for fresh Sonnet input — a 90% reduction on cached portions. For agentic tasks where the agent re-reads the same files across multiple tool calls, caching cuts total session cost by 40–60%. The benefit is highest when project context (CLAUDE.md, repo structure, test scaffolding) is stable across sessions so agents don't repeatedly pay full price for the same files.
Use Sonnet as the default for agentic PR runs; reserve Opus for tasks where reasoning quality is the bottleneck. Opus costs 5x more per token than Sonnet. For the majority of feature work, bug fixes, and refactors, Sonnet delivers equivalent output at a fraction of the cost. The exception is complex algorithmic tasks where Opus's higher reasoning quality reduces fix cycles — if Opus completes in 2 cycles where Sonnet takes 5, Opus may be cheaper overall despite the per-token premium.
Tracking agentic costs at the team level requires correlating token counts from each session to the developer and PR that generated them. Anthropic's Analytics API provides aggregate token usage per model per day, not per developer or per PR. You need a session-level capture layer that records developer identity, project context, and all four token types (input, output, cache_creation_input, cache_read_input) per agentic run, then maps those records to merged PRs via git metadata. CloudByte AI does this automatically for Claude Code teams.
A $1–$3 cost-per-PR target is achievable for most engineering teams using Claude Sonnet with prompt caching and well-scoped tasks. At a fully-loaded developer cost of $100–$150/hour, a task that saves 30 minutes of manual work is worth $50–$75 — well above a $1.50 agentic session cost. The more important metric is outlier control: the top 10% of agentic sessions by cost account for 45–55% of total agentic spend. Setting per-session alerts at 3x the team median catches these before they accumulate.
