Skip to content

Detect Duplicate Bugs with AI

Bug Triage & ReportingUpdated 2026-10-11intermediate
TL;DR

Given a new bug description and N existing bug summaries, returns a ranked list of duplicate candidates with similarity scores (0-100) based on ROOT-CAUSE likelihood rather than surface text: with one-line evidence per candidate.

When to use it

  • Triaging a high-volume bug intake (50+ bugs/week) where duplicates waste cycles.
  • Closing a long-stale bug and need to find it might have re-surfaced under a different title.
  • Looking for patterns across customer complaints: same root cause, different reports.
  • Auditing a bug tracker for likely duplicates that should be merged.

The prompt

XML-tagged: works best with Claude
duplicate-bug-detector.claude.mdprompt
<role>You are a bug triage specialist. You judge duplicates by ROOT CAUSE likelihood, not surface text. Two bugs that mention "checkout" may be unrelated. Two bugs with totally different titles may be the same race condition.</role> <context>Similarity is judged on: (a) likely root cause overlap, (b) shared component / code path, (c) shared trigger conditions. Surface text overlap (same words) is a weak signal: it can mislead in both directions.</context> <task>For the new bug and the candidate list:1. Score each candidate 0-100 for likelihood of being a duplicate.2. Provide ONE LINE of evidence per candidate explaining the score.3. Recommend an action per candidate: MERGE (clear duplicate, > 80), LIKELY DUPLICATE (review, 50-80), UNRELATED (< 50).4. Identify any pattern across multiple candidates suggesting a broader common cause.</task> <input>New bug description: {new_bug}Candidate bugs (with brief summaries): {candidates}Component context (optional, helps disambiguate): {context}</input> <constraints>- Scoring based on ROOT CAUSE likelihood, not text overlap.- Evidence cites SHARED conditions (component, trigger, error code) not shared keywords.- A high score requires more than overlapping keywords: must cite a causal mechanism.- If candidates are sparse or limited info, lower scores and note ambiguity.</constraints> <output_format>Two sections:1. **Ranked table**: Candidate | Score (0-100) | Evidence | Action2. **Pattern note**: 1-2 sentences if multiple high-score candidates suggest a broader root cause; otherwise "No pattern observed"</output_format> <approach>Before writing, identify the new bug's likely root cause (proximate + systemic). Use that to evaluate similarity instead of word overlap.</approach>

Example

Input
New bug description: Discount code SAVE20 applied successfully in UI but subtotal doesn't update for carts > $1000. POST /api/cart/discount returns 200 with discount: 0.

Candidate bugs:
1. [BUG-441] Checkout fails for carts over $1500 with promo code SALE15
2. [BUG-512] Promo code field allows expired codes to "apply" with no error
3. [BUG-477] Cart subtotal flickers when applying any discount code
4. [BUG-403] /api/cart/discount returns 0 discount amount for high-value orders
5. [BUG-518] Discount validation message uses wrong language in Spanish locale

Component context: Same e-commerce checkout system; recent refactor of discount-eligibility logic.
Output
## Ranked table

| Candidate | Score | Evidence | Action |
|-----------|-------|----------|--------|
| BUG-403: /api/cart/discount returns 0 discount amount for high-value orders | 92 | Same API endpoint, same response shape (discount=0), same high-value cart trigger, almost certainly the same root cause | MERGE |
| BUG-441: Checkout fails for carts > $1500 with promo code SALE15 | 68 | Different code (SALE15 vs SAVE20) but same cart-value threshold pattern, same checkout failure: likely same backend bug affecting multiple promo codes | LIKELY DUPLICATE |
| BUG-477: Cart subtotal flickers when applying any discount code | 18 | Surface keyword overlap ("discount", "subtotal") but root cause is a UI render race, not a backend zero-discount issue: unrelated | UNRELATED |
| BUG-512: Promo code field allows expired codes to apply with no error | 15 | Different problem class (validation gap), the new bug is about valid codes returning zero, not invalid codes being accepted | UNRELATED |
| BUG-518: Discount validation message uses wrong language in Spanish locale | 3 | Pure localization bug, no shared mechanism with the new bug despite keyword overlap | UNRELATED |

## Pattern note

BUG-403, BUG-441, and the new bug all involve high-cart-value triggering discount-amount-zero responses. This is likely a single backend bug in the discount-eligibility logic that triggers above a value threshold: probably the recent refactor mentioned in component context. Merge the new bug into BUG-403 and link BUG-441 as related; investigate the threshold logic as the systemic cause.

Common pitfalls

  • Model scores on word overlap: 'discount' in both gets high score regardless of mechanism. Re-prompt to enforce mechanism-based scoring.
  • Sparse candidates produce high scores from limited evidence. Lower confidence when descriptions are short.
  • Pattern note gets skipped when not enforced; that's where the most valuable insight often hides (multiple candidates sharing a root cause).
  • Score thresholds (> 80, 50-80, < 50) should match your team's auto-merge tolerance; adjust if needed.

Tips

  • Run this on a regular cadence (weekly) against open bugs vs newly filed ones to keep the tracker clean.
  • Feed in the candidates from a similarity search first (e.g., JIRA "similar issues" feature): limits the prompt size and improves accuracy.
  • Don't auto-merge based on score alone; treat as triage suggestion. Human confirms.
  • When the pattern note surfaces a broader root cause, file a META bug to track the systemic fix.

FAQ

How do I integrate this with JIRA / Linear automatically?

Use their similarity APIs to pre-filter the candidate set, then feed the top 5-10 candidates into this prompt for ranking. Most bug trackers have search APIs but lack the causal-mechanism scoring this prompt provides.

What's a safe auto-merge threshold?

Conservative: never auto-merge, always require human confirmation. Moderate: auto-merge at > 95 confidence. Aggressive: auto-merge at > 85 and notify reporter. False-merge cost is high (you lose customer data), so err conservative.

What's the false-positive cost vs false-negative cost?

False positive: you wrongly merged two distinct bugs; customer's report gets lost in another ticket. False negative: you missed a duplicate; engineer wastes time triaging the same issue twice. Most teams should accept FN over FP: keep the threshold high.

Can this find duplicates across years of historical bugs?

Yes, but feed it in batches of 10-20 candidates per run for quality. Beyond that, the model loses precision in ranking.