My harness for Claude Code had grown for a year. Investigate, write a spec, review it, plan each slice, build test-first, verify, recap. It worked. It was also expensive, and I no longer knew which parts earned their cost.
A harness is everything around the model: instruction files, skills, hooks, gates, the process the agent must follow. Every piece of it costs tokens. So I asked one simple question: which parts change the result, and which only cost tokens?
To answer it I ran 19 controlled experiments. Each changed one thing and measured the effect on the same task: building one slice of a feature in a Blazor WebAssembly application from an approved spec. Two independent judge agents scored every build on acceptance criteria, on planted bugs caught by the tests, on weak tests and on cost.
The short version
The build cost fell from 5.57 USD to 1.81 USD per slice (−67%). The tests became stronger at the same time: a real page-level integration test, and a mutation score of 100% on the slice's code.
The final run missed my strict quality floor by two minor test gaps, and most conditions were run once. So the last figure is an indication, not a proven mean.
Three things made a measurable difference:
- removing duplicate work;
- keeping tool output out of the context;
- replacing written testing rules by a mechanical check (mutation testing).
Three things did not: shortening or adding instruction text, removing paperwork, and regrouping tool calls. A cheaper model (Sonnet 5.5) held the quality once the mechanical check was in place.
And the results agree with Anthropic's published guidance on almost every point I could test.
The method
Task and baseline
- Codebase: a Blazor WebAssembly line-of-business application, with unit, UI (bUnit) and integration test projects.
- Task: build slice 1 of a "CSV export" feature from an approved spec with 11 acceptance criteria (file name with local date, sorted rows across pages, localized headers, quoting, formula-injection guard, a log record without personal data, and so on).
- Agent: Claude Code, unattended, with a fixed prompt, a fixed tool allow-list and a cap of 300 turns. Opus 5.5 unless stated.
- Baseline: the harness as it was (kit 2.5.6), built three times: 5.59, 5.64 and 5.48 USD. Mean 5.57 USD, spread ±1.5%.
What I measured
Two judge agents scored each build. Neither had seen the build session.
| Judge | What it measures |
|---|---|
| Build judge | Acceptance criteria met (of 11); gate green (0 warnings, all tests, formatting); 2 bugs planted after the build and whether the tests catch them; code quality (0–5) |
| Coverage judge | 10 planted bugs (M1–M10) and how many the tests catch; weak tests (cannot fail, or only check a constant or a mock); whether a real integration test exists; line coverage |
Cost is the build job's cost in USD. I also recorded turns and the tokens re-read from cache, as a proxy for context size.
Quality floor: 11/11 criteria, 10/10 planted bugs, 0 weak tests, a real integration test.
The loop
Every experiment followed the same cycle.
- Propose one improvement, with a reason taken from the previous analysis.
- Modify the harness (a new kit version or a setup change) and install it on the fixed baseline commit.
- Measure: one unattended build, then both judges.
- Analyse: cost, turns and context against the reference; the judges' findings.
- Decide: adopt, reject or "not alone". Adoption required at least 5% lower cost with the quality held, or better quality at an accepted cost.
- Next: the following proposal comes from what the analysis showed, not from a fixed list.
An adopted change became the new reference for the next experiment.
A defect in my own method
After experiment 10 I found a bug in my runner. It started each session on the repository's default branch and switched to the experiment commit afterwards. Claude Code loads the instruction file, the unscoped rules and the lists of skills and agents at session start. So changes to always-loaded text were never in effect in experiments 1–10.
The consequences: experiment 6 (shorter instruction text) is void, and absolute costs before the fix carry extra text. I fixed the runner so sessions start on the experiment commit, re-measured the reference in isolation at 4.29 USD, and re-tested the instruction-text question in experiments 11–12 and 15.
Phase 1: cost at equal quality
Experiments 1 to 10.
| # | Change | Cost USD | Decision |
|---|---|---|---|
| base | Kit 2.5.6 | 5.57 | reference |
| 1 | No slice-plan file, no separate analysis build, short recap | 4.78 (−14%) | adopted |
| 2 | Every build and test through a fresh sub-agent | 8.57 (+54%) | rejected |
| 3 | Many small targeted builds and tests | 6.37 (+33%) | rejected |
| 4 | Fewer, more targeted tests | 4.61 (−4%) | not alone |
| 5 | Integration test first, slice gate filtered to it | 4.77 (0%) | adopted with 4: first real integration test at equal cost |
| 6 | Always-loaded instructions −55% | 4.78 (0%) | void (see the method defect) |
| 7 | Quiet build and test output, read once | 4.11 (−14%) | adopted |
| 8 | Write all tests, then all code (batching) | 4.60 (+12%) | rejected |
| 9 | No recap file, no spec edits | 4.04 (−2%) | not adopted |
| 10 | Parallel independent tool calls | 5.62 (+37%) | rejected |
Result of phase 1: 5.57 → 4.11 USD (−26%) with the quality held.
Phase 2: how much harness do you need?
Experiments 11 and 12.
| Run | Harness | Cost USD | Criteria | Planted bugs |
|---|---|---|---|---|
| Isolated reference | Full kit 2.5.9 | 4.29 | 11/11 | 10/10 |
| 11b | Minimal harness, no spec, from the one-paragraph request | 3.42 | 5/11 | 8/10 |
| 11c | Minimal harness with the approved spec | 3.96 | 10/11 | 10/10 |
| 12 | Kit 2.6.0: build skill cut from 22.6 KB to 3.1 KB | 4.33 | 11/11 | 10/10 |
Without the spec, the agent built less. No date in the file name, no log record, no empty state, and an unrequested grid filter. The saving was real, but it came from building a smaller feature.
With the spec, a minimal harness reached almost the same quality as the full process.
Cutting the build instructions by 86% changed neither cost nor quality.
Phase 3: test quality
Experiments 13 to 19. The judges kept finding the same weaknesses: tests written after the code, tests that could not fail, an integration test that bypassed the page. I tried three ways to fix this.
| # | Change | Model | Cost USD | Criteria | Bugs | Weak tests | Integration test |
|---|---|---|---|---|---|---|---|
| 13 | Home-made check "each test was seen failing first" | Opus | 4.67 | 11/11 | 10/10 | 1 | bypasses the page |
| 14 | Same check, corrected | Opus | 5.31 | 11/11 | 10/10 | 0 | bypasses the page |
| 15 | Seven written rules for efficient tests | Opus | 4.94 | 10/11 | 10/10 | 1 | bypasses the page |
| 16 | Rules + mutation testing as the slice gate | Opus | 5.09 | 11/11 | 10/10 | 0 | drives the page |
| 17 | Mutation gate packaged, stricter, whole changed files | Opus | 5.78 | 11/11 | 10/10 | 1 | bypasses the page |
| 18 | Same as 17 | Sonnet 5.5 | 3.22 | 11/11 | 10/10 | 0 | bypasses the page |
| 19 | Mutation on changed lines only; outer test must drive the page | Sonnet 5.5 | 1.81 | 10/11 | 10/10 | 1 | drives the page |
- The home-made check failed twice (13, 14) on details of the test runner's output. It blocked correct builds and cost more.
- Written rules changed nothing (15). The build broke the very rules it had been given.
- Mutation testing worked (16). Fewest tests of the series, none weak, and an integration test that caught five of the ten planted bugs by itself.
- Scope matters (17, 18). When the tool mutated whole files, the agent wrote tests for existing code to reach the threshold. In experiment 18, 11 of 12 new view-model tests were off-scope.
- Limiting the check to changed lines removed that (19). 38 of 38 mutants killed, 122 outside the slice not scored, no off-scope tests, and 44% cheaper than experiment 18 on the same model.
The overall gain
| Baseline | Final (exp. 19) | |
|---|---|---|
| Build cost per slice | 5.57 USD | 1.81 USD (−67%) |
| Against the isolated reference (4.29 USD) | −58% | |
| Acceptance criteria | 11/11 | 10/11 (one partly met) |
| Planted bugs caught | 10/10 | 10/10 |
| Weak tests | 0 | 1 |
| Real integration test | no (a UI test) | yes, through the page, on the real container |
| Mutation score on the slice's code | not measured | 100% |
| Line coverage | ≈87% | ≈97% |
Where the saving came from, roughly:
- process and output changes on the same model: −26%;
- the cheaper model: about −44% (experiment 17 against 18);
- a correctly scoped check: a further −44% (18 against 19).
What made a real difference
- The spec. It was the single largest quality factor: 5/11 criteria without it, 10–11/11 with it, whatever the rest of the harness looked like. The spec is where the owner's decisions enter the build.
- Removing duplicate work. A separate plan file and a second analysis build repeated what the spec and the gate already did: −14%.
- Keeping tool output out of the context. Quiet build and test output: −14% cost, −27% context. The context grows from what the agent reads and runs, not from the instructions.
- A mechanical check instead of prose. Mutation testing changed how the agent tested. Seven written rules did not.
- Scoping that check to the slice. An unscoped gate creates its own waste.
- Model choice, once the gate exists. Sonnet 5.5 met the same floor as Opus 5.5 at 56% of the cost. The gate, not the model, set the quality.
What had no measurable effect
- Instruction text, in either direction. −86% of the build skill: no change. Seven new rules: no change.
- Paperwork. Dropping the recap file and spec edits: −2%, inside the noise.
- Regrouping work. Batching tests, parallel tool calls, many small commands: all more expensive, because each turn re-reads the context and bigger steps grow it.
What made things worse
- A sub-agent per command: +54% and more than twice the time.
- A home-made verification hook: two versions, two defects, both blocking correct work. A proven tool (Stryker.NET) did the job the first time.
- Stale instructions. Old texts left in the project contradicted the new ones. Two builds from the same base differed by 37%.
Anthropic's guidance holds up
I compared my findings with three Anthropic sources: the Claude Code best-practices page, "Harness design for long-running application development" (March 2026) and "Harnessing Claude's intelligence" (April 2026).
| Guidance | My measurement | Verdict |
|---|---|---|
| Write a spec, then build from it in a fresh session | Spec: 5/11 → 11/11. Every build ran in a fresh session from the spec. | Confirmed, strongest effect of the study |
| Instructions are advisory; what must always happen belongs in a hook or a check | Rules text: no effect (exp. 15). Mutation gate: clear effect (exp. 16, 19). | Confirmed |
| Give the agent a check that returns pass or fail | The mutation check let the agent find and close its own gaps (68% → 83%, 70% → 87%). | Confirmed |
| "Every component in a harness encodes an assumption about what the model can't do on its own"; remove components and measure | Plan file, analysis build and 86% of the build skill removed without loss. | Confirmed |
| Keep the instruction file short | Shorter is harmless, but it saved nothing measurable: the context is dominated by tool output. | Partly: right for clarity, not a cost lever here |
| Keep noisy output out of the main context | Quiet output: −14% cost, −27% context. | Confirmed |
| Sub-agents isolate noisy work | One sub-agent per build or test command: +54%. | Not confirmed as I applied it: isolation has a start-up cost; per command is too fine |
| Agents grade their own work too positively; use a separate evaluator | My independent judges found weak tests, false claims in the test list and mislabelled mutants that the builders reported as fine. | Confirmed |
| Every enforced rule will sometimes fire wrongly and must be maintained | My own red-check hook failed twice. | Confirmed, the hard way |
| Sonnet costs less on routine work | Same quality floor at 56% of the cost, with the gate in place. | Confirmed |
| Stale or contradictory instructions should be audited out | A 37% cost difference traced to stale texts. | Confirmed |
On plan mode
Several third-party articles report that Anthropic now puts less weight on plan mode and more on a written spec. I did not find this stated in the Anthropic pages I read, so I treat it as unverified.
My data is consistent with it. Removing the separate planning step saved 14% with no loss. Removing the spec lost half the acceptance criteria. For this kind of work, the spec is the plan.
Limitations
- One task, one codebase, one slice. A different feature may behave differently.
- Mostly single runs. The baseline spread was ±1.5% over three runs, but I also saw 37% between two runs with contaminated instructions. Differences under 10% should be read as noise. The larger effects (−14%, −44%, +54%) are outside it.
- The final run did not fully meet the floor (one criterion partly tested, one weak test). It is the best cost and the best integration test, not a clean win on every line.
- The judges are models. They were blind to the build session and consistent across runs, but they are not ground truth.
- Early absolute costs are inflated by the isolation defect. Relative results for skill and setting changes hold.
- Evaluation is not free. The two judges cost about 4.5 USD per experiment, more than the final build itself.
Keep what decides, drop what only instructs
The harness I ended with is smaller than the one I started with. It produces better-tested code for about a third of the cost.
The pattern behind every gain was the same: keep what carries decisions (the spec) and what can be checked by a machine (the gate, the mutation check); remove what only tells the model how to work.
The practical advice I draw from the measurements:
- Invest in the spec; it decides what gets built.
- Enforce with a proven tool, not with more text and not with home-made hooks.
- Scope every gate to the change under review.
- Watch tool output, not instruction length, when the cost is too high.
- Measure one change at a time against a fixed task, and start every session on the commit under test.
- Re-test the model choice after the gate is in place.
Measurements
All runs
Costs in USD for the build job only. "Ctx" is tokens read from cache, in millions. "–" means not judged.
| Run | Harness / change | Model | Cost | Turns | Ctx | Criteria | Bugs caught | Weak | Line cov. | Decision |
|---|---|---|---|---|---|---|---|---|---|---|
| base-1 | Kit 2.5.6 | Opus | 5.59 | 147 | 12.30 | 10/11 | – | – | – | baseline |
| base-2 | Kit 2.5.6 | Opus | 5.64 | 150 | 10.81 | – | – | – | – | found one criterion untestable; spec fixed |
| base-3 | Kit 2.5.6, spec fixed | Opus | 5.48 | 149 | 11.06 | 11/11 | – | – | – | reference |
| 1 | No plan file, no analysis build | Opus | 4.78 | 121 | 10.53 | 11/11 | – | – | – | adopted (2.5.7) |
| 2 | Sub-agent per build/test | Opus | 8.57 | – | – | – | – | – | – | rejected |
| 3 | Small targeted commands | Opus | 6.37 | 152 | 15.70 | – | – | – | – | rejected |
| 4 | Test economy | Opus | 4.61 | 118 | 8.84 | – | – | – | – | not alone |
| 5 | Integration test first | Opus | 4.77 | 101 | 9.50 | 11/11 | – | – | – | adopted with 4 (2.5.8) |
| 6 | Instructions −55% | Opus | 4.78 | 126 | 9.39 | – | – | – | – | void |
| 7 | Quiet output | Opus | 4.11 | 103 | 6.93 | 11/11 | 10/10 | 0 | ≈87% | adopted (2.5.9) |
| 8 | Batch red, batch green | Opus | 4.60 | 116 | 8.57 | – | – | – | – | rejected |
| 9 | No recap, no spec edits | Opus | 4.04 | 101 | 7.12 | – | – | – | – | not adopted |
| 10 | Parallel tool calls | Opus | 5.62 | 114 | 7.99 | – | – | – | – | rejected |
| ref-iso | Kit 2.5.9, isolated | Opus | 4.29 | 102 | 8.05 | 11/11 | 10/10 | 0 | ≈87% | isolated reference |
| 11b | Minimal harness, no spec | Opus | 3.42 | 96 | 6.82 | 5/11 | 8/10 | 0 | 100% | rejected |
| 11c | Minimal harness + spec | Opus | 3.96 | 101 | 7.61 | 10/11 | 10/10 | 0 | ≈92% | not adopted as is |
| 12 | Kit 2.6.0, slim build skill | Opus | 4.33 | 121 | 8.60 | 11/11 | 10/10 | 0 | ≈89% | kept (simpler, equal) |
| 13 | Kit 2.6.1, red check | Opus | 4.67 | 117 | – | 11/11 | 10/10 | 1 | ≈90% | check defective |
| 14 | Kit 2.6.2, red check v2 | Opus | 5.31 | 139 | 10.87 | 11/11 | 10/10 | 0 | 100% | check defective |
| 15 | Kit 2.6.3, testing rules only | Opus | 4.94 | 109 | 10.03 | 10/11 | 10/10 | 1 | ≈91% | not adopted |
| 16 | + mutation gate | Opus | 5.09 | 117 | 10.50 | 11/11 | 10/10 | 0 | 100% | adopted (2.6.4) |
| 17 | Kit 2.6.4 | Opus | 5.78 | 152 | 11.60 | 11/11 | 10/10 | 1 | 100% | confirmed, padding found |
| 18 | Kit 2.6.4 | Sonnet | 3.22 | 168 | – | 11/11 | 10/10 | 0 | 100% | model adopted |
| 19 | Kit 2.6.5 | Sonnet | 1.81 | 113 | – | 10/11 | 10/10 | 1 | ≈97% | recommended |
All judged runs had a green gate, caught both bugs planted by the build judge, and scored 4/5 on code quality.
Mutation testing detail
| Run | Scope | Mutants scored | First score | Final score | Tests added for it | Off-scope tests |
|---|---|---|---|---|---|---|
| 16 | Selected files | 45 | 71.4% | 80.0% | 2 | 0 |
| 17 | Whole changed files | 123 | 68.3% | 82.9% | 9 | 5 |
| 18 | Whole changed files | 125 | 70.4% | 87.2% | ≈20 | 11 |
| 19 | Changed lines only | 38 (122 outside, not scored) | 7 survivors | 100% | 0 beyond the slice | 0 |
Tool: Stryker.NET 5.1.0, threshold 80%, no mutant without coverage allowed. Surviving mutants are committed with the slice and classified as killed later, equivalent (unobservable by any test) or accepted for the reviewer.
The ten planted bugs
| Bug | Caught in exp. 19 by | |
|---|---|---|
| M1 | Separator ; changed to , | 1 unit, 2 integration |
| M2 | Byte-order mark removed | 13 unit, 2 integration |
| M3 | CRLF changed to LF | 13 unit, 2 integration |
| M4 | Quoting removed | 4 unit |
| M5 | Formula guard for = removed | 2 unit |
| M6 | Headers in a fixed language | 1 integration |
| M7 | Only the current page exported | 1 integration |
| M8 | Grid sort ignored | 1 integration |
| M9 | UTC date instead of local date in the file name | 1 integration |
| M10 | A person's name added to the log record | 1 unit |
Sources
- Anthropic, Best practices for Claude Code
- Anthropic Engineering, Harness design for long-running application development, 24 March 2026
- Anthropic, Harnessing Claude's intelligence, 2 April 2026
- Stryker.NET