Module 4: Harness engineering

Back to the course | Previous: Context engineering | Next: Tools and protocols

Time to give your agent a bit of a rest. We'll take a look at a commercial one with real tasks now on a real repository.

You already know that a model is a tiny part of the whole story. Everything around a model, the thing we are building, is the harness: instructions, tools, checks, everything. Birgitta Böckeler splits it into two kinds of things. Guides steer the agent before it acts and sensors check what it did after.

This is where our hoarded knowledge gets to be in play! The way you like errors wrapped, functions written, preferences on if vs switch statements, solutions to hard problems, snippets of code, interface design, etc. Written down in a repo where the agent reads it every time. That is how it ends up writing the code you would have written. Mostly. Largely.

One rule for this module, and for the rest of your career with these tools: when the agent repeats a mistake, fix the harness, not the prompt!!!!!!!!! THIS IS INCREDIBLY IMPORTANT! Make a rule in AGENTS.md. Make a mod/plugin. Write down the code, the context, whatever! Fix. The. Harness!

Read

Harness engineering for coding agent users by Birgitta Böckeler.

Build

Pick a real Go repo you work on.

  1. Write the instructions file. AGENTS.md: how to build, test, conventions, and restrictions. Keep it short! Every line costs context.
  2. Make the checks one command. go vet ./..., your linter and go test ./.... Tell the agent that these tools are the gates for it declaring success on a task.
  3. Do two real tasks with a commercial coding agent. Just small ones and notice any errors it makes. Any small error is fine.
  4. Fix the harness. Each time it does something you don't want, don't skip over it! Ask what would have prevented that action! It, or you, will turn it into either a line in the instructions, or a lint rule, or a test, and you'll add that to the harness.

As said, be a good citizen to others. Review the diff yourself before anybody else does, and write the pull request description by hand. It's common courtesy.

Done when

You have fixed at least one repeated agent mistake by changing the harness, not the prompt.

Discuss

Which checks were cheapest to add and resulted in the most things fixed? A simple DO NOT or a small test or maybe a mod that prevents further errors?

Extras

Optional reading