kit/plugins/code-testing-agent/skills/tdd-fix/SKILL.md
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.
npx skillsauth add shawn-sandy/agentics tdd-fixInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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
Invoke the commit-agent skill. When it drafts the commit message, ensure:
fixExample: fix(tests/demo): correct add() operator from subtraction to addition
The commit-agent skill handles staging, pre-commit hooks, and conventional
format — do not duplicate that logic here.
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.
data-ai
Craft-prompt: interviews users and assembles a structured AI prompt using Anthropic best-practice techniques. Use when the user runs /plan-agent:craft-prompt or asks to craft a prompt.
development
Generates a SOCIAL.md project sharing config by analyzing the codebase. Use when asked to set up social sharing preferences or create a SOCIAL.md file.
development
Explains how any project file, component, or concept works. Reads source files and synthesizes developer-friendly principles, social copy, and a dark-mode card. Use when asked 'how does X work' or 'explain X'.
development
Generate an HTML implementation-plan document. Produces a self-contained .html plan file with steps, acceptance criteria, and metadata. Use when the user asks to create a plan document, generate an HTML plan, or write a plan file — not for general planning questions.