Test-Driven Development
Claude Code can write files and run tests in the same session, making it ideal for TDD. The explicit red-green-refactor phases with test output verification at each step ensures genuine TDD rather than writing tests after implementation.
I want to implement {{featureDescription}} using TDD. **Tech:** {{testFramework}} for testing, {{language}} codebase **Step 1 — Write tests first:** - Create test file at {{testFilePath}} - Write tests for these behaviors: {{expectedBehaviors}} - Include edge cases: {{edgeCases}} - Use descriptive test names: "should {{behavior}} when {{condition}}" - All tests should FAIL initially (red phase) **Step 2 — Run the tests:** - Execute {{testCommand}} and confirm they all fail for the right reasons - Show me the output **Step 3 — Implement the minimum code to pass:** - Write the implementation at {{implFilePath}} - Write only enough code to make the tests pass — no extra features - Run tests again to confirm they all pass (green phase) **Step 4 — Refactor if needed:** - Clean up the implementation while keeping all tests green - Run the full test suite to check for regressions Do each step sequentially. Show me the test output after each phase.
Variables to customize
Why this prompt works
Claude Code can write files and run tests in the same session, making it ideal for TDD. The explicit red-green-refactor phases with test output verification at each step ensures genuine TDD rather than writing tests after implementation.
Save this prompt to your library
Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.
Related prompts
Get thorough code reviews with actionable feedback tailored to your language, framework, and standards.
Context-Aware Code CompletionProviding the surrounding code and project context lets the model match existing patterns exactly. The constraint against modifying existing code prevents unwanted side effects.
Inline Code SuggestionConstraining suggestions to match existing style and scope produces insertions that feel native to the codebase. The 'no explanation' rule mimics real inline completion behavior.
Code ExplanationThe audience level parameter adjusts complexity automatically. Requiring a usage example ensures the explanation is practical, not just theoretical.