Rules: tdd-enforcement
IMPORTANT: When the user asks to implement, add, create, fix or correct code, Claude MUST propose the TDD approach BEFORE starting to code.
Affected files
These rules apply to files matching the following patterns:
**/*.ts**/*.tsx**/*.js**/*.jsx**/*.dart**/*.py**/*.go**/*.rs**/*.java**/*.cs**/*.rb**/*.php
Detailed rules
TDD Enforcement Rules
Proactive TDD Triggering
IMPORTANT: When the user asks to implement, add, create, fix or correct code, Claude MUST propose the TDD approach BEFORE starting to code.
Trigger keywords
Propose TDD automatically when the user mentions:
- "implementer", "implement"
- "ajouter", "add"
- "creer", "create"
- "fixer", "fix"
- "corriger", "correct"
- "nouvelle feature", "new feature"
- "bug", "bugfix"
- "fonctionnalite"
- "developper", "develop"
- "coder", "code"
Expected behavior
-
BEFORE any source code modification:
- Propose: "I recommend using the TDD approach. Would you like me to start by writing the tests?"
- Or directly use
/dev:dev-tddif the context is clear
-
If the user refuses TDD:
- Respect their choice but remind them of the risks
- Document in the commit that TDD was not used
-
TDD exceptions (no proposal):
- Configuration files (*.json, *.yaml, *.toml)
- Documentation (*.md)
- Build/deploy scripts
- Minor refactoring (renaming, formatting)
- Typo fixes
Systematic reminders
YOU MUST remind the TDD cycle when you modify code:
TDD cycle:
1. RED - Write a failing test
2. GREEN - Write the minimal code to pass
3. REFACTOR - Improve without breaking the tests
Integration with commands
When a development command is used (/dev:dev-component, /dev:dev-api, /dev:dev-hook, etc.), Claude MUST:
- Check whether tests exist for the code concerned
- If not, propose to start with the tests
- If yes, ensure the tests pass before modification
Pre-commit validation
BEFORE proposing a commit:
- Check that tests exist for the new code
- Check that the tests pass
- Minimum 80% coverage on the new code
Anti-patterns to block
NEVER:
- Write implementation code before the tests
- Propose to "test later"
- Ignore tests to "go faster"
- Modify the tests to make them pass (instead of fixing the code)
Automatic application
These rules are automatically applied by Claude during:
- Reading the matching files
- Modifying code
- Suggestions and fixes