/skills:tdd-fixfrom skills
Fixes bugs via TDD with up to 10 red-green iterations. Writes a failing test then autonomously iterates until the bug is resolved. Use when the user asks to TDD-fix a bug or run a red-green cycle.
Ships in skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Given a bug description, write a failing test that reproduces it, then
enter an autonomous loop — run tests, analyze failures, edit code, re-run —
until green or 10 iterations. Log each iteration's hypothesis. After
passing, run the full suite, commit with a fix: prefix, and open a PR.
Freedom level: Strict — Follow these steps in order. Do not skip or combine steps. Stop at each hard-stop marker.
Does not design tests from scratch — use code-testing-agent. Does not review test quality — use reviewing-tests.
Use TodoWrite to create todos for Steps 1–9, all status: "pending".
Mark each status: "completed" as you finish it.
Extract from the invocation message:
| Field | What to extract |
|---|---|
| Symptom | What the code currently does wrong |
| Expected behavior | What it should do instead |
| Affected file(s) | Source file(s) containing the bug — explicit path, or inferred from symptom |
| Test file | Corresponding test file (infer from naming convention if not given) |
If any field is missing and cannot be inferred, use AskUserQuestion
with a focused question for the missing field only. Do not ask for everything
at once.
Do not open any source file yet. Only parse the message.
Locate the test file. Use Glob to find it:
*.test.ts, *.test.js, *.spec.ts, *.spec.js (JS/TS)test_*.py, *_test.py (Python)*_test.go (Go)*_test.rs (Rust)*.test.sh, *.bats (shell)If multiple candidates exist, prefer the one closest in the directory tree to the affected source file.
Read the test file (Read) to understand its structure, assertion
style, and import pattern.
Append a new test case that will fail because of the bug. Use Edit
(not Write) to add to the existing file. The test must:
# tdd-fix: reproducing <symptom> (or language
equivalent) to identify it laterDo NOT edit any production code in this step.
Run the test once (Bash) to confirm it fails. If it unexpectedly
passes, stop and use AskUserQuestion:
"The new test passed without any code changes — the bug may already be fixed, or the test may not be reproducing it correctly. How do you want to proceed?"
Initialize an iteration log. Render it as a markdown table and update it live after each iteration:
| # | Hypothesis | Change Made | Result |
|---|------------|-------------|--------|
For each iteration i from 1 to 10:
Read the failure output from the previous run (or from Step 2 on iteration 1). In one sentence, state why the test is failing and what in the production code is responsible. Write the hypothesis to the iteration log.
Examples of well-formed hypotheses:
add() is subtraction, not addition."parseDate does not handle the Z timezone suffix."< n but should be <= n."Use Edit (not Write) to apply the minimal change implied by the
hypothesis. Record a one-line diff summary in the log.
Do not refactor unrelated code. Do not add unrelated tests. Change only what the hypothesis requires.
Run only the test written in Step 2 via Bash. Record the result (PASS
or FAIL + excerpt) in the iteration log.
i < 10, increment and go to 3a. If i == 10, proceed
to Step 4.Show the updated iteration log after every iteration.
If the loop reaches 10 iterations without a passing test:
tdd-fix stopped after 10 iterations. The test is still failing.
No commit or PR will be created.
Suggestions for next steps:
- Review the iteration log above for patterns.
- Consider whether the bug is in a different file than expected.
- The test file and any partial edits remain on disk for manual inspection.
Once the scoped test passes, run the full test suite with no scope
filter. Use Bash with the appropriate full-suite command for the project:
npm test, yarn test, pnpm test, or npx vitest runpytest, python -m pytestgo test ./...If any previously-passing test now fails:
Regression detected. The fix broke existing tests (listed above).
No commit or PR will be created. The changes remain on disk.
If all tests pass, continue to Step 6.
Print a summary block before committing:
## tdd-fix Summary
Bug: <symptom from Step 1>
Fix: <final hypothesis from Step 3>
Iterations: <i of 10>
Files changed:
- <production file(s) edited>
- <test file appended>
Full suite: PASS
Stage the changed files and commit with a conventional commit message once the fix is green:
fixExample: fix(tests/demo): correct add() operator from subtraction to addition
Invoke the pr-agent skill. When it drafts the PR body, include the
iteration log from Step 3 under a ## How it was found (tdd-fix) section.
The pr-agent skill handles push, platform detection (GitHub/GitLab), and
branch checks — do not duplicate that logic here.
STOP here. Do not analyze code further, do not re-run tests, do not
suggest refactors or cleanup, do not open additional issues. The fix is
complete when the PR URL is returned by pr-agent.
What SKILL.md sets; muted values are Claude Code's defaults
13 skills in this plugin
/agentic-memory-managementAudits and optimizes CLAUDE.md project memory files. Checks adherence to Claude Code best practices and produces actionable fixes. Use when the user asks to audit, optimize, or diagnose a CLAUDE.md./code-review-agentReviews code for bugs, security issues, and breaking changes. Produces prioritized findings on quality, vulnerabilities, and regressions. Use when asked to review code or check a PR diff./code-testing-agentSuggests purpose-driven tests tied to actual behavior. Writes test files covering untested paths and behavior gaps in the codebase. Use when the user asks to suggest tests or find untested behavior.npx claudepluginhub shawn-sandy/skills --plugin skillsOther plugins' skills for the same job