What a harness is
A harness is everything around the model when it writes code for you: the instructions it reads, the knowledge base it can look things up in, the specification of the task, the commands it may and may not run, the tests, linters and type checks that judge its output, and the review that reads the change before a person does. The model sits in the middle. The harness decides what it sees, what it can touch, and what happens to its work.
The term caught on in early 2026, when OpenAI published "Harness engineering: leveraging Codex in an agent-first world". A small team built a product of around a million lines over five months with the rule that no line was written by hand. Progress was slow at first, and the post puts it down to an underspecified environment: the agent lacked tools, structure and documentation. The engineers stopped writing features and started asking, after each failure, what capability was missing and how to make it visible and enforceable for the agent.
Birgitta Böckeler took the idea further on martinfowler.com in "Harness engineering for coding agent users". She splits a harness into guides, which steer the agent before it acts, and sensors, which observe what it did and let it correct itself. She also makes the point this article builds on: a good harness should not necessarily aim to fully eliminate human input, but rather "direct it to where our input is most important".
The practical consequence for an engineering leader: the model is the part you can swap. The harness is the part your team owns, keeps in git and improves. It is also the difference between agentic development, where each developer drives an agent their own way, and an AI SDLC, where the whole team works inside one process.
Harness, context and prompt: three different jobs
These three words get used as if they meant the same thing. They answer different questions and live in different places.
| Prompt engineering | Context engineering | Harness engineering | |
|---|---|---|---|
| Question | How do I phrase this request? | What should the agent see right now? | What must the system forbid, check and correct? |
| Lives in | One person's head and chat history | The session: files loaded, tools offered, search results | The repository and the pipeline: rules, specs, tests, CI, review |
| Survives | One conversation | One session | Every session, for every person |
| Fails as | A good result nobody can repeat | An agent that misses what it needed, or drowns in what it did not | An agent that may do things nobody would allow |
Context engineering is one layer inside the harness, not a rival to it. A perfect context does not stop an agent from pushing to main; a hook that refuses the push does.
The four layers of a harness
A working harness does four things: it constrains, informs, verifies and corrects. Each maps to files you can version and review like code.
1. Rules and boundaries (constrain)
What the agent may change, which commands it may run without asking, which services it may reach, and what is off limits. Prose rules belong in an instructions file such as AGENTS.md or CLAUDE.md (see AGENTS.md and CLAUDE.md). Rules that matter must also be enforced by the tool: permission settings, a list of forbidden commands, a hook that refuses them at the moment they run.
2. Knowledge base (inform)
What a new senior engineer would ask in their first week: the architecture, the contracts between services, the decisions already taken and why. The OpenAI team kept its top-level instructions file short, about a hundred lines, and used it as a table of contents into a docs/ folder treated as the system of record, with architecture notes and a quality score per domain. One long instructions file crowds out the task and goes stale.
3. Specifications (inform)
What this particular task must do and how anyone will know it does. The specification carries acceptance criteria, each one tied to a check. Spec-driven development covers this layer in depth.
4. Quality gates (verify and correct)
Tests, linters, type checks, architecture rules, an agent's review, and a person's review where the stakes call for it. The rule for this layer: if a check exists only in prose, it is a wish. A rule such as "the UI layer never imports the database client" becomes an architecture test that fails CI, with an error message that tells the agent how to fix it.
# AGENTS.md (a skeleton: short, with links)
## Commands
- Install: make setup
- Test everything: make test # run before saying a task is done
- One module: make test MOD=billing
## Layout
- src/billing/ invoices, discounts, renewals
- src/web/ UI only; never imports src/db directly (enforced by tests/arch)
## Never
- edit migrations that are already on main
- change a public API without a line in docs/api-changes.md
## Read before you start
- docs/architecture.md the map of modules and who calls whom
- specs/<task>.md the task's spec and its acceptance criteria
Fix the defect in the harness, not in the code
This is the habit that separates a harness from a pile of config files. When the agent gets something wrong, the reflex is to open the file and fix it by hand. That fixes today's change and teaches the system nothing: the next task makes the same mistake.
Take an example. An agent implements a promo code feature. In review it turns out a discount can be applied twice when a customer reloads the checkout page, because the code checks for an existing discount after writing the new one. A developer could swap the two lines and move on. The harness way asks three questions instead:
- Was the spec wrong or silent? It never said a discount is applied at most once per order. Add that as an acceptance criterion, and add a line to the spec template: "state what may happen at most once".
- Was there a check that should have caught it? No test exercised a repeated request. Add one, and a rule in the instructions for the payments module: every write that changes money has a test that repeats the request.
- Was the agent missing knowledge? The codebase already had an idempotency helper the agent never found. Link it from the module's instructions.
Then the agent fixes the code, against the new criterion and the new test. The fix cost a few minutes more than a hand edit; every later change to money code now gets the rule for free.
Three mechanics keep this loop honest:
- A limit on retries. An agent that fails the same gate again and again is not converging. After a small fixed number of attempts, hand the problem to a person rather than loop.
- Read the hand edits. Every commit a person makes on an agent's branch before merge is a candidate rule or check. Look at them weekly.
- Link defects to specs. For each escaped defect, decide whether the spec was wrong (fix the spec template) or the spec was right and the code wrong (fix rules and checks).
Where a person decides: by blast radius
A harness does not remove people. It moves them to where a wrong decision is expensive. The useful question is not "is this task hard?" but "how far does a mistake reach?"
| Blast radius | Example | Who accepts |
|---|---|---|
| One module, covered by tests | A new filter on an internal report | The automated cycle: agent writes, agent reviews, CI passes, a person merges on a prepared summary |
| Public API or stored data | A new field in a public endpoint, a migration | A person at a checkpoint, before the change goes on |
| Other teams or shared infrastructure | A change to a shared library, a network rule | The owners of that system, through their usual review |
The old rule still holds: an author does not approve their own change. An agent that wrote the code is not the one that signs it off, and the agent that reviews it is not the one that merges.
Starting a harness in your team
A first version takes days. Agreeing who owns it takes longer, so start that conversation on day one.
- Measure where you areLead time, release frequency, the share of changes reworked, time a pull request waits for review. Without a baseline you cannot tell a harness that helps from one that only feels good. See DORA metrics.
- Write a short instructions fileCommands, layout, the handful of things that are never allowed, links into the knowledge base. Under a page.
- Turn review comments into checksRead the last month of review threads. Every comment that appears three times becomes a linter rule, an architecture test or a hook.
- Give tasks a specAcceptance criteria, each with the test that proves it. Small tasks can skip this; anything that touches more than one module should not.
- Run real tasks through itTwo or three from the backlog, start to finish. Every hand edit and every repeated question becomes a change to the harness.
A pilot is the natural place to do this with one team before others follow.
Mistakes that sink a harness
- Fixing the agent's code by hand. It works once and teaches nothing. Every hand fix should end with a question: which rule, check or link would have prevented it?
- One giant instructions file. Agents follow long files worse, and nobody maintains them. Keep the root file short, split by module, push detail into the knowledge base.
- Rules only in prose. "Please never push to main" in capital letters is still advice. Anything whose violation costs real money or data needs a check that refuses it.
- A harness owned by one enthusiast. When that person is busy or leaves, the harness rots. It needs one to three named owners with time set aside.
- Building tooling out of the agent. A crew of agents checking agents is expensive and drifts. Deterministic work, such as running tests, checking a status or opening a pull request, belongs in a script that costs no tokens and behaves the same every time.
- No measurement. Without before-and-after numbers the harness becomes a matter of taste. See measuring AI's impact.
Questions
Is harness engineering just DevOps for agents?
There is a large overlap: CI, tests and permissions are shared ground. A harness adds what an agent needs and a pipeline does not: instructions written for a reader that forgets everything between sessions, a knowledge base, task specifications, and a loop that turns each agent mistake into a rule or a check.
Do we need a harness if developers already use Claude Code or Cursor on their own?
Individual use gets individual results. Without shared rules and checks, the effect depends on who is at the keyboard, and each person rebuilds the same private tooling. A harness is what turns personal speed into a team's process.
Does a harness tie us to one model or vendor?
Mostly not. Instructions in markdown, specs, tests, linters and CI work with any agent. The parts that are tool-specific, such as permission settings or hook formats, are thin and can be ported.
How long does it take to build one?
A first version takes days. Making it work for a team, with owners, measured results and a habit of fixing the harness instead of the code, takes a pilot of a few months. The adoption plan lays out the stages.
Take your team there, step by step
A 13-week pilot on one team: a baseline, a harness built around your process, real backlog tasks through the whole cycle, and the numbers before and after.