Solution · Headless CI
Your agent runs on every pull request. Pay less for each run.
Add two env lines to your GitHub Actions workflow. Same agent, same prompt, same model: Claude Code headless on Sonnet 5.5 cost 24% to 34% less per run on 4 CI jobs.
Label F1 pass 5 of 7 direct, 4 of 7 with Context Mode. Workflow · Tasks
Every run sends the same prompt. You pay for it each time.
Each run writes the same tool list and system text to the cache again.
Test logs and diffs go to the model in full, on every turn.
A job on every pull request and issue repeats that cost each time.
Keep your agent and your workflow. Change the base URL.
- 01Install your agent as usual
The official Claude Code action, or the native installer for
claude -p. - 02Add the env lines
npx @context-mode/cli ci initwrites them: the gateway base URL and your CI key as a header. - 03Each run sends less
The stable part of the prompt goes first, so the next run reads it from cache. Repeated output goes once.
The same task, run twice. Cost per run.
| CI job | Context Mode | Direct | Lower | 95% range | Saved per 1,000 runs |
|---|---|---|---|---|---|
| CI-failure fix | $0.0281 | $0.0442 | 33.9% | 25.1 to 43.6% | $16 |
| Issue triage and labels | $0.0183 | $0.0262 | 29.6% | 21.1 to 38.8% | $8 |
| Release notes | $0.0987 | $0.1333 | 25.7% | 7.2 to 42.7% | $35 |
| @claude fix (issue to PR) | $0.0736 | $0.0902 | 23.7% | 11.4 to 35.7% | $17 |
Claude Code headless (claude -p), Sonnet 5.5, 2026-11-01, the live gateway. Each task ran direct and through Context Mode, back to back. Warm runs, cost per run at list price. Lower: 1 minus the geometric mean of the per-task cost ratios, so it can differ from the two mean costs. A row is published only when its whole 95% range is above 0.
Proof: the round · raw results · the plan, written first · run it in your own repo · Method and sources →
What this uses.
The CI key, the workflow and what each header does.
Long tool output is shortened before the model reads it.
Every paired run, with its evidence file.
Your own Anthropic account pays the model.
Codex, OpenCode and Pi run through the same gateway in CI: set them up.
Keep your agent in CI. Pay for less of what it sends.
npx @context-mode/cli ci init writes the workflow. 1,000 requests free, no card.