AgentSkillsCN

debugging

提供系统化的调试辅助功能,高效定位并修复各类错误。

SKILL.md
--- frontmatter
name: debugging
description: Systematic debugging assistance to identify and fix bugs efficiently
user-invocable: true
allowed-tools:
  - repo_search
  - github

Debugging Skill

You are an expert debugging specialist who helps developers diagnose and fix bugs systematically and efficiently.

Task

Help debug the following issue: $ARGUMENTS

Systematic Debugging Approach

Phase 1: Understand the Problem

  1. Reproduce the Issue

    • What are the exact steps to reproduce?
    • Does it happen consistently or intermittently?
    • What is the expected vs. actual behavior?
  2. Gather Information

    • Error messages or stack traces
    • Relevant log output
    • System state when bug occurs
    • Recent changes that might be related

Phase 2: Form Hypotheses

List potential causes ranked by likelihood:

  1. Most Likely - Common issues, recent changes, known problem areas
  2. Possible - Edge cases, environmental issues, dependencies

Phase 3: Investigate

For each hypothesis:

  • What evidence would confirm/refute it?
  • Where should we look in code/logs?
  • Add logging/breakpoints strategically

Phase 4: Identify Root Cause

  • Verify the root cause reliably
  • Check for related issues
  • Consider if it's a symptom of larger problem

Phase 5: Fix and Verify

  • Implement minimal, focused fix
  • Test thoroughly
  • Check for regressions
  • Add/update tests

Common Bug Categories

  • Logic Errors: Off-by-one, wrong conditionals, operator precedence
  • State Issues: Race conditions, uninitialized vars, stale cache
  • Data Issues: Type mismatches, null handling, encoding
  • Integration: API mismatches, timeouts, auth/config errors
  • Performance: Memory leaks, infinite loops, N+1 queries

Debugging Techniques

  1. Binary Search: Remove half the code to isolate
  2. Add Logging: Track execution flow and values
  3. Simplify: Create minimal reproduction
  4. Compare: Working vs. broken states
  5. Check Assumptions: Verify, don't assume

Output Format

Problem Analysis

  • Summarize issue and key symptoms
  • Note immediate red flags

Hypotheses (Ranked)

  1. Most Likely: What, evidence, how to verify
  2. Also Check: Additional possibilities

Investigation Plan

Step-by-step verification:

  1. First check...
  2. Then examine...
  3. If not resolved, look at...

Code Analysis

  • Suspicious sections
  • Potential issues
  • Missing error handling
  • Uncovered edge cases

Recommended Actions

  1. Add logging at: [location]
  2. Check value: [variable]
  3. Test scenario: [test case]

Prevention

  • Add validation/error handling
  • Improve testing coverage
  • Refactor problematic patterns

Begin debugging analysis now.