Skip to content

Fix Bug

Fix a Bug With a Failing Test First

AI Tools:
Cursor, ClaudeWorks with Cursor, Claude
Category: Cursor & AI Coding

Force the agent to reproduce the bug, write or run a failing test, then apply a minimal fix.

Prompt Quality - 100/100 · Strong

The Prompt

fix-a-bug-with-a-failing-test.md

Debug this repository like a careful teammate. Do not shotgun-rewrite.

Bug: {{bug}}
Expected: {{expected}}
Actual: {{actual}}
How to reproduce:
{{repro}}
Suspect area (if any): {{suspect}}

Process:
1. Reproduce from the description. If you cannot, stop and say what is missing.
2. Write or identify a test that fails because of this bug.
3. Apply the smallest fix. No unrelated cleanup.
4. Show the test passing.
5. Note any other call sites with the same bug.

If the bug is a misunderstanding of intended behaviour, say so instead of "fixing" it.

Negative prompt

Included when you copy the prompt

Do not shotgun-rewrite unrelated files or "clean up" while fixing. Do not skip reproduction or the failing test. Do not patch symptoms without confirming the test fails for the right reason. Do not change intended behaviour when the report may be a misunderstanding - flag it instead. Do not add flaky sleeps or broad mocks to force a green test. Do not claim fixed without showing the test pass.

The PromptUTF-8

Fill in your details below - this prompt updates as you type, then copy it.

Fill in your details

0 of 5 filled. Preview updates as you type - then copy the finished prompt (negative prompt included when present).

What is wrong.

What should happen.

What happens instead.

Steps, URL, or test command.

Files or features you already blame.

fix-a-bug-with-a-failing-test.md

Prompt preview

Debug this repository like a careful teammate. Do not shotgun-rewrite.

Bug: {{bug}}
Expected: {{expected}}
Actual: {{actual}}
How to reproduce:
{{repro}}
Suspect area (if any): {{suspect}}

Process:
1. Reproduce from the description. If you cannot, stop and say what is missing.
2. Write or identify a test that fails because of this bug.
3. Apply the smallest fix. No unrelated cleanup.
4. Show the test passing.
5. Note any other call sites with the same bug.

If the bug is a misunderstanding of intended behaviour, say so instead of "fixing" it.
0 / 5 filledPreview

Examples

Example input

Bug: Prompt share URL copies with a trailing slash doubled (…/prompt//my-slug). Expected: https://example.com/prompt/my-slug Actual: https://example.com/prompt//my-slug Repro: Open any prompt → Share → Copy link; paste into notepad. Suspect: src/lib/share-url.ts or the ShareButton handler.

What you should get

1. Reproduced by calling buildShareUrl("my-slug") - returns …/prompt//my-slug when base ends with /. 2. Added test: expect(buildShareUrl("my-slug")).toBe("https://example.com/prompt/my-slug") - fails. 3. Minimal fix: join base and path with a helper that strips duplicate slashes (or use URL constructor). 4. Test passes; ShareButton unchanged. 5. Same bug: any other place concatenating VITE_APP_URL + "/prompt/" + slug.

When to use this prompt

Use it when

  • You need help with engineers.
  • You need help with cursor users.
  • You need help with maintainers.

Skip it when

  • You only need a one-line ask with no constraints, format, or context.
  • You cannot supply the fill-in details the template asks for.
  • A different category or tool-specific workflow fits the job better.

How to get a good result

Done when

1. Reproduced by calling buildShareUrl("my-slug") - returns …/prompt//my-slug when base ends with /. 2. Added test: expect(buildShareUrl("my-slug")).toBe("https://example.com/prompt/my-slug") - fails. 3. Minimal fix: join base and path with a helper that strips duplicate slashes (or use URL constructor). 4. Test passes; ShareButton unchanged. 5. Same bug: any other place concatenating VITE_APP_URL + "/prompt/" + slug.

Common mistakes

  • Leaving bug, expected, actual vague - the model then invents placeholders.
  • Asking Cursor or Claude for a shorter answer after a long structured prompt - that throws away the format rules.
  • Stopping when the first draft appears instead of checking it against the success criteria below.

FAQ

What do I fill in before I copy this prompt?
Replace these placeholders with your details: bug, expected, actual, repro, suspect. Required fields are marked on the page. The prompt text updates as you type.
Which AI tools is this prompt written for?
It works best with Cursor, Claude. Copy the filled prompt and paste it into the tool you already use.
What should a good result look like?
1. Reproduced by calling buildShareUrl("my-slug") - returns …/prompt//my-slug when base ends with /. 2. Added test: expect(buildShareUrl("my-slug")).toBe("https://example.com/prompt/my-slug") - fails. 3. Minimal fix: join base and path with a helper that strips duplicate slashes (or use URL constructor). 4. Test passes; ShareButton unchanged. 5. Same bug: any other place concatenating VITE_APP_URL + "/prompt/" + slug.
What are common mistakes with this prompt?
Leaving bug, expected, actual vague - the model then invents placeholders. Asking Cursor or Claude for a shorter answer after a long structured prompt - that throws away the format rules. Stopping when the first draft appears instead of checking it against the success criteria below.

Best for

  • Engineers
  • Cursor users
  • Maintainers

More prompts like this — same topic and style.