Your personal memory, across sessions, agents, and devices.

Claude Code Evaluation: How to Build a Harness

memU Team memU Team

Is Claude Code getting better at our work, or are we just getting used to it? A Claude Code evaluation harness answers that with numbers. It runs the agent on a fixed set of tasks and checks the result with tests. Every transcript is kept so you can see why a run failed. Below are the parts of a harness, the flags that make headless runs repeatable, and how to score task completion. The last section covers memory, which quietly shifts results between runs.

What is a Claude Code evaluation harness, in one sentence?

A Claude Code evaluation harness is the infrastructure that runs Claude Code on fixed coding tasks and grades each attempt with an objective check, so you can compare runs.

The definition follows Anthropic's January 9, 2026 engineering post, Demystifying evals for AI agents. That post separates two things people often call "the harness." The evaluation harness runs the tasks and grades them. The agent harness (or scaffold) is what lets a model act as an agent. In this setup, Claude Code is the agent harness and your eval system wraps it.

Anthropic's post also fixes the vocabulary. A task is one test with inputs and success criteria, and each attempt at it is a trial. Graders score the attempt, and the transcript records every tool call and output. The outcome is the final state of the environment. It can differ from what the agent says it did.

How does a harness differ from a public benchmark?

A public benchmark ranks models on someone else's tasks. Your own harness runs Claude Code on your repo, with your CLAUDE.md loaded.

Aspect Public benchmark (SWE-bench Verified, Terminal-Bench) Your own harness
Tasks Fixed, published set 20 to 50 tasks from your own failures, then more
Environment Their Docker images Your repo and toolchain
Grader Their tests Your tests, plus checks you write
What it answers How a model compares with other models Whether a change to model, prompt or setup helps your team
Memory and instructions Usually none Whatever your sessions really load

SWE-bench Verified is a set of 500 engineer-confirmed solvable problems taken from real GitHub issues. Its evaluation guide applies each patch in Docker and runs the repository's tests. An instance counts as resolved when the patch makes the required tests pass. Terminal-Bench measures resolution rate on end-to-end terminal tasks. It was on version 4.0 when we checked in October 2026.

How do you run Claude Code inside a harness?

Run it headless. The headless docs describe claude -p, which takes a prompt and exits with code 0 on success. A typical eval call looks like this:

claude --bare -p "$(cat instruction.md)" \
  --output-format json \
  --allowedTools "Bash,Read,Edit" \
  --max-turns 40

What each flag does:

  • --bare skips auto-discovery of hooks, skills, plugins, MCP servers, auto memory and CLAUDE.md. Anthropic recommends it for scripts and CI "where you need the same result on every machine." It needs an API key from the environment, since it never reads your subscription login.
  • --output-format json returns the result with a session ID. It also reports an estimated cost. The docs call the cost a client-side estimate that can differ from your bill.
  • --allowedTools pre-approves what the agent may use. In a manual-mode run, Claude Code denies any unlisted call that needs approval.

You do not have to build the runner yourself. Harbor, from the makers of Terminal-Bench, is a framework for running "any agent with any model on any task" in sandboxes. Its pre-integrated agents include claude-code, codex and cursor-cli. Its task format is a folder with an instruction file, an environment spec such as a Dockerfile, and a tests folder. The test script writes a numeric reward to a file after the agent finishes. You can copy that layout without adopting Harbor.

How do you measure task completion rate for Claude Code?

Grade the final state of the code. For coding work, Anthropic's post asks one question: "does the code run and do the tests pass?" Write a test for each task that fails before the fix and passes after it. Also run the existing suite so a fix that breaks something else does not count.

Then run several trials per task, because the same prompt gives different results. Two metrics from Anthropic's post cover most needs:

Metric Meaning Use it when
Completion rate Share of all trials whose tests pass Tracking progress over time
pass@k Chance that at least one of k trials succeeds One good answer is enough, such as a developer picking from options
pass^k Chance that all k trials succeed The agent runs unattended, such as a CI job

pass@k rises as k grows, while pass^k falls. A team running Claude Code in GitHub Actions cares more about pass^k, because nobody is there to rerun a bad attempt.

