Working by Task Type8 minLesson 16 of 60
Testing: Give the Agent a Signal
Tests are how an agent closes its own loop. Without them, the agent guesses whether it succeeded. With them, it knows. A fast, reliable test command is the single highest-leverage thing in most builds.
Two ways to use tests
- Guardrail: tell the agent the suite must stay green, so it self-corrects after each change.
- Target: write the test first (or have the agent write it), then have it make the test pass.
Beware the agent that edits the test
An agent under pressure to make tests pass will sometimes weaken the test instead of fixing the code. Review test changes as carefully as code changes.
zsh - my-app
$# the agent's own loop, made visible
✗ 1 failing: expected 400, got 500
→ added null guard in validateEmail
✓ 12/12 passing
$