๐ก Originally published on neelshah.co.
On November 18, Gartner named Harness Engineering one of its top strategic software-engineering trends for 2026 โ and made a claim that reframes how teams should think about AI coding: harness engineering will become "a more important determinant of output quality than the choice of model itself." The reasoning is that frontier models are converging โ the gap between the best and second-best is narrowing โ so the leverage has moved from which model you pick to how well you set it up to work. Gartner projects that by 2028, teams with AI coding harness infrastructure will ship 60% fewer post-deployment defects than those without.
I've spent my last three posts on the problems: who's accountable for AI code, what it really costs, and how to prove it works. Harness engineering is the constructive answer to all three. So let's define it, then actually build one for a TypeScript project.
โ ๏ธ Why AI-generated code fails without a harness
Drop a capable agent into a bare repo with a one-line prompt and the failure modes are predictable: it invents a convention your codebase doesn't use, picks the wrong test command and declares the task done, edits a file it shouldn't touch, or produces a plausible diff that quietly breaks something three modules away. None of that is the model being "bad." It's the model working without the context a human teammate takes for granted.
Think about what a new engineer gets on day one: a README, the conventions, access to run the tests, a code review before anything merges, and a CI pipeline that blocks broken builds. We'd never let a new hire push straight to main with no review โ yet that's exactly the setup many teams give an agent. A harness is simply giving the agent the same scaffolding we give people: the context to do the work, the rules to do it your way, and the guardrails that stop a mistake from reaching production.
๐งฉ What a harness actually is
A harness has five layers. The first three help the agent succeed; the last two stop it from doing harm and tell you whether it worked.
- Context โ what the agent needs to know about this project.
- Standards โ the rules its code must satisfy.
- Tools โ the exact commands it should use.
- Guardrails โ what prevents an unsafe change from landing.
- Evals โ how you measure whether the output is reliable.
Let's build each one for a small TypeScript API.
๐ 1. Context โ a minimal AGENTS.md
AGENTS.md is the now-standard file agents read on entry. But here's the counterintuitive part, and it's backed by evidence: more context is not better. A 2026 study found that LLM-generated AGENTS.md files added over 20% cost for no average gain in success โ they made agents run more tests and explore more without getting more right. Microsoft Research's TokenEconomizer reached the same conclusion from the cost side: experience helps only when it's selective โ "short, verifiable facts about the environment," like the one canonical test command, not a wall of prose.
So write it by hand, keep it tight, and put only high-signal facts in it:
# AGENTS.md
## Commands (use these exactly)
- Install: pnpm install
- Test: pnpm test # Vitest; all tests must pass
- Lint: pnpm lint # ESLint; zero warnings allowed
- Types: pnpm typecheck # tsc --noEmit
- Build: pnpm build
## Conventions
- Validation lives in `src/schemas/` using Zod. Never validate inline.
- All API handlers return `Result<T>`, never throw across a boundary.
- New endpoints require a test in `test/` and a Zod schema.
## Do not
- Do not edit `src/generated/` (codegen output).
- Do not add dependencies without noting why in the PR description.
That's the whole file. It names the exact commands (so the agent doesn't guess), the two or three conventions that actually matter, and a short "do not" list. In a doc-poor repo this earns its keep; a sprawling auto-generated version just burns tokens.
โ 2. Standards โ enforced, not suggested
A convention in a Markdown file is a hope. A convention in a config file that CI enforces is a rule. The agent should be unable to produce code that violates your standards without the build going red. For TypeScript, that means strict compiler settings and linting that fails on warnings:
// tsconfig.json โ strictness is the cheapest guardrail you have
{
"compilerOptions": {
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"exactOptionalPropertyTypes": true,
"noEmit": true
}
}
// package.json โ one gate that runs everything
{
"scripts": {
"verify": "pnpm lint && pnpm typecheck && pnpm test && pnpm build"
}
}
The verify script matters more than it looks: it gives the agent (and CI, and you) one command that defines "done." Strict typing in particular does a huge amount of quiet work โ noUncheckedIndexedAccess alone catches a whole class of the subtle, plausible-looking bugs agents love to introduce.
๐ง 3. Tools โ remove ambiguity
Half of an agent's wasted effort is figuring out how to do routine things: which test runner, which package manager, how to run a single test. Every guess is tokens and a chance to go wrong. The harness removes the ambiguity by making the right tools obvious and the wrong paths impossible โ the AGENTS.md commands above, a committed lockfile so it can't pick the wrong dependency versions, and a pinned Node version so "works on my machine" isn't in play:
// package.json
{
"packageManager": "pnpm@9.12.0",
"engines": { "node": ">=22 <23" }
}
This is the same insight TokenEconomizer operationalizes as "micro-skills": the single most useful thing you can hand an agent is the canonical command, injected right when it's relevant.
๐ก๏ธ 4. Guardrails โ stop unsafe changes from landing
This is the layer that lets you trust the system even when you don't fully trust any single agent run. Gartner lists Agent Sandboxing as its own 2026 trend for exactly this reason โ it predicts 70% of enterprises will sandbox agentic workflows in preproduction by 2030. The principle is least privilege plus a mandatory gate:
- Sandbox the workspace. The agent works in an isolated branch/worktree or container, never with direct access to production credentials or the ability to run arbitrary deploys.
-
No direct
mainpushes. Branch protection requires a PR; the agent opens a PR, it doesn't merge one. -
CI is the gate, not the agent's say-so. Every PR must pass
verifyon a clean runner before it's mergeable.
# .github/workflows/verify.yml โ the independent gate
name: verify
on: pull_request
jobs:
verify:
runs-on: ubuntu-latest
permissions:
contents: read # least privilege: read-only by default
steps:
- uses: actions/checkout@v5
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v5
with: { node-version: 22, cache: pnpm }
- run: pnpm install --frozen-lockfile
- run: pnpm verify # lint + types + tests + build
Pair that with a branch-protection rule requiring the verify check and at least one human review, and an agent cannot land a change that breaks the build โ no matter how confidently it reported success. The guardrail doesn't trust the claim; it checks.
๐ 5. Evals โ measure reliability, not vibes
The last layer answers "is this working?" Gartner's fifth trend, Eval-Driven Development, is the discipline here (they expect 70% of teams to adopt it by 2028). You don't assess an agent on whether a run felt productive โ you assess it on evidence, the way I argued two posts back: independent CI status, not the agent's summary. Track a few things over time:
-
First-pass verify rate โ what fraction of agent PRs pass
verifywith no human fixes. - Human intervention โ how much correction each change needed to become mergeable.
-
Cost per verified change โ
(agent + CI + review cost) รท changes that pass acceptance, the metric from my cost post. - Escaped defects โ bugs that got past the harness. This is the number Gartner's 60% is about.
These turn "the agent is great / the agent is useless" (a vibe) into a trend line you can actually act on โ and show you which harness layer to tighten when the numbers slip.
๐ With vs. without: what changes
You can run this comparison yourself โ give the same task ("add a validated POST /users endpoint") to an agent in a bare repo, then in the harnessed one, and watch the difference. Without the harness, the agent guesses the validation approach, maybe skips a test, reports success, and leaves you to find the gaps. With it, the agent reads the canonical commands, follows the Zod convention because the types won't compile otherwise, writes the test because verify fails without passing ones, opens a PR, and CI independently confirms the whole thing on a clean runner before you spend a minute reviewing.
Same model. Same task. The difference is entirely the harness โ which is Gartner's whole point.
๐ Takeaways
- Harness engineering โ setting agents up with context, standards, tools, and guardrails โ is now, per Gartner, a bigger lever on code quality than model choice, because models are converging.
-
Context should be minimal and hand-written. Research shows bloated
AGENTS.mdfiles add 20%+ cost for no gain; selective, factual context is what helps. -
Make standards enforceable โ strict TypeScript + a single
verifygate turns conventions from hopes into rules. -
Guardrails over trust โ sandbox the workspace, forbid direct
mainpushes, and make independent CI the gate. The harness checks the claim; it doesn't believe it. - Measure with evals โ first-pass verify rate, human intervention, cost per verified change, escaped defects.
- The payoff Gartner projects is concrete: 60% fewer post-deployment defects by 2028.
The agents are already good enough. Whether they're reliable is now mostly up to you โ and that's the discipline worth building.
I write weekly about AI engineering, TypeScript, and full-stack development. If this was useful, the original โ and more like it โ lives at neelshah.co.
Top comments (0)