bug-fix-tdd
Bug Fix TDD guides you through test-driven bug resolution: write a failing test that reproduces the issue, then apply the minimum fix to make it pass. The skill covers test placement, mock patterns, and the complete red-green-refactor cycle for both standard fixes and fallback code-analysis approaches when reproduction isn't possible.
Bug Fix TDD reproduces bugs with failing tests, then applies minimal fixes using red-green-refactor workflow.
AI-generated summary based on this skill's SKILL.md
Install
stacklok/toolhive-studio/bug-fix-tdd · repository language: TypeScript
git clone https://github.com/stacklok/toolhive-studio
cp -r toolhive-studio/.claude/skills/bug-fix-tdd ~/.claude/skills/bug-fix-tddFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How do I fix bugs with test-driven development?
Bug Fix TDD teaches you to start by writing a failing test that reproduces the bug, then apply minimal code changes to make it pass. This red-green-refactor cycle ensures your fix is targeted and regression-proof. The skill covers test placement, mock setup, and verification strategies for both unit and integration scenarios.
What's the TDD bug fix workflow red green refactor cycle?
Bug Fix TDD's red-green-refactor workflow has three phases: Red (write a test that fails because the bug exists), Green (apply the smallest code change to pass that test), and Refactor (clean up while keeping tests passing). This approach prevents over-engineering and keeps fixes minimal and focused on the actual problem.
How do I reproduce a bug with a unit test first?
Bug Fix TDD guides you to write a failing test that captures the buggy behavior before touching production code. You set up mocks and assertions that expose the issue, then verify the test fails. Once the test confirms the bug, you apply your fix and watch it turn green—proving the bug is resolved.
Can Bug Fix TDD automate bug fixing in CI pipelines?
Yes. Bug Fix TDD covers integrating test-first bug fixes into CI workflows so that regression tests run automatically on every commit. The skill teaches how to structure tests and minimal fixes that CI systems can validate, catching regressions early and ensuring fixes stay stable across deployments.
What if I can't easily reproduce the bug in a test?
Bug Fix TDD includes fallback code-analysis approaches when direct reproduction isn't possible. The skill teaches mock patterns and test design strategies to isolate hard-to-reproduce issues, plus techniques for analyzing logs and state to construct a test that validates your fix without needing the exact original conditions.
SKILL.md
rendered from the published skill — quoted content, verbatim
Bug Fix TDD
Reproduce bugs with a failing test, then apply the minimum fix. This skill is used by the automated bug-fix agent in CI but can also be invoked manually.
TDD Workflow
Phase 1 — Analysis & Failing Test (Red)
- Parse the bug report: extract description, steps to reproduce, expected vs actual behavior
- Find relevant code: use Grep/Glob to locate the component, hook, or route mentioned in the bug
- Write a unit test that reproduces the bug — the test MUST FAIL
- Run the test:
pnpm run test:nonInteractive -- <test-file-path> - Verify failure reason: the test must fail because of the bug, not because of import errors or unrelated issues
- Retry if needed: if the test passes (bug not reproduced), try a different approach (max 3 attempts)
- Write
bug-analysis.mdwith findings (see format below)
Constraints: Do NOT modify source files in Phase 1. Only create/edit
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 1 file
.claude/skills/bug-fix-tdd/SKILL.md