Test-First Bug Fix Skill: Reproduce, Fix, Prove (SKILL.md)

A SKILL.md that forces your coding agent to reproduce a bug with a failing test before changing code, apply the smallest fix, and prove it with the test suite.

You get: Bug statement, failing test output and root cause

More like this

Ready to use: no blanks to fill in.

The prompt

Installs to .agents/skills/test-first-bug-fix-skill-reproduce-fix-prove-skill-md/

mkdir -p .agents/skills/test-first-bug-fix-skill-reproduce-fix-prove-skill-md && curl -sL "https://prompts-gpt.com/prompts/test-first-bug-fix-skill-reproduce-fix-prove-skill-md/raw" -o .agents/skills/test-first-bug-fix-skill-reproduce-fix-prove-skill-md/SKILL.md
SKILL.md
Preview
---
name: test-first-bug-fix-skill-reproduce-fix-prove-skill-md
description: "A SKILL.md that forces your coding agent to reproduce a bug with a failing test before changing code, apply the smallest fix, and prove it with the test suite."
---

# Test-First Bug Fix Skill: Reproduce, Fix, Prove (SKILL.md)

A SKILL.md that forces your coding agent to reproduce a bug with a failing test before changing code, apply the smallest fix, and prove it with the test suite.

## Prompt

```
---
name: test-first-bugfix
description: Fixes bugs by first writing a failing test that reproduces them, then making the smallest change that passes. Use when the user reports a bug, a wrong result, a crash or a failing behaviour and asks for a fix.
---

# Test-first bug fix

## Steps
1. Restate the bug as: given this input or state, expected X, got Y. If you cannot, ask for the missing detail.
2. Find the code path. Read it; do not edit yet.
3. Write a test that reproduces the bug in the project's existing test framework and style. Run it and confirm it fails for the right reason (the bug, not a typo or missing import). Show the failure output.
4. Find the root cause. Explain it in two or three sentences.
5. Make the smallest change that fixes the cause. No refactors and no unrelated cleanups.
6. Run the new test (it must pass), then the related test files, then the full suite if it is quick.
7. Look for the same bug pattern elsewhere with a search, and list matches without fixing them.

## Output format
- Bug statement
- Failing test output (before)
- Root cause
- Diff of the fix
- Test results (after)
- Similar code found elsewhere

## Stop and ask
- The bug cannot be reproduced in a test after two attempts. Report what you tried.
- The fix needs a change to a public interface, a database migration or a new dependency.
- Existing tests fail before your change; report them rather than fixing them silently.

## Risks
Fixing the symptom. If the fix is a special case for the test input, keep looking for the cause.
```

## Usage Notes

Save as .claude/skills/test-first-bugfix/SKILL.md in a repo, or ~/.claude/skills/test-first-bugfix/SKILL.md for every project. Claude Code loads it when the description matches; the same file works in Codex, Cursor and Gemini CLI, which also read SKILL.md.

Tips and common edits

Save as .claude/skills/test-first-bugfix/SKILL.md in a repo, or ~/.claude/skills/test-first-bugfix/SKILL.md for every project. Claude Code loads it when the description matches; the same file works in Codex, Cursor and Gemini CLI, which also read SKILL.md.

Questions about this prompt

More in Coding

Release Notes From Git Log Skill for Users and Developers (SKILL.md)

A SKILL.md that writes release notes from the commits between two tags, split into a plain-language section for users and a technical changelog for developers.

Pre-Merge Code Review Checklist Skill (SKILL.md)

A save-ready SKILL.md that has your coding agent review a branch before merge: correctness, security, tests and migrations, with findings ranked by severity and no style nitpicks.

Conventional Commit and PR Description Writer Skill (SKILL.md)

A ready-to-save SKILL.md that makes your coding agent write Conventional Commits messages and pull request descriptions from the staged diff, never from guesses.

Failing Test First Bug Fix

Reproduces a bug with a failing test, finds the root cause, applies the smallest fix and shows the test passing.

Brand Voice Guard Skill That Checks Drafts Against VOICE.md (SKILL.md)

A SKILL.md that makes Claude write and edit in your brand's voice: it reads a VOICE.md in the project, or builds one from samples, then checks every draft against it.

Meeting Notes to Decisions and Action Items Skill (SKILL.md)

A SKILL.md that turns any meeting transcript or rough notes into a decision log, owner-and-date action items, open questions and a ready-to-send recap email.

Spreadsheet and CSV Cleanup Report Skill (SKILL.md)

A SKILL.md that has your agent profile a messy CSV or spreadsheet, fix it in a copy with a script, and report every change so the cleaned data can be trusted.

Debug an Error From the Message and the Code Around It

Finds the most likely cause of an error from the message and the relevant code, ranks other possible causes, and gives the smallest fix plus a way to prove it worked.

Edge-Case Test Suite for One Function in Your Existing Test Framework

Writes tests for a single function that cover normal inputs, boundaries, bad input and error paths, in the test framework your project already uses.

Explain a Codebase Folder to a New Developer on Their First Day

Produces an onboarding guide for one folder of a codebase: what it does, how data moves through it, the files to read first and the traps a new developer should avoid.

Root Cause Analysis from Stack Trace and Logs

Turns an error report, stack trace, and logs into ranked root-cause hypotheses. Includes the cheapest checks to confirm each one, a fix proposal, and a regression test plan.

Write a SKILL.md From a Workflow You Keep Repeating

Interviews you about a task you do over and over, then writes a complete, save-ready SKILL.md with a trigger description, steps, output format and stop conditions.