From 8d3915ad0e80420f4c64a187b73f7e5ea72147fb Mon Sep 17 00:00:00 2001 From: alexion Date: Tue, 14 Jul 2026 19:42:39 -0400 Subject: [PATCH] Enforce TDD in the implement flow Add a PreToolUse hook that reminds the main agent not to author test files directly, and change the implement skill to always use test-driven-development rather than only where possible. --- .claude/settings.json | 11 +++++++++++ .claude/skills/implement/SKILL.md | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.claude/settings.json b/.claude/settings.json index 6ac24c7..d83714a 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -19,6 +19,17 @@ } ] } + ], + "PreToolUse": [ + { + "matcher": "Write|Edit", + "hooks": [ + { + "type": "command", + "command": "f=$(jq -r '.tool_input.file_path // empty'); printf '%s' \"$f\" | grep -Eq '(\\.(test|spec)\\.[cm]?[jt]sx?$)|/__tests__/' && jq -n '{hookSpecificOutput:{hookEventName:\"PreToolUse\",additionalContext:\"test-driven-development skill: the MAIN agent must not author test files. Each test is written by a test-writer sub-agent (via the Agent tool) from the public interface alone. If you are running /implement or any TDD flow and have not loaded /test-driven-development, load it now and delegate this test to the sub-agent. If you ARE the test-writer sub-agent, disregard this reminder.\"}}' || true" + } + ] + } ] }, "model": "opus" diff --git a/.claude/skills/implement/SKILL.md b/.claude/skills/implement/SKILL.md index 6b27cbf..726131d 100644 --- a/.claude/skills/implement/SKILL.md +++ b/.claude/skills/implement/SKILL.md @@ -30,7 +30,7 @@ Always branch off `main`, never off a sibling task branch. ### 3. Implement -Build the work described in the task's "What to build" section, satisfying its acceptance criteria. Use `/test-driven-development` where possible, at the seams already agreed when the spec or task was written. +Build the work described in the task's "What to build" section, satisfying its acceptance criteria. ALWAYS use `/test-driven-development`, at the seams already agreed when the spec or task was written. Run typechecking regularly, single test files regularly, and the full test suite once at the end.