AgentSkillsCN

debugging

具备系统化调试能力,可精准复现Bug、深入分析根本原因并合理界定修复范围。 适用于Bug反馈响应、错误调查以及事件分析等场景。 触发条件:“Bug修复”、“错误分析”、“调试”、“事件根因分析”、“Debug”

SKILL.md
--- frontmatter
name: debugging
description: |
  Systematic debugging skill for bug reproduction, root cause analysis, and fix scope determination.
  Used for bug report response, error investigation, and incident analysis.
  Triggers: "bug fix", "error analysis", "debugging", "incident root cause", "debug"

Debugging

Goal

Systematically trace the root cause of a bug and determine the fix scope based on reproducible evidence.

Instructions

Step 1: Symptom Summary

Extract the following from the bug report or user description:

  • What: What behavior/result is abnormal?
  • When: Always? Only under specific conditions? Since a recent deployment?
  • Where: Which endpoint/screen/service?
  • Error info: Error message, stack trace, HTTP status code, logs
code
🐛 Bug Summary
Symptom: [What is going wrong and how]
Reproduction conditions: [Known conditions / Unknown]
Error: [Message or code]
Recent changes: [Related deployment/commit if any]

Step 2: Reproduce

Always reproduce the bug before fixing it.

Reproduction strategies:

SituationApproach
Clear error messageTrace directly to error location in code
Occurs only with specific inputWrite test case with that input
Intermittent occurrenceAnalyze logs, suspect concurrency/timing
Environment-dependentCompare env variables, config, dependency versions

Reproduction confirmation:

  • Can the bug be reproduced locally?
  • Has a reproducible test case been written? (a failing test)

If it cannot be reproduced, do not fix it. Request additional information from the user.

Step 3: Root Cause Analysis (RCA)

Find the cause, not the symptom.

Analysis techniques:

TechniqueWhen to useMethod
BacktrackingError location is clearTrace call chain top→down from stack trace
Binary searchUnclear when it brokegit bisect or compare logs by time period
Hypothesis testingMultiple cause candidatesHypothesis → verify with logs/code → eliminate → repeat
IsolationComplex systemRemove dependencies one by one to identify the causal module
Data tracingIncorrect result valuesIdentify the corruption point along input → transformation → output path

Root cause classification:

TypeExampleFix Complexity
Logic errorCondition mistake, off-by-one, null not handledLow
State issueRace condition, cache inconsistency, session corruptionHigh
Data issueBad migration, corrupted dataMedium–High
Environment/ConfigEnv variable, version mismatch, dependency conflictLow
External dependencyAPI change, library bug, infrastructure outageVariable

Output:

code
🔍 Root Cause Analysis

Cause type: [Logic error / State issue / ...]
Location: [filename:line] or [module/service name]
Description: [Why this code is the problem, specifically]
Evidence: [Reproduction test, logs, code path]

Step 4: Determine Fix Scope

After identifying the root cause, assess the scope of the fix.

  • Does this fix affect other features?
  • Does the same bug pattern exist elsewhere? (Shotgun Fix needed?)
  • Does the fix change an API contract or data structure?

Classification by scope:

ScopeCriteriaApproach
IsolatedSingle file/function, no impact elsewhereFix immediately
SpreadingSame pattern exists in multiple placesList all occurrences, batch fix
StructuralDesign flaw is the cause, refactoring neededCreate plan first (consider switching to full-dev-cycle)

Constraints

  • Do not fix without reproduction — do not change code based on "this is probably the cause"
  • Target root cause fix (Root Fix), not symptom fix (Symptom Fix)
  • If fix scope is Structural, notify the user and recommend switching to full-dev-cycle