Two Agents, Two Worktrees: Separating Test Writing from Implementation in AI Coding

A DEV Community tutorial examines the problem that a single AI agent writing both code and tests produces tests that agree with its own implementation rather than with the specification. It describes existing approaches that split test writing and implementation into separate agents or contexts, such as subagent setups and prompt-based restrictions. The author proposes instead enforcing separation through git: one agent, Codex, writes tests from a spec alone on its own branch and worktree, and the commit is cherry-picked into a second worktree where Claude Code implements the code. Claude Code is blocked from editing test paths via a deny rule in its settings. A git diff can then show whether the tests were preserved unchanged.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in