Sulat.com / Writing on AIThursday, December 3, 2026
Enter →
Agent Engineering/3 December 2026

Claude Code’s new harness audit command

Claude Code 2.1.335 adds /claude-api harness-audit, which finds agent loop code written for older models and proposes fixes as a diff. I ran it on a Sonnet 4 era harness and applied the result.

Glossy 3D Claude logo beside an antique gear harness under a magnifying glass, with code diff cards floating alongside
Illustration: Sulat

At a glance

  • Claude Code 2.1.335 adds /claude-api harness-audit, which scans agent harness code for loop limits, reminders, review steps and request settings written for older models and proposes a diff.
  • The audit is read-only. It never runs your code, and it applies edits only if asked.
  • On a Sonnet 4 era test harness it returned 8 high and 13 medium findings. The retired model, temperature and thinking budget would each have failed on the first request.
  • Applying its diff let the harness finish a small edit task on Sonnet 5.5 in four requests. I had no eval, so I couldn't measure whether the removals improve results.
  • Auditing the fixed harness still returned 18 findings, and each run cost a few dollars. Git history was skipped because the machine had git 2.43 and the audit needs 2.45.

Claude Code 2.1.335 adds a command called /claude-api harness-audit. The changelog says it finds agent harness code written for older models, such as loop limits, sub-agents, context management, injected reminders and session-start code, and proposes fixes as a diff. Oikon flagged it on X.

Oikon’s post about the new command.

I wrote a small harness the way people wrote them for Sonnet 4, ran the audit on it, applied the diff it proposed and ran the result against the live API. Then I audited the fixed version too.

Where the command sits

It’s a subcommand of the claude-api skill that ships inside Claude Code. That skill already carries a set of audit and migration flows: migrate moves code to a newer model, prompt-audit checks prompts and tool descriptions for text written for older models, and cost-optimize, latency-optimize, build-eval and hillclimb cover spend, speed and evals. harness-audit covers the code around the model. Its guide tells the audit to say in its report that prompt-audit handles the prompt wording.

The audit is Claude-only by design. If a harness also calls another provider, the guide says to audit only the Claude routes and never propose switching a route to another provider.

How the audit works

The skill’s guide treats a harness setting as a per-model artifact. A guard that’s dead weight on one model may have been load-bearing on the last one, so every finding names the model the code was tuned for and the model it’s audited against. Every removal is a hypothesis to measure, not a conclusion. The guide’s own line is that an audit that finds nothing should change nothing.

Five steps: read the harness, trace each part, sort every part, write the report, propose a diff and apply nothing
The audit reads and reports, then hands you a diff. Illustration: Sulat.

It takes the scope and the target model from your request and the repository rather than asking, and states both at the top of the report. It then inventories the loop, the tools and their results, context handling, sub-agents and review steps, injected text, request settings and anything that runs when a session starts or resumes. It reads usage logs for counts and saved transcripts for signs the model is struggling with a tool, when the repository keeps any.

Next comes provenance: for each component, which failure on which model was it added for, using git blame and commit messages. The audit never runs your code and never calls the model, and it doesn’t read env files, credential files, coding agent settings or MCP configuration beyond server names. Edits are applied only if the request explicitly asks for them. The report ranks findings as high, medium or low confidence, and only high and medium findings with a code action get a hunk in the diff.

The four kinds of code it sorts

Four boxes: guards to test removing, per-model settings to re-set, measured values to measure, facts the model cannot know to keep
Each part of a harness lands in one of four classes, and the class sets the action. Illustration: Sulat.

Guards the model now supplies itself are removal candidates, tested one at a time. The guide’s examples are a read-before-edit gate, a required todo tool, context resets, a fixed chain of single model calls, a same-tier reviewer on every step and specialist sub-agents split by team or product. Per-model settings such as delegation nudges, verification lines and progress-update cadences are re-set from the target model’s section, never removed wholesale.

Measured values such as effort, max_tokens, turn caps, timeouts and compaction thresholds get a measure finding and no new number, with three narrow exceptions. Facts the model can’t supply itself stay: the date a task needs, a permission boundary, a staleness check on a file. The keep list also protects tests, validators, safety classifiers and prompt-injection handling.

It also scans for mechanics that break on newer models, among them thinking budgets, history edits between requests, a token countdown shown to the model and harness text appended inside tool results. A last group is trouble on any model: cache-breaking habits, silent truncation and tool errors that look like success. And it can propose two additions: a tool for unattended agents to report a broken task, and the date or elapsed time where a task turns on it.

The harness I audited

I wrote three small Python files in the style of a Sonnet 4 era agent: a tool loop, a tools module and a reviewer. The loop caps turns, resets its context at 60% of an assumed 200K window, sets a thinking budget and a temperature, and appends a token countdown and a periodic reminder to tool results. A second model call reviews every step, a read-before-edit gate guards the file tool, the system prompt carries a timestamp and the session-start code appends to a notes file every time it runs. The request settings looked like this:

