AgentSkillsCN

systematic-debugging

根本原因分析与调试方法论

SKILL.md
--- frontmatter
name: systematic-debugging
description: Root cause analysis and debugging methodology

Systematic Debugging

Find root causes, not just symptoms.


Debugging Flow

code
1. REPRODUCE → Can you trigger the bug?
2. ISOLATE   → Where exactly does it fail?
3. IDENTIFY  → What is the root cause?
4. FIX       → Minimal change to solve it
5. VERIFY    → Does it work? Any regressions?

Questions to Ask

Reproduce

  • What are the exact steps?
  • What's expected vs actual?
  • Is it consistent or intermittent?

Isolate

  • Which file/function fails?
  • What changed recently?
  • What are the inputs?

Identify

  • Is this the root cause or symptom?
  • Why does this happen?
  • Are there similar issues?

Error Pattern Analysis

SymptomCheck
500 errorLogs, exception details
404 errorRoutes, URLs
Null referenceData flow, null checks
Type errorTypes, casting
Works locallyEnvironment config
IntermittentRace conditions, timing

Logging Strategy

csharp
// C# - structured logging
_logger.LogError(ex, "Failed to process order {OrderId}", orderId);
typescript
// TypeScript
console.error('Failed to fetch user:', { userId, error });

Fix Principles

PrincipleDescription
MinimalSmallest change that works
FocusedOnly fix the bug
TestedAdd regression test
DocumentedComment if complex

Post-Fix Checklist

  • Root cause confirmed
  • Minimal fix applied
  • Regression test added
  • No side effects
  • Documentation updated

DO / DON'T

✅ Do❌ Don't
Find root causePatch symptoms
Minimal changesMultiple fixes
Add testsSkip verification
Check side effectsAssume it works