bug-pattern-diagnosis-en
by @hgvgfgvh
Diagnoses bugs by matching user-reported symptoms against a curated library of past bug cases under experience/, using prior cases as memory references (neve...
clawhub install bug-pattern-diagnosis-enπ About This Skill
name: bug-pattern-diagnosis-en description: Diagnoses bugs by matching user-reported symptoms against a curated library of past bug cases under experience/, using prior cases as memory references (never as copy-paste answers). Accumulates new cases after each successful investigation. Use when the user reports "weird error / intermittent failure / only reproduces in specific environments / strange logs".
Bug Pattern Diagnosis (Symptom-Based Triage & Experience Accumulation)
Skill Purpose
This skill works like a doctor diagnosing a patient:
1. Collect symptoms β Ask the user to describe the bug (error messages, reproduction rate, environment, log patterns, etc.)
2. Recall past cases β Look up similar bugs in the experience/ folder as reference memory
3. Diagnose independently β Investigate using the current project's context. Past cases are only sources of inspiration and hypotheses, never reused as-is
4. Accumulate new experience β After successfully identifying a new bug, save it as a new BUGxx.md for future reference
Core value: Let past troubleshooting experience inspire the direction of new investigations β but never replace independent thinking. Similar symptoms do not guarantee the same root cause. Logs that look identical may hide completely different failures.
Iron Rule: Experience Is Reference, Not the Answer
> This is the single most important principle of this skill.
The BUGxx.md files under experience/ are an old doctor's case notebook, not a prescription template. When examining a new patient:
Why Direct Reuse Is Forbidden
1. Symptoms can match, root causes may not: "NPE + intermittent + multi-replica" may be a missing header in one case, a Redis connection pool flake in another, or a GC stop-the-world race in yet another β or multiple overlapping problems. 2. Projects differ wildly: The same code pattern behaves differently across versions, configs, and dependencies. 3. AI misdiagnosis is expensive: Copy-pasting a case misleads the user into changing code based on a wrong premise, masking the real bug. 4. The value of experience is in *prompting thought*, not *giving answers*: Good doctors read case files to broaden their thinking, not to copy-paste treatment plans.
Correct Usage Posture
| Situation | Wrong approach | Right approach |
|---|---|---|
| Symptoms match closely | "This is BUG01, modify invokeRemoteDeviceOpt and add x-token-payload" | "Your description reminds me of BUG01 β one of its signatures was asymmetric logs across replicas. Before proceeding, can you verify: do the failing requests actually produce 'stack trace on one replica, one-liner on another'?" |
| Partial feature match | "Not exactly, but the BUG01 fix should still work" | "There's a diagnostic trick from BUG01 that might apply here β send 100 requests in a row and see if the success rate is β 1/N. Let's validate that first." |
| Case contains specific code | Paste BUG01's fix and ask user to apply | "BUG01's fix idea was propagating headers, but for your project you need to first confirm: (1) What headers does your receiver actually depend on? (2) Is the serialization identical to the gateway's? We'll need these answers before writing any code." |
Case Library Structure
bug-pattern-diagnosis-en/
βββ SKILL.md β This file (purpose, flow, matching rules)
βββ experience/ β Case library
βββ BUG01.md β One document per case
βββ BUG02.md
βββ ...
Each BUGxx.md follows a fixed structure for fast lookup:
1. Case summary (one paragraph)
2. Symptom / signature checklist (like "positive findings" in a medical case β used for matching)
3. Detailed explanation (pathology / root-cause chain)
4. Diagnostic methodology (investigation flow / key techniques)
5. Remediation plan (fix + safety net + hardening)
6. Prevention checklist (to avoid recurrence)
7. Playbook for similar intermittent bugs (step-by-step for analogous cases)
When to Activate This Skill
Prefer this skill when the user describes issues like:
Core Flow
Step 1: Read the Case Library Index
Read the symptom / signature checklist section from all BUG*.md files under experience/ (the first 30-50 lines of each file typically suffice). Do not read full files upfront.
Step 2: Structure the Symptoms
Extract key features from the user's description, covering at least these dimensions:
| Dimension | Examples | |---|---| | Error signal | NPE / 500 / 403 / timeout / data corruption / deadlock | | Reproduction rate | 100% / 50% / sporadic / specific conditions | | Environment delta | Doesn't repro locally? repros in test? in prod? | | Multi-instance traits | Single replica / multiple? how many? | | Log distribution | Concentrated on one instance / scattered / one has stack one doesn't | | Triggering conditions | Specific user / specific params / specific time window | | Recent changes | New release? config change? scale up/down? dependency upgrade? |
Step 3: Recall Cases (Not Match Conclusions)
Compare the structured features against each case library entry for similarity, but never treat the result as a conclusion. No matter how high the similarity, a case is only a "prior experience worth consulting", not a "confirmed answer".
Similarity handling:
Step 4: Offer Investigation Suggestions (Not Diagnostic Conclusions)
Do not assert "this is BUGxx". Use the tone of "past cases had similar traits, here are possible directions and ways to verify".
Recommended response structure:
Step 4 β Negative Example (DO NOT OUTPUT)
β "Based on your symptoms, this is BUG01 (multi-replica intermittent NPE).
The root cause is that invokeRemoteDeviceOpt drops x-token-payload.
Apply this fix: [pastes BUG01's code directly]"
Step 4 β Positive Example
β
"A few things in your description stand out:
1) Intermittent failure with success rate near 50%
2) The error looks token-related, but the client clearly sent a token This reminds me of a past case (BUG01) where similar symptoms were
caused by 'multi-replica internal calls dropping an identity header'.
Your project isn't necessarily the same thing, so **let's validate
a couple of hypotheses first**:
Q1: How many replicas does your service have? Does the success rate
approximate 1/N?
Q2: Can you tail logs from all replicas simultaneously and see if
the failing request leaves traces on multiple replicas with
asymmetric detail levels?
Run those two checks, share the results, and we'll pick a path."
Step 5: Accumulate a New Case (Optional)
Proactively ask the user whether to capture this investigation as a new case when:
With user consent, create BUGxx.md (numbering = current max + 1) following the case document template below.
General Methodology (When No Case Matches)
Investigate unknown bugs in this order:
1. Quantify the Symptom
2. Inspect Deployment Topology
1/N or (N-1)/N?3. Cross-Instance Log Comparison
4. Source vs Deployed Binary Parity
javap -c -p the deployed jar's key classes and diff against local source5. Protocol Boundary Audit
If you suspect context propagation issues:
getHeaderNames() at the receiver to verify what headers actually arrive6. Compare Against Sibling Code
Case Document Template (for new BUG*.md files)
# BUGxx: Case Summary
Symptom / Signature Checklist (for matching)
> If N+ of these hold simultaneously, high probability of this case
[ ] Feature 1 (concrete, verifiable)
[ ] Feature 2
[ ] Feature 3
[ ] ... Key Log Fingerprints
Exclusion Criteria (Negative Signals)
If appears, this is NOT this case Detailed Explanation / Root Cause Chain
Diagnostic Methodology
Techniques Used
... Diagnostic Steps (in order)
1. ...
2. ...
3. ...
Remediation Plan
Root-Cause Fix
Safety Net / Defense in Depth
Hardening / Cleanup
Prevention Checklist
During development:
[ ] ... During deployment:
[ ] ... During review:
[ ] ... Playbook for Similar Intermittent Bugs
When symptoms look similar, walk through:
1. Quantify reproduction (10 min)
2. Check topology (5 min)
3. Cross-replica log diff (30 min)
4. ...
References
Relevant file paths
Relevant PRs / commits
Relevant wiki
Output Style Constraints
Hard Rules (Forbidden Actions)
BUGxx.md is "how that project fixed it", not necessarily right for the current project