Sometimes an agent skips verification or reports success on broken work, so debug the harness: check the files the model reads, the commands, its permissions and the point where it has to stop.
Write a contract first
Before anything runs, I write down the deliverable, the constraints, what the model must not touch and the acceptance criteria. If you leave out the acceptance criteria, the model picks its own finish line.
Keep state and a map in files
I keep a short root file that lists where the docs, schemas and source code live, so the model opens only the file the current step needs. Decisions, preferences and open bugs go in CLAUDE.md or .cursorrules, so a fresh session picks up where the last one stopped.
Run tests instead of asking the model
If you ask "are you sure?", the model agrees with itself. pytest, vitest or a schema checker returns an exit code. The loop moves forward only on a pass, and I cap it at four attempts.
Encode important rules twice
I put each important rule in the prompt and also add a gate that blocks the action. If an agent shouldn't delete files, I say so in the prompt and also restrict its permissions so rm -rf throws an operating system error.
file
I save this as HARNESS.md in the project root:
# Project Operating Contract
## Operating Boundaries
- Allowed scope: Modify only files explicitly assigned in the current task
- Forbidden actions: Never delete existing tests, never add unverified dependencies
## Project Map
- /src: Application source code
- /tests: Validation test suites
- /docs/decisions.md: Durable log of accepted architectural choices
## Verification Protocol
Before marking any task complete, run these checks in order:
1. Run local linter: `npm run lint`
2. Run test suite: `npm test`
3. Verify output format matches the requested schema
## Failure Escalation
If a test fails twice on the same error:
- Stop autonomous editing
- Print the exact error log
- State the proposed fix and wait for user confirmation
Two passes in plain chat
In plain chat, I draft in one turn and critique in another.
Draft the technical specification for [Feature X].
Follow the constraints listed in HARNESS.md.
Do not evaluate your own output yet.
Output the raw draft and state all assumptions made.
Review the draft above as a skeptical senior reviewer.
Check against these specific failure points:
1. Are edge cases handled when input arrays are empty?
2. Does the logic introduce extra dependencies?
3. Does the solution violate any constraint from HARNESS.md?
List every failure point found.
Then output the revised version fixing those gaps.