Anthropic suggests two kinds of suites. Capability evals should start at a low pass rate so there is room to climb. Regression evals should sit near 100% and catch backsliding. Tasks that pass reliably can graduate from the first suite to the second.

What makes Claude Code evals go wrong?

The most common mistake is trusting the score without reading transcripts. Anthropic's post says: "Read the transcripts!" A 0% pass rate across many trials usually means the task or grader is broken. A low score can also hide a grader that rejects valid solutions.

The second mistake is uncontrolled context. The memory docs say every Claude Code session loads CLAUDE.md files and auto memory at start. For auto memory, that is the first 200 lines or 25KB of MEMORY.md, whichever comes first. Auto memory lives per repository under the user's home directory. Two engineers running the same eval can therefore load different context and get different scores. You can turn it off with the auto memory setting or the CLAUDE_CODE_DISABLE_AUTO_MEMORY environment variable. Bare mode skips both CLAUDE.md and auto memory.

The third mistake is grading only text. A model-based grader can judge code quality or how the agent explained itself. Anthropic notes these graders cost more and need calibration against human review. Add them on top of tests.

How do you start?

  1. Collect 20 to 50 real tasks from issues or bugs Claude Code got wrong. Anthropic calls that range "a great start."
  2. Put each in a container with a failing test and a reference solution, so you know the task is solvable.
  3. Run each task three to five times in bare mode and record the transcripts.
  4. Report completion rate and pass^k per model or setup, and read every failure.
  5. Then turn on the context you use day to day, such as CLAUDE.md or a memory tool, and run again. The difference is the measured value of that context.

For pull request checks, the Claude Code GitHub Action accepts CLI arguments through its claude_args input, including turn limits. Keep the scored eval separate from that day-to-day automation, so a workflow change does not move your baseline.

The bottom line

Build a small harness from 20 to 50 real failures, graded by tests, before you trust any public score for your codebase. Run several trials per task in bare mode for a clean baseline, then measure memory and instruction files as a separate variable. Read the transcripts whenever the number moves.

How do you keep eval lessons from getting lost?

Evals produce two things: a score and a pile of transcripts. The score lands in a dashboard. The lessons in the transcripts often go nowhere: the edge case that tripped the agent, or the test command it kept getting wrong. The next session starts without them, and the same mistake shows up in the next run. Memory would keep those lessons, and it is also the variable your eval has to pin down. Keep it on for daily work. In the baseline, switch it off or measure it on purpose.

memU keeps that kind of knowledge as a shared wiki of readable Markdown files. A scheduled background task slices new session logs into jobs. The agent decides what to keep and writes it as memory or skill Markdown. memU's memory service makes no LLM calls. It only stores and retrieves what the agent prepared. A standing instruction in CLAUDE.md or AGENTS.md tells the agent to retrieve. Bare mode skips CLAUDE.md, so a bare run is your baseline without memU, and a normal run is the comparison.

The hosted version is free and syncs across devices. Get an API key from memu.so and send Claude Code one message:

Read https://memu.pro/SKILL.md, follow its instructions to install and configure memU, API Key is YOUR_MEMU_API_KEY.

The self-hosted setup and the support list for other agents are in the memU GitHub repository.

FAQ

What is the difference between an eval harness and an agent harness?

An agent harness lets a model act as an agent, and Claude Code is one. An evaluation harness runs tasks against that agent and grades the results.

How many tasks does a Claude Code eval need?

Anthropic suggests 20 to 50 simple tasks drawn from real failures as a starting point. Grow the set as you find new failures.

Should I use SWE-bench to evaluate Claude Code?

Use it to compare models in general. For your own team, a small harness built from your repository's tasks says more, because it runs with your tools and your instruction files.

How do I make Claude Code eval runs reproducible?

Run headless with bare mode, which skips auto memory and CLAUDE.md along with hooks and plugins. Pass any context you want through flags, and run several trials per task.

What is pass^k?

pass^k is the probability that all k trials of a task succeed. It falls as k grows and fits agents that run unattended, where every attempt has to work.