Least privilege
Part 3.3
Give every agent the smallest set of tools that lets it do its job, and nothing more.
The recon workers only get read and search. They can't edit, even if a confusing file or a prompt injection tells them to. Only the Test Engineer and the Tech Lead have edit, and the Tech Lead alone is meant to touch production code. If one agent goes wrong, the damage is limited to what it was allowed to do.
Look closelyThe Test Engineer's "tests only" rule lives in its prompt, not its tool list: it has edit like the Tech Lead. That's a suggestion, not a lock. To enforce it, add a PreToolUse hook that denies edits outside src/test. Spotting gaps like this is the point of reading agent files.
AnalogyA hotel key card opens your room, the gym and the lift to your floor. Not the other rooms, not the safe. If you lose it, the hotel's exposure is one room. An agent with every tool is a master key.
TidbitThe principle was written down by Jerome Saltzer and Michael Schroeder in 1975, in "The Protection of Information in Computer Systems": every program and user should operate with the least set of privileges necessary to complete the job. It's 50 years old and it fits agents perfectly.
The run, phase by phase
Part 3.4
- Recon, in parallel. The Tech Lead launches Bug Hunter, Security Auditor and Java Modernizer in one step. The timeline shows three
🤖 ┌ subagent START lines within a second or two. Each has a credit-usage pill.
- Skills load. Expand a subagent: you'll see
money-handling read and find-money-smells.sh run.
- Red first. The Test Engineer writes tests that fail for the right reason and runs
mvn -q test.
- Green. The Tech Lead fixes the production code.
- Quality gate. If it tries to finish while tests are red, the Stop hook says no:
🔁 quality gate RED, and it keeps working.
- Handoff. Two buttons: independent review, or draft the PR.
Test-driven: red, then green
Part 3.4
Writing the failing test first proves two things the final green run can't: that the bug is real, and that the test would catch it if it came back. A test written after the fix might pass for the wrong reason. Kent Beck popularized this as red, green, refactor in Test-Driven Development: By Example (2002).
TrapLedgerly's original four tests all pass. They test the happy path, not the money. "Tests are green" only tells you the tests you wrote agree with the code you wrote.
An independent reviewer
Part 3.6
The Code Reviewer has disable-model-invocation: true, so the Tech Lead can't call it as a subagent. It isn't marking its own homework. For a truly independent opinion, pin it to a different model family with model:.
TidbitResearchers (Panickssery, Bowman and Feng, 2024) found that language models used as judges can recognize their own writing and tend to rate it higher. Reviewing with a different model family is a cheap way around that bias.