ai/skills/tdd-bug-fix/SKILL.md
Enforce TDD when fixing bugs - write a failing test first, then make it pass. Use when about to fix a bug, correct broken behavior, or resolve an issue in production code. Activates for phrases like "let me fix", "I'll fix this", "same issue as", "the problem is", or when editing code after identifying a bug.
npx skillsauth add kurko/dotfiles tdd-bug-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.
When fixing bugs, you MUST follow Kent Beck's TDD discipline: write a failing test first, then make it pass. There is no world in which production code changes without a corresponding test change.
NEVER edit production code to fix a bug without first touching tests.
The sequence is always:
Before fixing anything, locate the test file:
spec/ # RSpec
test/ # Minitest, Jest, etc.
__tests__/ # Jest convention
*.test.ts # Test file patterns
*.spec.rb
If no tests exist for the code being fixed, create them.
Write a test that:
# Example: Bug where API client uses wrong encoding
context 'when sending data to the API' do
it 'sends JSON-encoded body, not form-encoded' do
# This test will FAIL with current code (form encoding)
# and PASS after the fix (JSON encoding)
expect(request.content_type).to eq('application/json')
end
end
Run the test and confirm it fails. This proves:
Now, and only now, edit the production code to fix the bug.
Run the test again. It should pass. This proves:
Do NOT require test changes for:
.env, .env.local, credentials filesdocker-compose.yml, Procfile, CI configIf there's no spec/, test/, or __tests__/ directory, skip the TDD workflow.
User: The API calls are failing
Claude: I see the issue - HTTParty is using form encoding instead of JSON.
First, let me write a failing test to reproduce this bug.
[Writes test in spec/lib/api_client_spec.rb]
Running the test... it fails as expected - the request uses
form encoding.
Now let me fix the client to use JSON:
[Edits lib/api_client.rb]
Running the test again... it passes. The bug is fixed.
User: The API calls are failing
Claude: Same HTTParty issue as the rake task - form encoding isn't working
correctly. Let me fix the client to use JSON:
[Edits lib/api_client.rb WITHOUT touching tests]
# THIS IS WRONG - no test was written to reproduce the bug
User: The API key isn't working
Claude: I see the issue - the .env file has an extra space in the API key.
Let me fix .env:
[Edits .env]
# This is fine - config fixes don't require tests
Before editing any production code to fix a bug, ask yourself:
If the answer to any of these is "no", STOP and write the test first.
From Kent Beck's "Test-Driven Development: By Example":
"The goal is clean code that works. First we'll make it work, then we'll make it clean."
But we can't know it "works" without a test. A bug fix without a test is:
The test IS the proof that the bug is fixed.
data-ai
Merge the current worktree branch into main and sync main back. Use when the user says "merge to main", "ship it", "merge and continue", or after completing a task in a worktree and wanting to continue with the next one.
tools
Synchronize AI agent skills, commands, configs, permissions, hooks, and instructions across Claude Code, Codex CLI, and other Agent Skills-compatible tools. Use when the user asks to pull skills from Claude into Codex, sync Codex work back to Claude, migrate agent commands, reconcile frontmatter, update permissions, or keep agent setup files in parity.
testing
Write or update UI-independent use cases for QA. Use when the user says "write use cases", "add use cases", "QA use cases", "update use cases", "compose use cases", or when starting implementation of a new feature (after plan approval). Also activates for "what should we test", "regression cases", or "use cases for QA".
documentation
Skill on how to write a task. Use when user asks you to write a task (for Asana, Linear, Jira, Notion and equivalent). Also activates when user says "create task", "write task", or similar task creation workflow requests.