TDD Skill
Test-driven development workflow. Write tests first, then implementation, with Claude guiding each step.
What it does
The TDD Skill enforces the red-green-refactor loop. Claude writes one failing test first, waits for you to confirm it fails, writes the minimum code to make it pass, confirms it passes, then refactors. No skipping steps, no batch-writing 10 tests at once.
What it does when Claude uses it
Claude proposes one test at a time, runs through the loop with you, and produces tests with Arrange/Act/Assert structure and sentence-style names. It mocks only what you own or what is slow, and keeps branch coverage as the target, not line coverage.
How to install
Which tool are you using?
Not sure? Claude.ai is the website. Claude Code is the command-line tool you install separately. Cursor is a code editor that reads .cursorrules.
- 01
Download the skill file
Click the Copy button on the code block below to grab the full contents of tdd.md. Save it locally as tdd.md.
- 02
Create your skills folder
Claude Code reads skills from ~/.claude/skills/. Create the folder if it does not exist.
terminalshellmkdir -p ~/.claude/skills/ - 03
Copy the file into the skills folder
Move the file into your skills directory so Claude picks it up.
terminalshellcp tdd.md ~/.claude/skills/tdd.md - 04
Verify installation
Open Claude Code and run /skills list. You should see "tdd" appear in the list.
terminalshell/skills list - 05
Start using it
Claude will now apply this skill automatically whenever the task matches the skill description. No extra prompting required.
The claude skill file
Copy the full contents below, or download the file directly.
---name: tdddescription: Use this skill when doing test-driven development. Enforces red-green-refactor loop and test-first implementation.--- # TDD Skill ## Loop1. Write the smallest failing test for the behavior you want2. Run it, watch it fail3. Write the minimum code to make it pass4. Run it, watch it pass5. Refactor both test and code while green6. Repeat ## Test Quality- One assertion per test when possible- Arrange / Act / Assert structure- Test names read like sentences: "returns_zero_when_cart_is_empty"- Mock only what you own or what is slow (DB, network, time) ## Coverage- Target 80%+ on domain logic, 0% on generated code- Branch coverage > line coverage- Flaky tests get fixed or deleted, never retriedExample output
What Claude does before and after you install this claude skill.
Claude writes the implementation first, then writes tests that trivially pass. You miss three edge cases.
Claude writes one failing test, waits, writes just enough code to pass, refactors, then moves to the next edge case — catching the three you would have missed.
Customization tips
If your codebase has a strict naming convention for tests (e.g. Given/When/Then), update the Test Quality section. Teams that enforce 100% coverage on domain logic can tighten the 80% target. For BDD style, swap the Arrange/Act/Assert structure for Given/When/Then.
Related resources
Code Review Skill
Claude reviews your code like a senior engineer — catches bugs, suggests improvements, flags security issues.
Bug Detective
Systematically debugs issues by asking the right questions and tracing root causes.
Senior Code Reviewer
Acts as a senior engineer reviewing your PR. Catches logic errors, security issues, and code smells.
Frequently asked questions
Does it work with any test framework?
Yes — Jest, Vitest, pytest, flutter_test, Go testing, etc. Framework-agnostic.
Will it let me skip the red step?
No. That is the whole point — the skill enforces the full loop.
Can I use it for integration tests?
Yes, but TDD is most valuable at the unit level. Use it there first.
Does it cover mutation testing?
Not by default. Ask Claude to add mutation-testing awareness on top of the skill.
Will it refactor aggressively?
Only while green. The skill enforces refactoring only when all tests pass.
Want more like this?
Browse the full RohanKit library — free resources for Claude and Cursor.