Code
MODEL = "claude-sonnet-4-5"
MAX_TURNS = 25            # sonnet 4 kept looping, cap it
CONTEXT_WINDOW = 200_000
RESET_AT = 0.6            # rotate session before context rot sets in

resp = client.messages.create(
    model=MODEL, max_tokens=1024, temperature=0.2, system=SYSTEM,
    thinking={"type": "enabled", "budget_tokens": 2000},
    tools=TOOLS, messages=messages,
)

I committed it to a fresh git repository and ran Claude Code 2.1.335 headless in that directory with the exact prompt below. The command runs the audit on the Opus 5.5 model, and the audit picked its own target.

Code
claude -p "/claude-api harness-audit" --model claude-opus-5-5 \
  --allowedTools "Read" "Grep" "Glob" "Bash" --output-format json

The machine was a 4 vCPU Intel Xeon at 2.10GHz with 15GB of memory and a 252GB disk, running Linux 6.18 with Python 3.13 and the Anthropic Python SDK 2.16.0.

What the first audit found

It took about five minutes. The code pinned claude-sonnet-4-5, so the audit chose Claude Sonnet 5.5 as the target and returned 8 high-confidence and 13 medium-confidence findings, a short list of values to measure and five flags with no edit. Its summary said that as written the harness couldn’t make a single successful request.

I checked the three claims behind that against the live API. The retired model returned a not-found error saying claude-sonnet-4-5 was retired on 30 November. On Sonnet 5.5, temperature came back as “deprecated for this model”. A thinking budget of the enabled type was refused with a message to use adaptive thinking and an effort setting instead.

Those are the kind of breaks the API would tell you about on the first call. The part a bare error doesn’t give you is the judgement about scaffolding that still runs. The audit flagged the token countdown and reminder text inside tool results, a same-tier reviewer that roughly doubles the requests, and search tools that always return “no results”. It also flagged an edit tool that returns “ok” when nothing was replaced, and a context reset at 120K tokens, below the API’s 150K default compaction trigger. It marked the read-before-edit gate and the required todo tool as flags only, because git history was unavailable.

Applying the diff

The diff applied cleanly to a copy. It moves to Sonnet 5.5, drops the temperature and the thinking budget, deletes the reviewer, the countdown and the reminder, and returns a status for every way a run can end. It also logs token usage, makes tool errors say what failed, and opts into the server-side refusal fallback. I gave the original and the patched copies the same task: open a file, change one greeting and report back.

Before: retired model, temperature and thinking budget rejected. After the diff: four requests and the file edited
The test harness couldn’t send a request before the diff and finished the edit task after it. Illustration: Sulat.

The original never got as far as the API: the current SDK raised a TypeError on the temperature argument first. The patched copy ran on Sonnet 5.5, made four requests and changed the file. That shows the mechanical fixes work. It doesn’t show that deleting the reviewer or the reminders improves results, because I had no eval to measure that against, and the guide says to test each behavioural change on its own.

Auditing the fixed version

I committed the patched harness and ran the same command again, to see whether a harness that already fits the target comes back clean.

RunCode auditedHighMediumReported cost
First auditOriginal harness813US$2.58
Second auditPatched harness47US$2.89
Each run took about five minutes. Cost is what the CLI reported for the run.

It didn’t come back clean. It returned 18 findings in all, four high, seven medium and seven low, plus eight patches. Its first finding was that max_tokens of 1024 is too small for a model that thinks by default, since thinking counts toward the limit. It also noted that effort is never set, that the two search tools I’d left in return “not implemented” while their descriptions say they search, and that a cut-off summary would silently produce an empty one. The last of those became a patch that ends the run as “compaction failed”.

Other items were a judgement call. It treated the harness as unattended because run() returns only a final response, and on that basis proposed a tool for the agent to report broken tasks. It also priced its own suggested test plan at roughly US$1,000 to US$1,200, which I didn’t run. For a six-line edit task, that plan is out of proportion.

Where it fell short

Provenance is the audit’s central idea, and it didn’t work here. The guide’s git commands need git 2.45 or newer, and this machine has 2.43, so both runs skipped history. Provenance lines read “unknown – lookup skipped” or came from code comments alone, and the guide caps findings that rest on that line at low confidence with no edit. That’s why the read-before-edit gate and the todo tool were flagged and never patched.

In the first run the audit also ran git ls-files and git log --oneline, which its guide doesn’t allow. It said so in the report and didn’t use the output as evidence. Each run needed an API key and Claude Code on a recent version, and a model run to read a few hundred lines of code cost a few dollars.

Who should run it

If you have a Messages API loop that was tuned for an older model, it’s worth one run on a branch. Read the report first, apply the changes the API would reject anyway, and treat everything labelled behavioural as a hypothesis for your own eval. Check your git version before you rely on the provenance step. If you don’t have an eval, the skill’s build-eval flow is where it sends you.

What I couldn’t test

I didn’t run it on a real production harness, and I didn’t measure whether removing any flagged component changes results. I couldn’t run the git-history step on this machine. I also didn’t try the Bedrock, Vertex or Foundry routes the guide covers.