# What is harness engineering?

> Harness engineering is building everything around a coding agent except the model (instructions, tools, tests) so it gets the work right on its own.

Updated November 22, 2026 · https://usecoral.app/glossary/harness-engineering

Harness engineering is building everything around a coding agent except the model: its instructions, tools, tests, linters, sandbox and feedback loops, so the agent gets things right on its own. Each time the agent makes a mistake, you change the harness so it can’t make that mistake again.

An “AI agent harness” is the thing itself, and harness engineering is the practice of building it. A short way to put it, from LangChain and quoted on [martinfowler.com](https://martinfowler.com/articles/harness-engineering.html): Agent = Model + Harness. (Harness, the CI/CD company, is unrelated.)

As of November 2026, from Mitchell Hashimoto’s [My AI Adoption Journey](https://mitchellh.com/writing/my-ai-adoption-journey), OpenAI’s [Harness engineering](https://openai.com/index/harness-engineering/) post and [Harness engineering for coding agent users](https://martinfowler.com/articles/harness-engineering.html) on martinfowler.com. The term is young, so those sources win if this page disagrees.

<p data-cta="guide_top">A good harness answers most of what an agent would ask. The rest should reach you fast: Coral puts every waiting agent in your Mac’s notch, so you answer with one key. <a href="/download">Download Coral for free</a></p>

## Where the term came from

**February 5, 2026: Mitchell Hashimoto.** In [My AI Adoption Journey](https://mitchellh.com/writing/my-ai-adoption-journey), Ghostty’s creator made “Engineer the Harness” his fifth step: “I don’t know if there is a broad industry-accepted term for this yet, but I’ve grown to calling this ‘harness engineering.’ It is the idea that anytime you find an agent makes a mistake, you take the time to engineer a solution such that the agent never makes that mistake again.” He named two forms: better instructions in `AGENTS.md`, where “each line … is based on a bad agent behavior”, and “actual, programmed tools”, like scripts to take screenshots or run filtered tests.

**February 11, 2026: OpenAI.** Six days later, Ryan Lopopolo’s [Harness engineering: leveraging Codex in an agent-first world](https://openai.com/index/harness-engineering/) made it a headline. OpenAI’s team built an internal product over five months with “0 lines of manually-written code”: about a million lines and roughly 1,500 merged pull requests, starting with three engineers driving Codex. Its summary: “Humans steer. Agents execute.” The engineers’ job “became enabling the agents to do useful work”, and when something failed, they asked “what capability is missing, and how do we make it both legible and enforceable for the agent?”

**April 2, 2026: guides and sensors.** An article on [martinfowler.com](https://martinfowler.com/articles/harness-engineering.html) gave the practice a model. Guides steer the agent before it acts; sensors watch after it acts and help it self-correct. Each can be computational (tests, linters, type checkers: fast and reliable) or inferential (an AI reviewer: slower, richer, less predictable).

Who said it first is disputed: Addy Osmani [credits Viv Trivedy](https://addyosmani.com/blog/agent-harness-engineering/) with coining it. Hashimoto’s and OpenAI’s posts are why it spread.

## What it looks like in practice

Most of a harness is files and settings you already have. Using the guides and sensors split:

| Harness piece | Kind | Claude Code | Codex |
|---|---|---|---|
| Instructions the agent reads every session | Guide | `CLAUDE.md` ([builder](https://usecoral.app/tools/claude-md)) | `AGENTS.md` ([builder](https://usecoral.app/tools/agents-md)) |
| What the agent may do without asking | Guide (a boundary) | [Permission rules and modes](https://usecoral.app/guides/claude-code-permission-prompts) | [Sandbox and approval policy](https://usecoral.app/guides/codex-sandbox) |
| Checks that run after each action | Sensor, computational | [`PostToolUse` hooks](https://usecoral.app/guides/claude-code-hooks) | [Codex hooks](https://usecoral.app/guides/codex-hooks) |
| Tests, linters, type checks the agent runs itself | Sensor, computational | Allowed commands in its loop | Same |
| A second agent reviewing the change | Sensor, inferential | Subagents | [Subagents](https://usecoral.app/guides/codex-subagents) |

Two details from OpenAI’s post show what “legible to the agent” means:

- **A map, not a manual.** A giant instruction file “crowds out the task, the code, and the relevant docs”. Their `AGENTS.md` is “roughly 100 lines”, treated “as the table of contents” with pointers to deeper docs.
- **Error messages written for the agent.** Their rules are enforced by custom linters, and “because the lints are custom, we write the error messages to inject remediation instructions into agent context.” The martinfowler.com article calls that “a positive kind of prompt injection”.

<p data-cta="guide_body">Every harness leaves some calls to a person. Coral shows them in the notch the moment an agent stops. <a href="/download">Get Coral, free</a></p>

## Harness engineering vs context engineering and nearby terms

| Term | What it names | When it acts |
|---|---|---|
| **Harness engineering** | Everything around the model: instructions, tools, checks, sandbox, feedback | Before, during and after each action |
| **[Context engineering](https://usecoral.app/glossary/context-engineering)** | What goes into the model’s context window for a task | Before the model answers |
| **[Agentic engineering](https://usecoral.app/glossary/agentic-engineering)** | The overall practice of building software with coding agents, under review | The whole job |
| **[Software factory](https://usecoral.app/glossary/software-factory)** | Agents that start on their own from issues, schedules or failures | Around the whole loop |

Context engineering is mostly a guide (what the agent knows going in). Harness engineering adds the sensors: the checks that tell the agent it’s wrong without a person saying so. That’s what makes longer unattended runs possible; OpenAI reports single Codex runs working on one task “upwards of six hours (often while the humans are sleeping).”

## A worked example: a mistake that never comes back

Say your agent keeps leaving lint errors that you catch in review. Hashimoto’s two forms, in order:

1. **Instructions first.** Add one line to `CLAUDE.md` or `AGENTS.md`: “Run `npx eslint <file>` on every file you change and fix what it reports.” That’s a guide. It often works, and it costs nothing.
2. **Then a tool that checks.** If it still slips, make it mechanical. In Claude Code, a `PostToolUse` hook runs after every edit; exit code 2 sends its output back to Claude as the reason (from the [hooks guide](https://usecoral.app/guides/claude-code-hooks)):

```json
{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [
          { "type": "command", "command": "jq -r '.tool_input.file_path' | xargs npx eslint 1>&2 || exit 2" }
        ]
      }
    ]
  }
}
```

Now the lint errors reach the agent seconds after it makes them, not you a day later. That’s a computational sensor. The same loop applies to every repeated mistake: a wrong command becomes an instruction, a recurring bug becomes a test, a risky action becomes a permission rule.

## Where it stops

A harness makes the agent right more often. It doesn’t make it right always, and it can’t decide for you:

- **Some calls aren’t mistakes.** Approving a plan, a `git push`, a change that touches payments, a question about what you meant. No linter answers those, and a harness that answered them for you would just be skipping review.
- **Boundaries create prompts.** The tighter the sandbox and permission rules, the more often a well-harnessed agent stops to ask. Those stops are the harness working, and they wait until someone answers.

So harness engineering moves your attention from catching errors to making decisions. The decisions still need a person, at the moment the agent asks.

## Where Coral fits

[Coral](https://usecoral.app/features) is built on the same hooks a harness uses. When a coding agent asks for permission, has a question or finishes, the hook tells Coral:

- **Every waiting agent in one place.** Claude Code, Codex, Copilot CLI, OpenCode and Grok sessions that stop for a permission, a question or a plan appear in your Mac’s notch, whoever has waited longest first.
- **Answer with one key.** Press 1, 2 or 3 from any app, and see what the agent wrote just before it asked. ⌘Z takes it back within two seconds.
- **It leaves your hooks alone.** Coral asks before it connects an agent, never replaces a hook you changed, and backs up the settings file first. If Coral isn’t running, its hook exits at once and your agents ask in the terminal as usual.
- **Away from your Mac.** Alerts on your iPhone are Free. Answering from the phone is [Pro](https://usecoral.app/pricing).

## Questions

### What is an AI agent harness?

Everything in a coding agent except the model: the system prompt and instruction files, the tools it can call, the sandbox and permission rules, and the checks that run after it acts. “Agent = Model + Harness” is the short version. Harness engineering is the work of building and improving it.

### Who coined harness engineering?

Mitchell Hashimoto used it in a February 5, 2026 post, saying he’d “grown to calling this ‘harness engineering’”. OpenAI’s February 11, 2026 post made it widely known. Addy Osmani credits Viv Trivedy with coining it.

### What is the difference between harness engineering and context engineering?

Context engineering decides what information the model sees for a task. Harness engineering covers that and more: the tools, the sandbox, and the tests, linters and hooks that check the agent’s work and feed errors back to it.

### What is the difference between harness engineering and prompt engineering?

Prompt engineering improves one input to the model. Harness engineering builds the lasting system around it, so the fix for a mistake is a rule, a tool or a check that applies to every future run, not a better-worded message.

### How do I start with harness engineering?

Keep a short instructions file (`CLAUDE.md` or `AGENTS.md`), make sure the agent can run your tests and linters, and add one line or one check each time it repeats a mistake. Hashimoto’s aim is that an agent never makes the same mistake twice.
