AgentReceipt

How much does Cursor agent cost per refactor?

Many files touched with mechanical edits; context grows fast, so cache behaviour dominates the bill. Here is what that costs at list prices, how much of it is usually avoidable, and real numbers from itemized receipts as they come in.

Short answer

A tidy Cursor agent refactor of about 55 model calls costs around $1.24 on GPT-5.1 Codex and $4.54 on Claude Opus 4.8. One coffee break that expires the cache plus one fix-and-test loop takes that to $1.45 and $5.52.

Billed by Cursor from your plan’s usage; the figures here are the equivalent at the labs’ API list prices.

Real medians from receipts

Cursor agent does not write a session log we can read yet, so there are no measured receipts for it. The numbers below are worked examples at the equivalent API list prices.

Worked example: one refactor

Worked example · modelled, not measured
ModelTidy session+1 idle miss, +1 loopCache hit
Claude Sonnet 4.6$2.72$3.3198%
GPT-5.1 Codex$1.24$1.4598%
Claude Opus 4.8$4.54$5.5298%

55 model calls, 26k tokens of starting context growing about 1.9k per call, 700 output tokens per call, list prices. The second column adds a 9-minute pause that expires the cache and a 3-attempt fix-and-test loop.

Where the money goes

In the GPT-5.1 Codex example, cache reads are $0.68, cache writes $0.17 and output $0.39. Because the whole context is re-sent on every call, the bill grows with the square of the session length: a refactor that takes twice as many calls costs roughly three to four times as much.

In the messy version, the expired cache alone adds $0.14 for one turn, and AgentReceipt marks $0.18 of the session as avoidable.

How to make a refactor cheaper

  • Keep one refactor per session and /clear between tasks, so the context stays small.
  • Do not leave a session idle for more than 5 minutes in the middle of the work; the cache expires.
  • Stop retry loops after two failed attempts and give the agent the exact error.
  • Trim tool output (head, grep, line ranges): every token stays in context for the rest of the session.
  • Use a smaller model or a subagent for exploration; save Claude Opus 4.8 for the hard edits.

Itemize your own session

Drop a Claude Code or Codex log. It is parsed in your browser, and you get your real numbers instead of a model.

Drop a session log here

Claude Code ~/.claude/projects/…/*.jsonl, a Codex rollout ~/.codex/sessions/…/rollout-*.jsonl, or the claude-code-action execution file.

Parsed in your browser. Your prompts and code never leave this tab.