Fix a Bug Without Breaking Things

Find every affected code path and the same bug elsewhere before landing the minimal fix.

Intermediate1 min read

Customize

Fill these in and the prompt below updates as you type. Anything you leave blank stays as a placeholder.

Your prompt

4 placeholders left
I have a bug: {{bug_description}}

Expected behavior: {{expected}}
Actual behavior: {{actual}}

Here's the relevant code:
{{code}}

Before suggesting a fix:
- Identify all code paths affected.
- Check if the fix could break any existing functionality.
- Look for other places in the code with the same pattern (they might have the same bug).

Then provide: the minimal fix (smallest change that solves the problem), an explanation of why it works, a test case that proves the bug is fixed, and a test case that proves existing functionality still works.

Similar prompts

Reproduce an Intermittent Bug

Rank the likely causes of a flaky bug and get a deterministic way to reproduce the top one.

Reproduce, Then Fix

Force a failing test that captures the bug before any fix is allowed to land.

Add Diagnostics Before Guessing

Instrument first, theorize second — logging with a stated plan for capturing the failure.

Add Types Incrementally

Type one file with runtime behavior frozen, and make the type-checker output the proof.