Agent harness for AI coding
The team wrote code with Claude Code, Codex and pi, but had no agent harness: no shared rules, so agents copied the nearest file and reviewers repeated the same remarks. I built one in the repo: what the agents read, what they can call, and what checks their work.
Result
The team now writes code with agents inside the harness I built. Style and convention issues are caught by checks before a PR exists, so human review is about behavior. Every rule change is backed by replayed tickets.
- reads
- rules with reasons, 40 lines
- 8 skills, one per kind of task
- calls
- Logsper environment
- Error trackerread errors and stack traces
- APIcall endpoints and read responses
- +5 more
- guard
- risky commands only
- they go to a human
- checks
- ◷✓comments
- ◷✓errors
- ◷✓logging
- +5 more
Checks in progress…8/8 passed → ready for human review
Key decision
Test rules like code. Replayed tickets show whether each rule still helps. When a new model comes out, one rerun finds the rules it no longer needs.
What I did
Claude Code, Codex and pi read the same rules from the repo. Anything task-specific lives in skills, loaded only when needed.
A rule that explains why fits the next case. A copied example spreads whatever is in that file.
Weak rule: Write tests like orders_test.go.
Better rule: A table test is a spec: one case per contract branch, named “returns X when Y”.
Agents read errors, logs, endpoint responses and data from the running system. The database is read-only and personal data is masked.
$ go test ./invoices/... ✗ TestListInvoices fails on this branch ↻ re-run on base commit: fails there too → old failure, not this change
Comments reviewers kept repeating became 8 checks that run before the agent says done, in pre-commit and in CI.
✗ errors invoices/service.go:42 returns a bare error fix: fmt.Errorf("list invoices: %w", err)
Show the command guard and the replay
Risky commands stop and go to a human; safe ones run as usual. The guard is a tripwire; branch protection and read-only roles do the locking.
$ git push --force origin main ✋ guard: protected branch. Ask a human.
- push to main
- force push
- prod DB write
- secrets
- PR merge
- guard edits
A rule changes only when the same miss shows up on two or more tasks.
| Task | Without | With |
|---|---|---|
| T-101 · invoice filter | ✗ copied old pattern | ✓ pass |
| T-102 · pagination fix | ✓ pass | ✓ pass |
| T-103 · new endpoint | ✗ bare error | ✓ pass |
| T-104 · migration | ✓ pass | ✓ pass |
Why the agents needed context
Archived codeReference only
Older servicesOutdated patterns
PrototypesDon’t copy
Reviewed codeFollow this
An agent copies the file it is in, or the one next to it.
Hardest part
Agents lock onto examples
An example in the agent’s context becomes its likely next step, so the agent copies it, including where it doesn’t fit. A rule with no example, like “write good tests”, is too vague to act on. I had to write down the thinking behind each rule: why the team does it and when it applies. “A table test is a spec: one case per contract branch” works on code the agent has never seen. “Write tests like orders_test.go” only works on code that looks like orders_test.go.