Explainer
Harness engineering: why the setup around a coding agent matters as much as the model
Harness engineering is designing the instructions, tests, limits and feedback loops a coding agent works in: what OpenAI reported, the critique, where to start.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkOn this page
Harness engineering is the work of designing the environment a coding agent operates in, so that it can do reliable work for long stretches without a person correcting every step. The model writes the code. The harness is everything around it: the instruction files it reads, the tests and linters that tell it when it is wrong, the rules about what it may touch, the sandbox it runs in and the logs it can query. When an agent keeps making the same mistake, harness engineering treats that as a missing piece of the environment rather than a reason to write a longer prompt.
The term took off after an OpenAI post on 11 February 2026. The glossary entry agent harness defines the thing itself; this page is about the discipline, what the evidence for it is, and how to apply it to a repository you already have. Sources were checked on 25 November 2026.
What OpenAI reported
In “Harness engineering: leveraging Codex in an agent-first world”, Ryan Lopopolo describes an internal product that a small team built with “no manually-written code”. Engineers steered and Codex wrote everything. The post reports:
- about one million lines of code and about 1,500 merged pull requests over five months, starting in late August 2025;
- three engineers at first, growing to seven, at about 3.5 pull requests per engineer per day;
- single Codex runs sometimes working on one task for more than six hours;
- an estimate that the work took about a tenth of the time hand-writing it would have.
The summary line is “Humans steer. Agents execute.” The interesting part is what the team had to build to make that true.
The parts of a harness
The post’s practices fall into five parts. Each maps to something you can set up on your own repository, and most have a page on this site.
| Part | What OpenAI did | What it looks like for you |
|---|---|---|
| Instructions | A short AGENTS.md, about 100 lines, that acts as “a map, not a 1,000-page instruction manual”, pointing to a structured docs/ folder |
A useful AGENTS.md, plus Agent Skills for procedures that load only when needed |
| Feedback | Tests, custom linters and structural tests whose error messages tell the agent how to fix the problem | Fast test and lint commands the agent can run, with failures that say what to change |
| Constraints | Fixed architectural layers with enforced dependency directions | Lint rules and type checks in CI, plus permission rules and sandboxes for what the agent may run |
| Observability | An isolated app instance per worktree, with logs, metrics and traces the agent queries | Local logs and a way to run the app, so the agent can check behaviour and not only compile |
| Clean-up | Background agents that scan for drift from “golden principles” and open small refactoring pull requests | A scheduled agent task, reviewed like any other change |
Two lines from the post explain why the parts matter. On knowledge: anything the agent “can’t access in-context while running effectively doesn’t exist.” A decision made in a chat thread is invisible to it, so the team moved that knowledge into versioned files in the repository. On control: “By enforcing invariants, not micromanaging implementations, we let agents ship fast without undermining the foundation.”
The clean-up part is the one most teams skip. Agents copy existing patterns, including bad ones, and drift builds up. Before the team automated clean-up, the post says, engineers spent every Friday, about a fifth of the week, removing what they called “AI slop”.
The critique
Birgitta Böckeler’s response on martinfowler.com, “Harness engineering: first thoughts” (17 February 2026), is the useful counterweight. She likes the word, “the tooling and practices we can use to keep AI agents in check”, and agrees that treating each agent failure as a signal to improve the harness is practical. Her reservations:
- Behaviour is not checked. “What I am missing in the write-up is verification of functionality and behaviour.” Most of the measures protect internal quality, not whether the product does the right thing.
- Old codebases are harder. Retrofitting a harness onto a non-standardised, high-entropy codebase may not be worth the effort.
- The source has an interest. OpenAI has “a vested interest in us believing in AI-maintainable code.”
- It is real work. What OpenAI describes is “much more work than just generating and maintaining a bunch of Markdown rules files.”
She groups the parts into three: context engineering, architectural constraints and “garbage collection”. That grouping is a good way to audit your own setup.
Our position
The core idea holds up and is useful well below OpenAI’s scale: when an agent fails, fix the environment so the same failure cannot recur, and prefer checks the agent can run over instructions it has to remember. That is the same lesson as context engineering, extended from what the model sees to what it can verify.
The headline numbers are a vendor’s report about its own product, built greenfield by a team that controlled every convention. Do not plan your team’s capacity on them. And Böckeler’s first point is the one to act on: a harness made only of linters and structural tests keeps the code tidy while the feature is wrong. Behavioural tests, and evaluating agents on your own repository, have to be part of it.
This applies most to teams that hand coding agents multi-hour or unattended work. If you use an agent for short, supervised edits, a decent AGENTS.md and a fast test command get you most of the benefit.
Where to start on an existing repository
- Write the map. A short
AGENTS.md, the open format now stewarded by the Agentic AI Foundation, with the commands to build, test and lint, the layout, and links to deeper docs. Delete anything the agent can find by reading the code. - Make failure loud and specific. Check that one command runs the tests the agent needs, finishes in minutes, and prints errors a newcomer could act on.
- Turn repeated review comments into checks. If you have written the same review comment three times, it belongs in a lint rule, a test or a skill, not in your head.
- Bound what the agent can do. Permission rules, an OS sandbox or a container, and a human checkpoint before anything leaves the repository. Claude Code auto mode shows how one product draws that line.
- Give it eyes. A way to run the app locally and read its logs, so the agent can check behaviour rather than guess.
- Schedule the clean-up. A recurring agent task that looks for drift and opens small pull requests, reviewed like any other change.
- Measure. Run a fixed set of real tasks before and after each harness change, and keep the change only if results improve.
Next steps
- Write the instruction file with AGENTS.md example and template and compare instruction files in CLAUDE.md and AGENTS.md.
- Add blocking checks with Claude Code hooks.
- Measure whether a harness change helped with evaluate coding agents on your repository.
- Follow the topic in order with the coding agents for teams learning path.
Covers
Check your understanding
Harness engineering quiz
What a harness is, OpenAI's report and its five parts, the martinfowler.com critique, how much weight the numbers deserve and where to start on an existing repository.
8 questions · pass mark 70%
Review
Related
- Agent harness
The software around a model that turns it into an agent: the loop, tools, prompts, context management, permissions and limits.
- Write a useful AGENTS.md: example, template and test
An AGENTS.md example and template with build and test commands, conventions and traps, plus a before-and-after task that shows whether the file actually helps.
- Evaluate coding agents on your own repository
Run Claude Code and Codex headless against 10 closed issues from your repo, then score them with the real fix's tests and a blind review rubric.
- What is context engineering?
Context engineering is deciding what a model sees at each step. Why the term replaced prompt engineering for people building agents, and what the work involves.
- Claude Code auto mode: what the classifier allows and when to turn it off
How Claude Code auto mode decides which tool calls run without a prompt, how CLAUDE.md, ask and deny rules steer it, and when plan mode or a sandbox is safer.