TDD Reminder
General Guidelines
Output Style
- Never explicitly mention TDD in code, comments, commits, PRs, or issues
- Write natural, descriptive code without meta-commentary about the development process
- The code should speak for itself - TDD is the process, not the product
Beads is available for task tracking. Use mcp__beads__* tools to manage issues (the user interacts via bd commands).
Plan File Restriction
NEVER create, read, or update plan.md files. Claude Code's internal planning files are disabled for this project. Use other methods to track implementation progress (e.g., comments, todo lists, or external tools).
TDD Fundamentals
The TDD Cycle
The foundation of TDD is the Red-Green-Refactor cycle:
Red Phase: Write ONE failing test that describes desired behavior
- The test must fail for the RIGHT reason (not syntax/import errors)
- Only one test at a time - this is critical for TDD discipline
- Exception: For browser-level tests or expensive setup (e.g., Storybook
*.stories.tsx), group multiple assertions within a single test block to avoid redundant setup - but only when adding assertions to an existing interaction flow. If new user interactions are required, still create a new test. Split files by category if they exceed ~1000 lines.
- Adding a single test to a test file is ALWAYS allowed - no prior test output needed
- Starting TDD for a new feature is always valid, even if test output shows unrelated work
- For DOM-based tests, use
data-testid attributes to select elements rather than CSS classes, tag names, or text content
- Avoid hard-coded timeouts both in form of sleep() or timeout: 5000 etc; use proper async patterns (
waitFor, findBy*, event-based sync) instead and rely on global test configs for timeout settings
Green Phase: Write MINIMAL code to make the test pass
- Implement only what's needed for the current failing test
- No anticipatory coding or extra features
- Address the specific failure message
Refactor Phase: Improve code structure while keeping tests green
- Only allowed when relevant tests are passing
- Requires proof that tests have been run and are green
- Applies to BOTH implementation and test code
- No refactoring with failing tests - fix them first
Core Violations
Multiple Test Addition
- Adding more than one new test at once
- Exception: Initial test file setup or extracting shared test utilities
Over-Implementation
- Code that exceeds what's needed to pass the current failing test
- Adding untested features, methods, or error handling
- Implementing multiple methods when test only requires one
Premature Implementation
- Adding implementation before a test exists and fails properly
- Adding implementation without running the test first
- Refactoring when tests haven't been run or are failing
Critical Principle: Incremental Development
Each step in TDD should address ONE specific issue:
- Test fails "not defined" → Create empty stub/class only
- Test fails "not a function" → Add method stub only
- Test fails with assertion → Implement minimal logic only
Optional Pre-Phase: Spike Phase
In rare cases where the problem space, interface, or expected behavior is unclear, a Spike Phase may be used before the Red Phase.
This phase is not part of the regular TDD workflow and must only be applied under exceptional circumstances.
- The goal of a Spike is exploration and learning, not implementation.
- The code written during a Spike is disposable and must not be merged or reused directly.
- Once sufficient understanding is achieved, all spike code is discarded, and normal TDD resumes starting from the Red Phase.
- A Spike is justified only when it is impossible to define a meaningful failing test due to technical uncertainty or unknown system behavior.
General Information
- Sometimes the test output shows as no tests have been run when a new test is failing due to a missing import or constructor. In such cases, allow the agent to create simple stubs. Ask them if they forgot to create a stub if they are stuck.
- It is never allowed to introduce new logic without evidence of relevant failing tests. However, stubs and simple implementation to make imports and test infrastructure work is fine.
- In the refactor phase, it is perfectly fine to refactor both test and implementation code. That said, completely new functionality is not allowed. Types, clean up, abstractions, and helpers are allowed as long as they do not introduce new behavior.
- Adding types, interfaces, or a constant in order to replace magic values is perfectly fine during refactoring.
- Provide the agent with helpful directions so that they do not get stuck when blocking them.
Continue Conversation
User arguments:
TDD: $ARGUMENTS
End of user arguments
Please continue with the user input above, applying TDD approach.
Source: wbern/agent-instructions — distributed by TomeVault.
1---2name: tdd-353description: Remind agent about TDD approach and continue conversation Use when this capability is needed.4---56# TDD Reminder78## General Guidelines910### Output Style1112- **Never explicitly mention TDD** in code, comments, commits, PRs, or issues13- Write natural, descriptive code without meta-commentary about the development process14- The code should speak for itself - TDD is the process, not the product1516Beads is available for task tracking. Use `mcp__beads__*` tools to manage issues (the user interacts via `bd` commands).1718## Plan File Restriction1920**NEVER create, read, or update plan.md files.** Claude Code's internal planning files are disabled for this project. Use other methods to track implementation progress (e.g., comments, todo lists, or external tools).2122## TDD Fundamentals2324### The TDD Cycle2526The foundation of TDD is the Red-Green-Refactor cycle:27281. **Red Phase**: Write ONE failing test that describes desired behavior2930 - The test must fail for the RIGHT reason (not syntax/import errors)31 - Only one test at a time - this is critical for TDD discipline32 - Exception: For browser-level tests or expensive setup (e.g., Storybook `*.stories.tsx`), group multiple assertions within a single test block to avoid redundant setup - but only when adding assertions to an existing interaction flow. If new user interactions are required, still create a new test. Split files by category if they exceed ~1000 lines.33 - **Adding a single test to a test file is ALWAYS allowed** - no prior test output needed34 - Starting TDD for a new feature is always valid, even if test output shows unrelated work35 - For DOM-based tests, use `data-testid` attributes to select elements rather than CSS classes, tag names, or text content36 - Avoid hard-coded timeouts both in form of sleep() or timeout: 5000 etc; use proper async patterns (`waitFor`, `findBy*`, event-based sync) instead and rely on global test configs for timeout settings37382. **Green Phase**: Write MINIMAL code to make the test pass3940 - Implement only what's needed for the current failing test41 - No anticipatory coding or extra features42 - Address the specific failure message43443. **Refactor Phase**: Improve code structure while keeping tests green45 - Only allowed when relevant tests are passing46 - Requires proof that tests have been run and are green47 - Applies to BOTH implementation and test code48 - No refactoring with failing tests - fix them first4950### Core Violations51521. **Multiple Test Addition**5354 - Adding more than one new test at once55 - Exception: Initial test file setup or extracting shared test utilities56572. **Over-Implementation**5859 - Code that exceeds what's needed to pass the current failing test60 - Adding untested features, methods, or error handling61 - Implementing multiple methods when test only requires one62633. **Premature Implementation**64 - Adding implementation before a test exists and fails properly65 - Adding implementation without running the test first66 - Refactoring when tests haven't been run or are failing6768### Critical Principle: Incremental Development6970Each step in TDD should address ONE specific issue:7172- Test fails "not defined" → Create empty stub/class only73- Test fails "not a function" → Add method stub only74- Test fails with assertion → Implement minimal logic only7576### Optional Pre-Phase: Spike Phase7778In rare cases where the problem space, interface, or expected behavior is unclear, a **Spike Phase** may be used **before the Red Phase**.79This phase is **not part of the regular TDD workflow** and must only be applied under exceptional circumstances.8081- The goal of a Spike is **exploration and learning**, not implementation.82- The code written during a Spike is **disposable** and **must not** be merged or reused directly.83- Once sufficient understanding is achieved, all spike code is discarded, and normal TDD resumes starting from the **Red Phase**.84- A Spike is justified only when it is impossible to define a meaningful failing test due to technical uncertainty or unknown system behavior.8586### General Information8788- Sometimes the test output shows as no tests have been run when a new test is failing due to a missing import or constructor. In such cases, allow the agent to create simple stubs. Ask them if they forgot to create a stub if they are stuck.89- It is never allowed to introduce new logic without evidence of relevant failing tests. However, stubs and simple implementation to make imports and test infrastructure work is fine.90- In the refactor phase, it is perfectly fine to refactor both test and implementation code. That said, completely new functionality is not allowed. Types, clean up, abstractions, and helpers are allowed as long as they do not introduce new behavior.91- Adding types, interfaces, or a constant in order to replace magic values is perfectly fine during refactoring.92- Provide the agent with helpful directions so that they do not get stuck when blocking them.9394## Continue Conversation9596**User arguments:**9798TDD: $ARGUMENTS99100**End of user arguments**101102Please continue with the user input above, applying TDD approach.103104---105> Source: [wbern/agent-instructions](https://github.com/wbern/agent-instructions) — distributed by [TomeVault](https://tomevault.io).106<!-- tomevault:4.0:skill_md:2026-06-24 -->