Inside Claude Code's Engine: Understanding the Agent Harness
If you have spent time with Claude Code, you have probably hit this failure mode: the model is clearly sharp, yet it goes off the rails on long tasks—forgetting the goal halfway through, declaring victory before the work is finished, or breaking Feature B while changing Feature A.
The culprit is rarely the model itself. It is the scaffolding wrapped around it: the Harness.
In March 2026, Anthropic published two engineering posts back-to-back on this topic, and the 82K-star community project ECC repositioned itself from a “config pack” to an “Agent Harness performance optimization system.” Industry consensus is crystallizing fast: Harness Engineering is the real differentiator in agentic coding.
This post breaks down what a Harness is, what components make it work, and how Anthropic used it to keep Claude coding autonomously for six hours straight.
The One-Sentence Definition
A Harness is the runtime environment wrapped around an AI model—turning an LLM that only knows how to chat into a reliable engineering system capable of sustaining complex coding work.
The core formula:
1 | Coding Agent = AI Model + Harness (Scaffolding / Runtime Environment) |
Think of it this way: an LLM is like a brilliant engineer with complete amnesia who wakes up every session with no memory of what happened before. The Harness is the workbench, project tracker, handoff notes, and verification checklist you give them so they can keep shipping without derailing.
A common reaction is, “Isn’t that just prompt engineering?” No. Harness design is a subset of Context Engineering. Prompt engineering is about how you talk to the model; context engineering is about the environment the model operates in—which tools it can invoke, when specific knowledge is loaded, and how it verifies its own output.
The Six Components of a Harness
A complete Harness consists of six configuration surfaces:
| Component | Role | What It Maps to in Your Project |
|---|---|---|
| CLAUDE.md | Project-level instruction injection, read automatically on every startup | Coding conventions, directory layout, common commands |
| MCP Servers | External tool capabilities for the agent | Playwright (browser automation), Linear (issue tracking) |
| Skills | Reusable knowledge modules loaded on demand | Frontend design skill, code review skill |
| Subagents | Execute subtasks in isolated context windows | Explore Agent, Plan Agent |
| Hooks | Event-driven automation workflows | Build verification, code formatting, notifications |
| Back-pressure | Mechanisms that let the agent self-verify work quality | Unit tests, type checking, test coverage |
Once you understand these six components, two principles are worth internalizing:
1. Progressive Disclosure
Don’t cram all of your knowledge into the system prompt up front. Load context only when the agent actually needs it. That is the core philosophy behind Skills: by default, the agent doesn’t carry a skill’s instructions in context—it activates and loads SKILL.md only when a matching task arrives.
2. The Context Window Is a Scarce Resource
Research from Chroma confirms that model performance degrades as context grows longer. Every irrelevant tool description and every passing test log adds noise. Anthropic even shipped an MCP tool search feature specifically to solve the context bloat caused by attaching too many MCP servers.
Anthropic’s Harness Architectures in Practice
Anthropic’s two engineering posts illustrate two evolutionary stages of Harness design.
Stage 1: The Two-Agent Architecture
The first problem to solve was straightforward: how do you let Claude build a complete application across multiple context windows without losing the plot?
The answer was two specialized agents:
| Role | Responsibility |
|---|---|
| Initializer Agent | Runs once on the first session; decomposes requirements into 200+ concrete features, scaffolds the repository, and creates init.sh |
| Coding Agent | Runs on every subsequent session; reads the progress log → picks one feature → implements it → writes a git commit → leaves handoff notes |
The feature list is stored in JSON rather than Markdown because models are much less likely to inadvertently rewrite or corrupt structured JSON files:
1 | { |
Every time the Coding Agent starts a shift, it runs the same routine:
1 | # 1. Orient yourself in the working directory |
This deceptively simple architecture solves three core failure modes:
- Trying to do everything at once and blowing up the context window → enforces one feature per session
- Fresh sessions having no idea what happened previously → handoff via progress file + git history
- Declaring “done” while features remain broken or unfinished → enforced verification via the feature list + end-to-end tests
Stage 2: The GAN-Inspired Three-Agent Architecture
The second evolution borrows from Generative Adversarial Networks (GANs). The core insight: when you ask a model to grade its own work, it grades on a generous curve. The fix is separating execution from evaluation across distinct agents.
1 | One-sentence user prompt |
The benchmark numbers speak for themselves. Take the “2D retro game maker” test case:
| Approach | Duration | Cost | Outcome |
|---|---|---|---|
| Single Agent | 20 min | $9 | UI existed, but core gameplay mechanics were completely broken |
| Three-Agent Harness | 6 hours | $200 | Fully working application, including AI-assisted features |
Now look at an even more demanding case—a browser-based DAW (Digital Audio Workstation):
| Phase | Duration | Cost |
|---|---|---|
| Planning | 4.7 min | $0.46 |
| Build (Round 1) | 2h 7m | $71.08 |
| QA (Round 1) | 8.8 min | $3.24 |
| Build (Round 2) | 1h 2m | $36.89 |
| QA (Round 2) | 6.8 min | $3.09 |
| Build + QA (Round 3) | 20.5 min | $9.94 |
| Total | 3h 50m | $124.70 |
The QA Agent caught real, subtle bugs like these:
“The rectangle fill tool only placed tiles at the start and end drag points instead of filling the entire region.”
“Route definition order causedreorderto be matched as aframe_id, returning a 422 error.”
These are the exact kinds of issues that slip past code inspection yet hit users immediately in live interaction.
Field Lessons: What Works and What Doesn’t
The HumanLayer team spent months validating Harness designs in real enterprise codebases and distilled several hard-won lessons.
What Works
- Start simple: Add configuration only after the agent actually fails. Don’t try to design a “perfect” Harness up front.
- Use subagents for context isolation, not roleplay: A clean, focused context window scoped to a specific task outperforms a “Frontend Engineer Agent” persona.
- Stay silent on success, speak up on failure: Four thousand lines of passing tests will drown the context window—surface only error output.
- Replace redundant MCP servers with CLIs: Models already know tools like GitHub and Docker from pretraining; running shell commands directly is leaner and faster than loading an MCP server.
- Control costs with model tiering: Run Opus in the parent session for planning and orchestration, and delegate execution to subagents running Sonnet or Haiku.
What Doesn’t Work
- Designing a “perfect” setup in one shot: A Harness is the product of iteration, not up-front design.
- Installing dozens of MCP servers “just in case”: Every tool description consumes context budget; unused tools are pure noise.
- Auto-generating
CLAUDE.mdwith an LLM: An ETH Zurich study across 138 agentfiles confirmed that LLM-generated instruction files actually reduce performance by 20%+. - Running the full test suite on every turn: Too slow, too long, too noisy. A targeted subset is enough.
You Are Already Running a Harness
After reading all of this, “Harness” might sound like an abstract, heavyweight architecture. In reality, if you use Claude Code, you have already built one.
Look at your own repository:
- Coding standards and command lists in
CLAUDE.md→ project-level instruction injection - Hooks in
.claude/settings.json→ automated control flow - Notification scripts (Feishu/Lark, desktop alerts) → external integrations
- Build-verification Hook → back-pressure
Mitchell Hashimoto (co-founder of HashiCorp) captured Harness Engineering in a single sentence:
Every time you catch an agent making a mistake, take the time to engineer a solution so it can never make that same mistake again.
The next time Claude Code underperforms, don’t jump straight to blaming the model—check your Harness first.
Summary
Anthropic ended its post with an observation worth remembering:
“As models continue to improve, the space of interesting harness combinations doesn’t shrink. It shifts. And the job of an AI engineer is to keep finding the next combination.”
In other words, stronger models let you build Harnesses that tackle increasingly ambitious work. A Harness isn’t a crutch for weak models—it’s the engine that unlocks what strong models can do.
If you are just getting started with Claude Code, focus on writing a crisp CLAUDE.md (under 60 lines is plenty) and adding one or two Hooks that eliminate real friction. That is already a solid starting Harness.
Series Navigation
- Index: Claude Code Complete Guide · Series Index
- Previous: Claude Code Subagents in Practice: Rewriting 20 Blog Posts in Parallel
- Further Reading: Claude Code in Practice · Series Index (10 posts on real-world projects, pitfall postmortems, and daily workflow practices)





