Agent skill · Testing & QA

tdd-bug-fix

Fix bugs using red-green-refactor — reproduce the bug as a failing test first, then fix it. Use when fixing bugs to ensure they never regress.

rshankrasgithub.com/rshankrasGitHub ↗
claude-codecan modify filesMIT
Install
npx skills add rshankras/claude-code-apple-skills --skill tdd-bug-fix --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 7 KB
Bundled scripts: none
Allowed tools: ReadWriteEditGlobGrepBashAskUserQuestion
Path: skills/testing/tdd-bug-fix/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 589
Language: Swift

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# TDD Bug Fix Fix bugs the right way: reproduce first, fix second, verify always. Especially critical when using AI to generate fixes — the test ensures the AI actually solved the problem. ## When This Skill Activates Use this skill when the user: - Reports a bug and wants it fixed - Says "this is broken" or "this doesn't work" - Asks to "fix and add a test" or "fix with TDD" - Wants to ensure a bug doesn't come back - Is skeptical of AI-generated fixes ("how do I know it's actually fixed?") ## Why TDD for Bug Fixes ``` Without TDD: With TDD: Bug reported Bug reported → AI generates fix → Write failing test (RED) → Deploy → AI generates fix (GREEN) → Hope it works → Test passes — confirmed fixed → Bug returns later → Test prevents regression forever ``` ## Process ### Phase 1: Understand the Bug Gather information: 1. **What's the expected behavior?** 2. **What's the actual behavior?** 3. **Steps to reproduce?** 4. **Which code is involved?** ``` Grep: "[relevant keyword]" to find the source Read: the suspected file(s) ``` Identify: - [ ] The function/method where the bug lives - [ ] The input that triggers the bug - [ ] The incorrect output/behavior - [ ] The correct expected outp

What's inside
Steps it walks through
  1. When This Skill Activates
  2. Why TDD for Bug Fixes
  3. Process
  4. Phase 1: Understand the Bug
  5. Phase 2: RED — Write the Failing Test
  6. Phase 3: GREEN — Fix the Bug
  7. Phase 4: REFACTOR (Optional)
  8. Phase 5: Verify Completeness
  9. Multiple Related Bugs
  10. Output Format
  11. Common Pitfalls
  12. References
Commands it runs
xcodebuild test -scheme YourApp \
Run the bug fix test
Run ALL tests to check for regressions
xcodebuild test -scheme YourApp
More from claude-code-apple-skills
All skills →
About this skill
What does the tdd-bug-fix skill do?

Fix bugs using red-green-refactor — reproduce the bug as a failing test first, then fix it. Use when fixing bugs to ensure they never regress.

How do I install it?

Run `npx skills add rshankras/claude-code-apple-skills --skill tdd-bug-fix --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From rshankras/claude-code-apple-skills, a repository with 589 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going