cd /news/ai-agents/a-spec-without-a-harness-is-a-docume… · home › topics › ai-agents › article
[ARTICLE · art-179220] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

A spec without a harness is a document nobody enforces

A developer published a bash script, spec-gate.sh, that enforces spec-driven development for AI coding agents by failing CI when a pull request's diff touches files outside a spec's 'Allowed files' list or when an acceptance criterion (AC-1, AC-2, …) has no test mentioning it. The script, which runs on macOS's bash 3.2 and is wired into a GitHub Actions pull_request job, operationalizes the distinction between specs (what a change must do) and harness engineering (how any change is made trustworthy), drawing on Birgitta Böckeler's harness definition and OpenAI's five-month Codex experiment that produced roughly a million lines and 1,500 merged pull requests with no manually written code. The author notes the gate proves tests exist, not that they are good.

recommendation

Add a spec-gate CI check that fails pull requests touching files outside the spec's allowed list or missing a test for each AC-n criterion, using grep -w to avoid AC-1 matching AC-10.

more in playbook: Working with AI coding agents
by read5 min views8 publishedDec 1, 2026

Two terms keep getting mixed up in AI coding: spec-driven development and harness engineering. They answer different questions. A spec decides what one change must do before the agent starts. A harness is everything around the agent except the model: what it reads, what it may touch, which checks run on its output, and what happens when one fails.

Teams that let agents write real code end up needing both, and each one fails in a predictable way without the other.

Birgitta Böckeler's article on martinfowler.com defines a harness as "everything in an AI agent except the model itself". The term took off in February 2026, when OpenAI's Ryan Lopopolo described a five-month experiment in which a small team shipped an internal product with zero manually written lines: about a million lines and roughly 1,500 merged pull requests. The engineers' job, in the post's words, became "to design environments, specify intent, and build feedback loops that allow Codex agents to do reliable work."

Two ideas from that post matter most here:

Spec-driven development Harness engineering
Question it answers What must this change do? How do we make any change trustworthy?
Scope One change or feature The whole repository, for its whole life
Main artifacts spec.md ,tasks.md , acceptance criteria AGENTS.md , linters, structural tests, test harness, CI
Changes when Every new feature The same failure happens twice
Failure if missing People argue about intended behaviour in code review People agree on the behaviour but cannot prove it cheaply

Böckeler splits a harness into guides, which steer the agent before it acts, and sensors, which observe after it acts so it can correct itself. A functional spec is on her list as a guide. It is the only guide that changes with every feature, which makes it the most important one for behaviour.

When you write a section of the spec, decide which harness control it feeds:

Spec section Harness control
Context, goal, non-goals Linked from AGENTS.md so the agent reads it first
Allowed files CI fails if the diff touches anything else
Acceptance criteria AC-1…n Each has a test that names it; CI fails if one is missing
Edge cases Fixtures and factory states that reproduce them
API contract Contract tests generated from the OpenAPI document
Rollback A feature flag exists and defaults off

The two rows that catch the most agent mistakes, allowed files and acceptance criteria, fit in one short script. It reads the spec, fails when the diff leaves the allowed list, and fails when a criterion has no test that mentions it. We ran it against a sample repository on bash 3.2, the version macOS ships:

#!/usr/bin/env bash
set -euo pipefail
spec="specs/active/$1/spec.md"
base="${2:-origin/main}"
status=0

allowed=$(sed -n '/^## Allowed files/,/^## /p' "$spec" | sed -n 's/^- //p')
while read -r file; do
  grep -qxF "$file" <<<"$allowed" || { echo "out of scope: $file"; status=1; }
done < <(git diff --name-only "$base"...HEAD)

for ac in $(grep -o 'AC-[0-9]\+' "$spec" | sort -u); do
  grep -rqw -- "$ac" tests/ || { echo "no test mentions $ac"; status=1; }
done

exit "$status"

It expects the spec to carry an ## Allowed files list of exact paths and criteria numbered AC-1, AC-2, and so on. The -w flag matters: without it, a test named after AC-10 would satisfy AC-1. As a pull request check, with the branch name used as the change folder:

name: spec-gate
on: pull_request
jobs:
  gate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - run: scripts/spec-gate.sh "$GITHUB_HEAD_REF" "origin/$GITHUB_BASE_REF"

It does not prove the tests are good. It proves the agent stayed inside the boundary and did not skip a criterion.

Take "retry refunds when the payment gateway times out". The spec is short:

## Acceptance
- AC-1: a gateway timeout retries once with the same idempotency key
- AC-2: a second timeout leaves the refund pending, no duplicate refund_id
- AC-3: every attempt writes an audit event

## Allowed files
- src/billing/refund-worker.ts
- tests/refund-worker.test.ts
- specs/active/refund-retry/evidence.md

This is the kind of failure the harness is for. The agent writes a plausible retry loop and a test that mocks the gateway to succeed on the second call. The test passes, AC-2 is never exercised, and the agent adds a helper to src/billing/ledger.ts because it seemed tidy. Without a harness, review catches some of that, late.

With a harness, the same run hits three sensors before a human looks. The scope gate flags ledger.ts. The AC check reports that no test mentions AC-2. And the gateway mock is part of the test harness rather than something each test improvises, so it already has a "times out twice" state and the missing test costs the agent one line.

A spec without a harness is a document nobody enforces. The agent mostly follows it and drifts at the edges: an extra field, a refactor outside scope, a criterion quietly dropped. Each of those is found in human review, the most expensive place to find it and the one that scales worst as agents open more pull requests. A note in OpenSpec's community schema catalog says it plainly: "OpenSpec only checks that artifacts exist."

A harness without a spec is a fast, green pipeline pointed at the wrong target. Lint passes, the tests are thorough, and the feature does something nobody asked for. Anthropic's March 2026 post on harness design found a related trap: "When asked to evaluate work they've produced, agents tend to respond by confidently praising the work." Its fix was a separate evaluator grading against criteria agreed before coding started, which is a spec by another name.

For a team that already writes specs, in order of return:

AGENTS.md a short map to where specs, architecture notes and commands live. The full article covers the prompt, context, harness and loop layers, the test-harness layers in more detail, and links to every source quoted here: Harness engineering vs spec-driven development.

── more in #ai-agents 4 stories · sorted by recency
── more on @birgitta böckeler 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/a-spec-without-a-har…] indexed:0 read:5min 2026-12-01 · —