All templates
🐛Coding

Debug a Bug in an Existing Codebase

A repository-aware debugging prompt that asks the coding assistant to inspect evidence, identify the root cause, make a focused fix, and verify it.

Best for: Developers using Cursor or Copilot

Prompt template

Investigate and fix the following bug in the existing repository:

BUG
[Describe the observed behavior, expected behavior, and exact reproduction steps.]

CONTEXT
- Runtime/framework and versions: [fill in]
- Relevant files or modules: [fill in]
- Recent changes that may be related: [fill in or "unknown"]
- Logs, stack traces, or failing tests: [paste here]

INSTRUCTIONS
1. Inspect the relevant implementation and adjacent tests before proposing a change.
2. Distinguish the symptom from the root cause. State the most likely root cause and the evidence supporting it.
3. Make the smallest coherent fix that follows existing repository conventions.
4. Do not introduce new dependencies, change public interfaces, or perform unrelated cleanup unless strictly required.
5. Add or update a regression test that fails before the fix and passes after it.
6. Run the focused tests, lint, and build commands available in the repository.

OUTPUT
- Root cause
- Files changed and why
- Verification performed
- Any remaining risk or unverified assumption

If the evidence is insufficient, ask targeted questions instead of guessing.

Customize before using

  • Replace the bug section with exact reproduction steps.
  • List the real framework versions and commands.
  • Paste the smallest useful logs rather than an entire production dump.

Result quality checks

  • Root cause is supported by repository evidence.
  • Fix stays inside the requested scope.
  • A regression test proves the behavior.

Related templates