AI‑Powered Defect Analyzer: A Structured Full‑Chain Bug Investigation Skill
The article presents a step‑by‑step AI‑driven defect‑analyzer skill that combats confirmation bias by forcing analysts to separate facts from hypotheses, enumerate multiple possible causes with evidence, rank investigations by likelihood and cost, and produce verifiable, repeatable bug‑fix reports for backend incidents.
Why a Structured Approach Is Needed
A production incident cost ¥30,000 because a tester assumed a slow database query on the coupon table was the root cause. After adding an index and optimizing SQL, the problem persisted. The real issue was a mis‑configured circuit‑breaker: the gateway cut the connection at 3 seconds while the coupon service timed out after 5 seconds, leaving the request hanging.
The core enemy of defect analysis is confirmation bias – seeing a clue, forming a story, and then only seeking evidence that supports that story.
The defect-analyzer Skill
This skill splits defect analysis into eleven mandatory parts, forcing a disciplined workflow.
1. Defect Phenomenon
Operation: User selects a coupon on the order page and clicks “Submit Order”.
Expectation: Order completes within 2 seconds and redirects to the payment page.
Actual: UI spins for >10 seconds, shows “System Busy”, and no order is created.
2. Impact Scope
Severity: P0 – core ordering function broken.
Frequency: High‑frequency intermittent; started at 10:00 am, multiple users reported, not 100 % reproducible.
3. Known Facts (Evidence)
Page spins >10 seconds – user screenshots & customer‑service feedback.
Final error is “System Busy” – user screenshots.
Orders succeed without coupons – partial user feedback.
Problem started at 10:00 am – timeline from support tickets.
4. Unknown Information
Questions that still lack answers, e.g., exact reproduction steps, error‑code details, affected versions, user‑segment patterns.
5. Possible Causes (Likelihood & Evidence)
Coupon‑deduction DB slow query / deadlock (High) – no‑coupon orders work, 10‑second spin suggests lock wait.
Coupon service timeout without degradation (High) – “System Busy” indicates timeout but circuit‑breaker didn’t fire.
Coupon status‑check bug (Medium) – order not generated, possible infinite loop in validation.
Database connection‑pool exhaustion (Medium) – sudden spike at 10:00 could be batch jobs consuming connections.
Frontend parameter error (Low) – no direct evidence, only theoretical.
6. Verification Methods
Slow query / deadlock: Search slow‑query logs after 10:00 for coupon SQL. Expected result: execution time >10 s or lock‑wait entries. Cost: Low.
Service timeout without degradation: Inspect the call‑chain of “Submit Order” for coupon‑service latency and circuit‑breaker status. Expected result: call exceeds timeout and breaker not triggered. Cost: Medium.
Status‑check bug: Reproduce in a test environment with a debugger, watch checkCouponStatus(). Expected result: thread hangs inside the method. Cost: Medium.
7. Recommended Investigation Order
Check slow‑query logs & connection‑pool metrics (≈5 min) – validates causes 1 and 4.
Inspect call‑chain monitoring for timeout & breaker (≈10 min) – validates cause 2.
Add debug logs in test env to reproduce and observe behavior (≈30 min) – validates causes 1‑3.
Ask ops for change records around 10:00 am (meeting required).
The rule is “do the cheap things first”: high‑likelihood, low‑cost items are investigated before expensive or low‑likelihood ones.
8. Additional Information Needed
Error logs for the “Submit Order” API after 10:00 am (ELK export).
APM P50/P99 response‑time distribution.
Full trace IDs for failed requests (trace platform).
Slow‑query statements >1 s after 10:00 am (DBA).
Code/configuration changes in the 24 h before 10:00 am (release platform).
9. Possible Fix Directions
Option A – Optimize slow query: Add index / reduce joins (root‑cause fix, may affect other features).
Option B – Adjust circuit‑breaker: Set timeout to 2 s and degrade gracefully (quick stop‑bleed, requires compensation for coupon validation).
Option C – Temporarily disable coupons: Deploy config to hide coupon entry (5 min rollout, impacts user experience).
10. Post‑Fix Validation
Functional verification: normal flow, error flow, boundary values.
Regression: full coupon test suite + order‑flow suite.
Data check: ensure no “order created but coupon not deducted” dirty data.
Monitoring: P99 response time < 2 s.
Long‑term observation: watch 24 h for new “System Busy” incidents.
11. Regression Test Points to Prevent Recurrence
Concurrent coupon usage – only one of two orders should succeed (P0).
Coupon‑service timeout – verify degradation works (P0).
Boundary: coupon value equals order amount.
Performance: coupon‑deduction P99 < 500 ms (P1).
Quality Red Lines (Hard Constraints)
Never conclude without evidence.
Never mix fact and hypothesis.
Always list ≥2‑3 possible causes.
Provide a verification method for every hypothesis.
Always specify impact severity.
How to Use the Skill
Place the defect-analyzer-cross-platform folder under ~/.workbuddy/skills/ and invoke it with a prompt like “Analyze this defect”. Python helper scripts are also supplied to generate the 11‑part framework from a markdown description or to check an existing draft for missing sections.
Conclusion
By forcing analysts to record facts, enumerate hypotheses, rank by likelihood × cost, and verify each step, the defect-analyzer skill turns intuition‑driven debugging into a repeatable, bias‑resistant process, saving time and preventing costly mis‑diagnoses.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
