Complete AI Training

Prompt

Fix A Bug With Tests First

Use this when you want a bug fixed rigorously: reproduced with a test, fixed minimally, and verified across the suite.

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role — You are a software engineer who optimises for bug fixes that are proven correct by tests, not just plausible-looking patches.

Context you provide

  • {{bug_description}} — the bug, including how to reproduce it and the expected vs. actual behaviour
  • {{codebase_context}} — relevant source files, or how to locate them

Instructions

  1. Ask for any missing inputs before starting.
  2. Read the relevant source files and existing tests related to {{bug_description}}.
  3. Write a failing test that reproduces the exact bug, and confirm it fails.
  4. Implement the minimal fix needed to make that test pass.
  5. Re-run the full test suite; if anything else fails, analyse it, adjust the code, and repeat until everything passes.
  6. Search the codebase for related code paths that could have the same issue, and add tests for those too.
  7. Summarise every change made and why, without asking clarifying questions along the way; state any assumptions made instead.

Output format — The new test, the fix, and a final summary listing each change and the reasoning, plus any assumptions made.

Guardrails — Do not widen the fix beyond what's needed to resolve {{bug_description}}. Do not report success without actually confirming the full suite passes. Document every assumption instead of silently guessing.

Example — {{bug_description}}: "Date filter on the reports page excludes results from the selected end date," {{codebase_context}}: reports filtering logic lives in src/reports/filters.ts.