AgentSkillsCN

debugging

系统化调试与根源分析。适用于故障排查、复杂问题的诊断、性能剖析,以及调试策略的制定。

SKILL.md
--- frontmatter
name: debugging
description: |
  Systematic debugging and root cause analysis. Use for investigating errors,
  diagnosing complex issues, performance profiling, or developing debugging
  strategies.

Debugging Skill

Systematic debugging, root cause analysis, and error investigation.

When to Use

  • Investigating errors or bugs
  • Diagnosing unexpected behavior
  • Performance issues
  • Production incidents
  • User says "debug", "error", "why is this broken", "not working"

Debugging Approach

1. Understand the Problem

  • What is expected vs actual behavior?
  • When did it start? Can it be reproduced?
  • What changed recently?

2. Gather Evidence

  • Read logs and stack traces
  • Review recent changes
  • Identify patterns

3. Form Hypothesis

  • What is the most likely cause?
  • What evidence supports this?

4. Test Hypothesis

  • Design targeted test
  • Observe results
  • Refine if needed

5. Implement Fix

  • Develop minimal fix
  • Verify resolution
  • Add regression tests

6. Document

  • Root cause and fix
  • Add monitoring/alerting

Issue Categories

  • Logic Errors: Incorrect conditions, off-by-one, wrong operators
  • State Errors: Race conditions, stale closures, shared mutable state
  • Integration Errors: API mismatch, auth issues, timeouts
  • Performance: N+1 queries, missing indexes, memory leaks
  • Environment: Config differences, missing vars, permissions

Systematic Process

Follow the six-step debugging process with:

  • Checklists for investigation and evidence gathering
  • Severity levels (CRITICAL, HIGH, MEDIUM, LOW)
  • Output templates for documentation
  • Tools by environment (browser, Node.js, database)

See refs/process.md for detailed process, checklists, and severity guidelines.

Common Patterns

Debugging techniques and solutions for:

  • Null/undefined issues with optional chaining
  • Async timing and race conditions
  • Scope and closure problems
  • Binary search debugging with git bisect
  • Performance profiling
  • Database query analysis

See refs/patterns.md for code examples and debugging techniques.

External Integration Discovery

Debugging can leverage available integrations by capability:

CapabilityDiscovery PatternsProvides
Error trackingsentry, rollbar, datadogRecent errors, stack traces, user context
Observabilitynewrelic, dynatrace, telemetryAPM data, traces, metrics
Loggingsplunk, elastic, cloudwatchLog aggregation, search

Run ListMcpResourcesTool to discover available integrations. Fall back to local log analysis via wicked-search when none available.

Notes

  • Start with the simplest explanation
  • Use scientific method: hypothesis, test, refine
  • Document your findings for future reference
  • Add tests to prevent regression