[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6MZ17Y7XCSNB94YARYEWRY4":3,"skill-same:01M6MZ17Y7XCSNB94YARYEWRY4":72},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":44,"commitSha":45,"skillDirectory":46,"forksCount":47,"repositoryHtmlUrl":48,"repositoryHomepageUrl":6,"ownerHtmlUrl":49,"ownerBlogUrl":6,"ownerDescription":50,"updatedAt":51,"install":52,"resources":65},"01M6MZ17Y7XCSNB94YARYEWRY4","debugging-strategies",null,"Master systematic debugging techniques, profiling tools, and root cause analysis to efficiently track down bugs across any codebase or technology stack. Use when investigating bugs, performance issues, or unexpected behavior.","snewhouse\u002Faa-ma-forge","snewhouse","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6317143?v=4","01M6MYYWF28C4KBQHHWB9SC6TS","Stephen J Newhouse","01M6MYYWJWQMDN2ZPFMJ584SSM",6,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fsnewhouse\u002Faa-ma-forge\u002Fblob\u002Fmain\u002Fclaude-code\u002Fskills\u002Fdebugging-strategies\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"debugging","debugging strategies","strategies","use","track","down","bugs","techniques","systematic","across","technology","master","performance","behavior","profiling","stack","analysis","Tools","issues","systematic debugging","2026-11-10 10:12:30",false,"---\nname: debugging-strategies\ndescription: Master systematic debugging techniques, profiling tools, and root cause analysis to efficiently track down bugs across any codebase or technology stack. Use when investigating bugs, performance issues, or unexpected behavior.\n---\n\n# Debugging Strategies\n\n> **Origin:** Techniques refined through systematic debugging of concurrent test failures in a large TypeScript codebase (2025).\n\nTransform debugging from frustrating guesswork into systematic problem-solving with proven strategies, powerful tools, and methodical approaches.\n\n## When to Use This Skill\n\n- Tracking down elusive bugs\n- Investigating performance issues\n- Understanding unfamiliar codebases\n- Debugging production issues\n- Analyzing crash dumps and stack traces\n- Profiling application performance\n- Investigating memory leaks\n- Debugging distributed systems\n\n## Core Principles\n\n### 1. The Scientific Method\n\n**1. Observe**: What's the actual behavior?\n**2. Hypothesize**: What could be causing it?\n**3. Experiment**: Test your hypothesis\n**4. Analyze**: Did it prove\u002Fdisprove your theory?\n**5. Repeat**: Until you find the root cause\n\n### 2. Debugging Mindset\n\n**Don't Assume:**\n- \"It can't be X\" - Yes it can\n- \"I didn't change Y\" - Check anyway\n- \"It works on my machine\" - Find out why\n\n**Do:**\n- Reproduce consistently\n- Isolate the problem\n- Keep detailed notes\n- Question everything\n- Take breaks when stuck\n\n### 3. Rubber Duck Debugging\n\nExplain your code and problem out loud (to a rubber duck, colleague, or yourself). Often reveals the issue.\n\n## Systematic Debugging Process\n\n### Phase 1: Reproduce\n\n```markdown\n## Reproduction Checklist\n\n1. **Can you reproduce it?**\n   - Always? Sometimes? Randomly?\n   - Specific conditions needed?\n   - Can others reproduce it?\n\n2. **Create minimal reproduction**\n   - Simplify to smallest example\n   - Remove unrelated code\n   - Isolate the problem\n\n3. **Document steps**\n   - Write down exact steps\n   - Note environment details\n   - Capture error messages\n```\n\n### Phase 2: Gather Information\n\n```markdown\n## Information Collection\n\n1. **Error Messages**\n   - Full stack trace\n   - Error codes\n   - Console\u002Flog output\n\n2. **Environment**\n   - OS version\n   - Language\u002Fruntime version\n   - Dependencies versions\n   - Environment variables\n\n3. **Recent Changes**\n   - Git history\n   - Deployment timeline\n   - Configuration changes\n\n4. **Scope**\n   - Affects all users or specific ones?\n   - All browsers or specific ones?\n   - Production only or also dev?\n```\n\n### Phase 3: Form Hypothesis\n\n```markdown\n## Hypothesis Formation\n\nBased on gathered info, ask:\n\n1. **What changed?**\n   - Recent code changes\n   - Dependency updates\n   - Infrastructure changes\n\n2. **What's different?**\n   - Working vs broken environment\n   - Working vs broken user\n   - Before vs after\n\n3. **Where could this fail?**\n   - Input validation\n   - Business logic\n   - Data layer\n   - External services\n```\n\n### Phase 4: Test & Verify\n\n```markdown\n## Testing Strategies\n\n1. **Binary Search**\n   - Comment out half the code\n   - Narrow down problematic section\n   - Repeat until found\n\n2. **Add Logging**\n   - Strategic console.log\u002Fprint\n   - Track variable values\n   - Trace execution flow\n\n3. **Isolate Components**\n   - Test each piece separately\n   - Mock dependencies\n   - Remove complexity\n\n4. **Compare Working vs Broken**\n   - Diff configurations\n   - Diff environments\n   - Diff data\n```\n\n## Debugging Tools\n\n### JavaScript\u002FTypeScript Debugging\n\n```typescript\n\u002F\u002F Chrome DevTools Debugger\nfunction processOrder(order: Order) {\n    debugger;  \u002F\u002F Execution pauses here\n\n    const total = calculateTotal(order);\n    console.log('Total:', total);\n\n    \u002F\u002F Conditional breakpoint\n    if (order.items.length > 10) {\n        debugger;  \u002F\u002F Only breaks if condition true\n    }\n\n    return total;\n}\n\n\u002F\u002F Console debugging techniques\nconsole.log('Value:', value);                    \u002F\u002F Basic\nconsole.table(arrayOfObjects);                   \u002F\u002F Table format\nconsole.time('operation'); \u002F* code *\u002F console.timeEnd('operation');  \u002F\u002F Timing\nconsole.trace();                                 \u002F\u002F Stack trace\nconsole.assert(value > 0, 'Value must be positive');  \u002F\u002F Assertion\n\n\u002F\u002F Performance profiling\nperformance.mark('start-operation');\n\u002F\u002F ... operation code\nperformance.mark('end-operation');\nperformance.measure('operation', 'start-operation', 'end-operation');\nconsole.log(performance.getEntriesByType('measure'));\n```\n\n**VS Code Debugger Configuration:**\n```json\n\u002F\u002F .vscode\u002Flaunch.json\n{\n    \"version\": \"0.2.0\",\n    \"configurations\": [\n        {\n            \"type\": \"node\",\n            \"request\": \"launch\",\n            \"name\": \"Debug Program\",\n            \"program\": \"${workspaceFolder}\u002Fsrc\u002Findex.ts\",\n            \"preLaunchTask\": \"tsc: build - tsconfig.json\",\n            \"outFiles\": [\"${workspaceFolder}\u002Fdist\u002F**\u002F*.js\"],\n            \"skipFiles\": [\"\u003Cnode_internals>\u002F**\"]\n        },\n        {\n            \"type\": \"node\",\n            \"request\": \"launch\",\n            \"name\": \"Debug Tests\",\n            \"program\": \"${workspaceFolder}\u002Fnode_modules\u002Fjest\u002Fbin\u002Fjest\",\n            \"args\": [\"--runInBand\", \"--no-cache\"],\n            \"console\": \"integratedTerminal\"\n        }\n    ]\n}\n```\n\n### Python Debugging\n\n```python\n# Built-in debugger (pdb)\nimport pdb\n\ndef calculate_total(items):\n    total = 0\n    pdb.set_trace()  # Debugger starts here\n\n    for item in items:\n        total += item.price * item.quantity\n\n    return total\n\n# Breakpoint (Python 3.7+)\ndef process_order(order):\n    breakpoint()  # More convenient than pdb.set_trace()\n    # ... code\n\n# Post-mortem debugging\ntry:\n    risky_operation()\nexcept Exception:\n    import pdb\n    pdb.post_mortem()  # Debug at exception point\n\n# IPython debugging (ipdb)\nfrom ipdb import set_trace\nset_trace()  # Better interface than pdb\n\n# Logging for debugging\nimport logging\nlogging.basicConfig(level=logging.DEBUG)\nlogger = logging.getLogger(__name__)\n\ndef fetch_user(user_id):\n    logger.debug(f'Fetching user: {user_id}')\n    user = db.query(User).get(user_id)\n    logger.debug(f'Found user: {user}')\n    return user\n\n# Profile performance\nimport cProfile\nimport pstats\n\ncProfile.run('slow_function()', 'profile_stats')\nstats = pstats.Stats('profile_stats')\nstats.sort_stats('cumulative')\nstats.print_stats(10)  # Top 10 slowest\n```\n\n### Go Debugging\n\n```go\n\u002F\u002F Delve debugger\n\u002F\u002F Install: go install github.com\u002Fgo-delve\u002Fdelve\u002Fcmd\u002Fdlv@latest\n\u002F\u002F Run: dlv debug main.go\n\nimport (\n    \"fmt\"\n    \"runtime\"\n    \"runtime\u002Fdebug\"\n)\n\n\u002F\u002F Print stack trace\nfunc debugStack() {\n    debug.PrintStack()\n}\n\n\u002F\u002F Panic recovery with debugging\nfunc processRequest() {\n    defer func() {\n        if r := recover(); r != nil {\n            fmt.Println(\"Panic:\", r)\n            debug.PrintStack()\n        }\n    }()\n\n    \u002F\u002F ... code that might panic\n}\n\n\u002F\u002F Memory profiling\nimport _ \"net\u002Fhttp\u002Fpprof\"\n\u002F\u002F Visit http:\u002F\u002Flocalhost:6060\u002Fdebug\u002Fpprof\u002F\n\n\u002F\u002F CPU profiling\nimport (\n    \"os\"\n    \"runtime\u002Fpprof\"\n)\n\nf, _ := os.Create(\"cpu.prof\")\npprof.StartCPUProfile(f)\ndefer pprof.StopCPUProfile()\n\u002F\u002F ... code to profile\n```\n\n## Advanced Debugging Techniques\n\n### Technique 0: AST-Based Code Tracing\n\nWhen `sg` (ast-grep) is available, use structural search for precise code tracing:\n\n```bash\n# Trace all exception raise\u002Fcatch patterns\nsg run -p 'raise $EXCEPTION' -l python src\u002F\nsg run -p 'except $TYPE as $VAR:' -l python src\u002F\n\n# Find all assignments to a variable (track state mutations)\nsg run -p '$TARGET = $VALUE' -l python src\u002Fmodule\u002F\n\n# Map async call chains (find all await expressions)\nsg run -p 'await $EXPR' -l python src\u002F\n\n# Find all callers of a suspect function\nsg run -p 'suspect_function($$$ARGS)' -l python src\u002F\n\n# Find all error handler paths\nsg run -p 'except $TYPE:\n    $$$BODY' -l python src\u002F\n\n# Trace decorator usage (find wrapped functions)\nsg run -p '@$DECORATOR\ndef $NAME($$$):' -l python src\u002F\n```\n\n**When to prefer sg over Grep for debugging:**\n- Multiline patterns (function calls spanning lines)\n- Structural patterns (all try\u002Fexcept, all async\u002Fawait)\n- Precise matching (function calls vs string mentions)\n- If `sg` is unavailable, fall back to Grep + manual verification\n\n### Technique 1: Binary Search Debugging\n\n```bash\n# Git bisect for finding regression\ngit bisect start\ngit bisect bad                    # Current commit is bad\ngit bisect good v1.0.0            # v1.0.0 was good\n\n# Git checks out middle commit\n# Test it, then:\ngit bisect good   # if it works\ngit bisect bad    # if it's broken\n\n# Continue until bug found\ngit bisect reset  # when done\n```\n\n### Technique 2: Differential Debugging\n\nCompare working vs broken:\n\n```markdown\n## What's Different?\n\n| Aspect       | Working         | Broken          |\n|--------------|-----------------|-----------------|\n| Environment  | Development     | Production      |\n| Node version | 18.16.0         | 18.15.0         |\n| Data         | Empty DB        | 1M records      |\n| User         | Admin           | Regular user    |\n| Browser      | Chrome          | Safari          |\n| Time         | During day      | After midnight  |\n\nHypothesis: Time-based issue? Check timezone handling.\n```\n\n### Technique 3: Trace Debugging\n\n```typescript\n\u002F\u002F Function call tracing\nfunction trace(target: any, propertyKey: string, descriptor: PropertyDescriptor) {\n    const originalMethod = descriptor.value;\n\n    descriptor.value = function(...args: any[]) {\n        console.log(`Calling ${propertyKey} with args:`, args);\n        const result = originalMethod.apply(this, args);\n        console.log(`${propertyKey} returned:`, result);\n        return result;\n    };\n\n    return descriptor;\n}\n\nclass OrderService {\n    @trace\n    calculateTotal(items: Item[]): number {\n        return items.reduce((sum, item) => sum + item.price, 0);\n    }\n}\n```\n\n### Technique 4: Memory Leak Detection\n\n```typescript\n\u002F\u002F Chrome DevTools Memory Profiler\n\u002F\u002F 1. Take heap snapshot\n\u002F\u002F 2. Perform action\n\u002F\u002F 3. Take another snapshot\n\u002F\u002F 4. Compare snapshots\n\n\u002F\u002F Node.js memory debugging\nif (process.memoryUsage().heapUsed > 500 * 1024 * 1024) {\n    console.warn('High memory usage:', process.memoryUsage());\n\n    \u002F\u002F Generate heap dump\n    require('v8').writeHeapSnapshot();\n}\n\n\u002F\u002F Find memory leaks in tests\nlet beforeMemory: number;\n\nbeforeEach(() => {\n    beforeMemory = process.memoryUsage().heapUsed;\n});\n\nafterEach(() => {\n    const afterMemory = process.memoryUsage().heapUsed;\n    const diff = afterMemory - beforeMemory;\n\n    if (diff > 10 * 1024 * 1024) {  \u002F\u002F 10MB threshold\n        console.warn(`Possible memory leak: ${diff \u002F 1024 \u002F 1024}MB`);\n    }\n});\n```\n\n## Debugging Patterns by Issue Type\n\n### Pattern 1: Intermittent Bugs\n\n```markdown\n## Strategies for Flaky Bugs\n\n1. **Add extensive logging**\n   - Log timing information\n   - Log all state transitions\n   - Log external interactions\n\n2. **Look for race conditions**\n   - Concurrent access to shared state\n   - Async operations completing out of order\n   - Missing synchronization\n\n3. **Check timing dependencies**\n   - setTimeout\u002FsetInterval\n   - Promise resolution order\n   - Animation frame timing\n\n4. **Stress test**\n   - Run many times\n   - Vary timing\n   - Simulate load\n```\n\n### Pattern 2: Performance Issues\n\n```markdown\n\n## Reference Files\n\nFor detailed patterns and code examples, see [references\u002Ftools-and-profiling.md](references\u002Ftools-and-profiling.md).\n","# Debugging Strategies\n\n> **Origin:** Techniques refined through systematic debugging of concurrent test failures in a large TypeScript codebase (2025).\n\nTransform debugging from frustrating guesswork into systematic problem-solving with proven strategies, powerful tools, and methodical approaches.\n\n## When to Use This Skill\n\n- Tracking down elusive bugs\n- Investigating performance issues\n- Understanding unfamiliar codebases\n- Debugging production issues\n- Analyzing crash dumps and stack traces\n- Profiling application performance\n- Investigating memory leaks\n- Debugging distributed systems\n\n## Core Principles\n\n### 1. The Scientific Method\n\n**1. Observe**: What's the actual behavior?\n**2. Hypothesize**: What could be causing it?\n**3. Experiment**: Test your hypothesis\n**4. Analyze**: Did it prove\u002Fdisprove your theory?\n**5. Repeat**: Until you find the root cause\n\n### 2. Debugging Mindset\n\n**Don't Assume:**\n- \"It can't be X\" - Yes it can\n- \"I didn't change Y\" - Check anyway\n- \"It works on my machine\" - Find out why\n\n**Do:**\n- Reproduce consistently\n- Isolate the problem\n- Keep detailed notes\n- Question everything\n- Take breaks when stuck\n\n### 3. Rubber Duck Debugging\n\nExplain your code and problem out loud (to a rubber duck, colleague, or yourself). Often reveals the issue.\n\n## Systematic Debugging Process\n\n### Phase 1: Reproduce\n\n```markdown\n## Reproduction Checklist\n\n1. **Can you reproduce it?**\n   - Always? Sometimes? Randomly?\n   - Specific conditions needed?\n   - Can others reproduce it?\n\n2. **Create minimal reproduction**\n   - Simplify to smallest example\n   - Remove unrelated code\n   - Isolate the problem\n\n3. **Document steps**\n   - Write down exact steps\n   - Note environment details\n   - Capture error messages\n```\n\n### Phase 2: Gather Information\n\n```markdown\n## Information Collection\n\n1. **Error Messages**\n   - Full stack trace\n   - Error codes\n   - Console\u002Flog output\n\n2. **Environment**\n   - OS version\n   - Language\u002Fruntime version\n   - Dependencies versions\n   - Environment variables\n\n3. **Recent Changes**\n   - Git history\n   - Deployment timeline\n   - Configuration changes\n\n4. **Scope**\n   - Affects all users or specific ones?\n   - All browsers or specific ones?\n   - Production only or also dev?\n```\n\n### Phase 3: Form Hypothesis\n\n```markdown\n## Hypothesis Formation\n\nBased on gathered info, ask:\n\n1. **What changed?**\n   - Recent code changes\n   - Dependency updates\n   - Infrastructure changes\n\n2. **What's different?**\n   - Working vs broken environment\n   - Working vs broken user\n   - Before vs after\n\n3. **Where could this fail?**\n   - Input validation\n   - Business logic\n   - Data layer\n   - External services\n```\n\n### Phase 4: Test & Verify\n\n```markdown\n## Testing Strategies\n\n1. **Binary Search**\n   - Comment out half the code\n   - Narrow down problematic section\n   - Repeat until found\n\n2. **Add Logging**\n   - Strategic console.log\u002Fprint\n   - Track variable values\n   - Trace execution flow\n\n3. **Isolate Components**\n   - Test each piece separately\n   - Mock dependencies\n   - Remove complexity\n\n4. **Compare Working vs Broken**\n   - Diff configurations\n   - Diff environments\n   - Diff data\n```\n\n## Debugging Tools\n\n### JavaScript\u002FTypeScript Debugging\n\n```typescript\n\u002F\u002F Chrome DevTools Debugger\nfunction processOrder(order: Order) {\n    debugger;  \u002F\u002F Execution pauses here\n\n    const total = calculateTotal(order);\n    console.log('Total:', total);\n\n    \u002F\u002F Conditional breakpoint\n    if (order.items.length > 10) {\n        debugger;  \u002F\u002F Only breaks if condition true\n    }\n\n    return total;\n}\n\n\u002F\u002F Console debugging techniques\nconsole.log('Value:', value);                    \u002F\u002F Basic\nconsole.table(arrayOfObjects);                   \u002F\u002F Table format\nconsole.time('operation'); \u002F* code *\u002F console.timeEnd('operation');  \u002F\u002F Timing\nconsole.trace();                                 \u002F\u002F Stack trace\nconsole.assert(value > 0, 'Value must be positive');  \u002F\u002F Assertion\n\n\u002F\u002F Performance profiling\nperformance.mark('start-operation');\n\u002F\u002F ... operation code\nperformance.mark('end-operation');\nperformance.measure('operation', 'start-operation', 'end-operation');\nconsole.log(performance.getEntriesByType('measure'));\n```\n\n**VS Code Debugger Configuration:**\n```json\n\u002F\u002F .vscode\u002Flaunch.json\n{\n    \"version\": \"0.2.0\",\n    \"configurations\": [\n        {\n            \"type\": \"node\",\n            \"request\": \"launch\",\n            \"name\": \"Debug Program\",\n            \"program\": \"${workspaceFolder}\u002Fsrc\u002Findex.ts\",\n            \"preLaunchTask\": \"tsc: build - tsconfig.json\",\n            \"outFiles\": [\"${workspaceFolder}\u002Fdist\u002F**\u002F*.js\"],\n            \"skipFiles\": [\"\u003Cnode_internals>\u002F**\"]\n        },\n        {\n            \"type\": \"node\",\n            \"request\": \"launch\",\n            \"name\": \"Debug Tests\",\n            \"program\": \"${workspaceFolder}\u002Fnode_modules\u002Fjest\u002Fbin\u002Fjest\",\n            \"args\": [\"--runInBand\", \"--no-cache\"],\n            \"console\": \"integratedTerminal\"\n        }\n    ]\n}\n```\n\n### Python Debugging\n\n```python\n# Built-in debugger (pdb)\nimport pdb\n\ndef calculate_total(items):\n    total = 0\n    pdb.set_trace()  # Debugger starts here\n\n    for item in items:\n        total += item.price * item.quantity\n\n    return total\n\n# Breakpoint (Python 3.7+)\ndef process_order(order):\n    breakpoint()  # More convenient than pdb.set_trace()\n    # ... code\n\n# Post-mortem debugging\ntry:\n    risky_operation()\nexcept Exception:\n    import pdb\n    pdb.post_mortem()  # Debug at exception point\n\n# IPython debugging (ipdb)\nfrom ipdb import set_trace\nset_trace()  # Better interface than pdb\n\n# Logging for debugging\nimport logging\nlogging.basicConfig(level=logging.DEBUG)\nlogger = logging.getLogger(__name__)\n\ndef fetch_user(user_id):\n    logger.debug(f'Fetching user: {user_id}')\n    user = db.query(User).get(user_id)\n    logger.debug(f'Found user: {user}')\n    return user\n\n# Profile performance\nimport cProfile\nimport pstats\n\ncProfile.run('slow_function()', 'profile_stats')\nstats = pstats.Stats('profile_stats')\nstats.sort_stats('cumulative')\nstats.print_stats(10)  # Top 10 slowest\n```\n\n### Go Debugging\n\n```go\n\u002F\u002F Delve debugger\n\u002F\u002F Install: go install github.com\u002Fgo-delve\u002Fdelve\u002Fcmd\u002Fdlv@latest\n\u002F\u002F Run: dlv debug main.go\n\nimport (\n    \"fmt\"\n    \"runtime\"\n    \"runtime\u002Fdebug\"\n)\n\n\u002F\u002F Print stack trace\nfunc debugStack() {\n    debug.PrintStack()\n}\n\n\u002F\u002F Panic recovery with debugging\nfunc processRequest() {\n    defer func() {\n        if r := recover(); r != nil {\n            fmt.Println(\"Panic:\", r)\n            debug.PrintStack()\n        }\n    }()\n\n    \u002F\u002F ... code that might panic\n}\n\n\u002F\u002F Memory profiling\nimport _ \"net\u002Fhttp\u002Fpprof\"\n\u002F\u002F Visit http:\u002F\u002Flocalhost:6060\u002Fdebug\u002Fpprof\u002F\n\n\u002F\u002F CPU profiling\nimport (\n    \"os\"\n    \"runtime\u002Fpprof\"\n)\n\nf, _ := os.Create(\"cpu.prof\")\npprof.StartCPUProfile(f)\ndefer pprof.StopCPUProfile()\n\u002F\u002F ... code to profile\n```\n\n## Advanced Debugging Techniques\n\n### Technique 0: AST-Based Code Tracing\n\nWhen `sg` (ast-grep) is available, use structural search for precise code tracing:\n\n```bash\n# Trace all exception raise\u002Fcatch patterns\nsg run -p 'raise $EXCEPTION' -l python src\u002F\nsg run -p 'except $TYPE as $VAR:' -l python src\u002F\n\n# Find all assignments to a variable (track state mutations)\nsg run -p '$TARGET = $VALUE' -l python src\u002Fmodule\u002F\n\n# Map async call chains (find all await expressions)\nsg run -p 'await $EXPR' -l python src\u002F\n\n# Find all callers of a suspect function\nsg run -p 'suspect_function($$$ARGS)' -l python src\u002F\n\n# Find all error handler paths\nsg run -p 'except $TYPE:\n    $$$BODY' -l python src\u002F\n\n# Trace decorator usage (find wrapped functions)\nsg run -p '@$DECORATOR\ndef $NAME($$$):' -l python src\u002F\n```\n\n**When to prefer sg over Grep for debugging:**\n- Multiline patterns (function calls spanning lines)\n- Structural patterns (all try\u002Fexcept, all async\u002Fawait)\n- Precise matching (function calls vs string mentions)\n- If `sg` is unavailable, fall back to Grep + manual verification\n\n### Technique 1: Binary Search Debugging\n\n```bash\n# Git bisect for finding regression\ngit bisect start\ngit bisect bad                    # Current commit is bad\ngit bisect good v1.0.0            # v1.0.0 was good\n\n# Git checks out middle commit\n# Test it, then:\ngit bisect good   # if it works\ngit bisect bad    # if it's broken\n\n# Continue until bug found\ngit bisect reset  # when done\n```\n\n### Technique 2: Differential Debugging\n\nCompare working vs broken:\n\n```markdown\n## What's Different?\n\n| Aspect       | Working         | Broken          |\n|--------------|-----------------|-----------------|\n| Environment  | Development     | Production      |\n| Node version | 18.16.0         | 18.15.0         |\n| Data         | Empty DB        | 1M records      |\n| User         | Admin           | Regular user    |\n| Browser      | Chrome          | Safari          |\n| Time         | During day      | After midnight  |\n\nHypothesis: Time-based issue? Check timezone handling.\n```\n\n### Technique 3: Trace Debugging\n\n```typescript\n\u002F\u002F Function call tracing\nfunction trace(target: any, propertyKey: string, descriptor: PropertyDescriptor) {\n    const originalMethod = descriptor.value;\n\n    descriptor.value = function(...args: any[]) {\n        console.log(`Calling ${propertyKey} with args:`, args);\n        const result = originalMethod.apply(this, args);\n        console.log(`${propertyKey} returned:`, result);\n        return result;\n    };\n\n    return descriptor;\n}\n\nclass OrderService {\n    @trace\n    calculateTotal(items: Item[]): number {\n        return items.reduce((sum, item) => sum + item.price, 0);\n    }\n}\n```\n\n### Technique 4: Memory Leak Detection\n\n```typescript\n\u002F\u002F Chrome DevTools Memory Profiler\n\u002F\u002F 1. Take heap snapshot\n\u002F\u002F 2. Perform action\n\u002F\u002F 3. Take another snapshot\n\u002F\u002F 4. Compare snapshots\n\n\u002F\u002F Node.js memory debugging\nif (process.memoryUsage().heapUsed > 500 * 1024 * 1024) {\n    console.warn('High memory usage:', process.memoryUsage());\n\n    \u002F\u002F Generate heap dump\n    require('v8').writeHeapSnapshot();\n}\n\n\u002F\u002F Find memory leaks in tests\nlet beforeMemory: number;\n\nbeforeEach(() => {\n    beforeMemory = process.memoryUsage().heapUsed;\n});\n\nafterEach(() => {\n    const afterMemory = process.memoryUsage().heapUsed;\n    const diff = afterMemory - beforeMemory;\n\n    if (diff > 10 * 1024 * 1024) {  \u002F\u002F 10MB threshold\n        console.warn(`Possible memory leak: ${diff \u002F 1024 \u002F 1024}MB`);\n    }\n});\n```\n\n## Debugging Patterns by Issue Type\n\n### Pattern 1: Intermittent Bugs\n\n```markdown\n## Strategies for Flaky Bugs\n\n1. **Add extensive logging**\n   - Log timing information\n   - Log all state transitions\n   - Log external interactions\n\n2. **Look for race conditions**\n   - Concurrent access to shared state\n   - Async operations completing out of order\n   - Missing synchronization\n\n3. **Check timing dependencies**\n   - setTimeout\u002FsetInterval\n   - Promise resolution order\n   - Animation frame timing\n\n4. **Stress test**\n   - Run many times\n   - Vary timing\n   - Simulate load\n```\n\n### Pattern 2: Performance Issues\n\n```markdown\n\n## Reference Files\n\nFor detailed patterns and code examples, see [references\u002Ftools-and-profiling.md](references\u002Ftools-and-profiling.md).\n",{"name":5,"description":7},"main","cd9a2962c9a7e0797fe440f7b1ba4ceccc16ae0d","claude-code\u002Fskills\u002Fdebugging-strategies",1,"https:\u002F\u002Fgithub.com\u002Fsnewhouse\u002Faa-ma-forge","https:\u002F\u002Fgithub.com\u002Fsnewhouse","Data Scientist, Bioinformatician, Dad, Husband, MS warrior","2026-11-11 21:34:39",{"source":8,"skillName":5,"commands":53,"prompt":63,"zipAvailable":64},[54,57,60],{"tool":55,"command":56},"npx","npx skills add snewhouse\u002Faa-ma-forge --skill debugging-strategies",{"tool":58,"command":59},"bunx","bunx skills add snewhouse\u002Faa-ma-forge --skill debugging-strategies",{"tool":61,"command":62},"pnpm","pnpm dlx skills add snewhouse\u002Faa-ma-forge --skill debugging-strategies","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fsnewhouse\u002Faa-ma-forge\u002Fblob\u002Fmain\u002Fclaude-code\u002Fskills\u002Fdebugging-strategies\u002FSKILL.md",true,[66],{"path":67,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":70,"sourceHtmlUrl":71},"references\u002Ftools-and-profiling.md","REFERENCE","参考文档",2532,"https:\u002F\u002Fgithub.com\u002Fsnewhouse\u002Faa-ma-forge\u002Fblob\u002Fmain\u002Fclaude-code\u002Fskills\u002Fdebugging-strategies\u002Freferences\u002Ftools-and-profiling.md",[73,97,125,146,171,200],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":84,"publishedAt":39},"01M6MZ588SD5DDH59H18PRNWEV","deploy-helper","You can use this to help with deploy stuff, deploying, deployments, releases, shipping, pushing to prod, going live, rollouts.","https:\u002F\u002Fgithub.com\u002Fsnewhouse\u002Faa-ma-forge\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fevals\u002Fskill-draft\u002Fdraft\u002FSKILL.md",[79],{"categoryNo":80,"categoryName":81,"taxonomyType":82,"taxonomyTypeDesc":83},"01JBSEEDCAT000000000000011","运维与部署","SCENARIO","使用场景",[85,86,87,88,89,90,91,92,93,22,94,95,96],"deploy","deploy helper","helper","you","live","with","can","rollouts","shipping","deployments","releases","help",{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":101,"licenseFileUrl":102,"sourceHtmlUrl":103,"categories":104,"keywords":116,"publishedAt":39},"01M6MZ54NEKRYXGMJ1KJWYMKM7","writing-for-agents","Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.","MIT","https:\u002F\u002Fgithub.com\u002Fsnewhouse\u002Faa-ma-forge\u002Fblob\u002Fmain\u002Fclaude-code\u002Fskills\u002Fwriting-for-agents\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fsnewhouse\u002Faa-ma-forge\u002Fblob\u002Fmain\u002Fclaude-code\u002Fskills\u002Fwriting-for-agents\u002FSKILL.md",[105,108,111],{"categoryNo":106,"categoryName":107,"taxonomyType":82,"taxonomyTypeDesc":83},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":109,"categoryName":110,"taxonomyType":82,"taxonomyTypeDesc":83},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":112,"categoryName":113,"taxonomyType":114,"taxonomyTypeDesc":115},"01JBSEEDCAT000000000000036","内容创作者","PROFESSION","适用职业",[117,118,119,120,22,121,122,123,124],"writing","writing for agents","for","line","instructions","read","editing","documents",{"skillNo":126,"name":127,"nameZh":6,"description":128,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":129,"categories":130,"keywords":131,"publishedAt":39},"01M6MZ500T0FH1G8TBSQV7G5G2","verify-plan","Slash entry for plan verification: runs plan-verification on an existing AA-MA plan, writes [task]-verification.md, and with --iterate loops until the plan converges. Use when the user types \u002Fverify-plan or wants the verification report saved.","https:\u002F\u002Fgithub.com\u002Fsnewhouse\u002Faa-ma-forge\u002Fblob\u002Fmain\u002Fclaude-code\u002Fskills\u002Fverify-plan\u002FSKILL.md",[],[132,133,134,135,136,22,137,90,138,139,140,141,142,143,144,119,145],"verify","plan","verify plan","loops","task","user","verification","report","types","plan verification","entry","iterate","Existing","saved",{"skillNo":147,"name":148,"nameZh":6,"description":149,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":150,"categories":151,"keywords":152,"publishedAt":39},"01M6MZ4V9ST4K54NT1SRBGCE7P","verify-impl","Post-impl adversarial review symmetric to \u002Fverify-plan. Dispatches up to 5 parallel audit agents (code-reviewer, security-auditor, tdd-sequence-auditor, context7-evidence-auditor, future-proofing-auditor) based on the milestone's plan-declared Audit-Profile. CRITICAL findings surface via AskUserQuestion accept\u002Fdispute\u002Fdefer panel before §7.3 user authorization. Introduced in v0.8.0 per ADR-0005. Invoked by Phase 6.8 of \u002Fexecute-aa-ma-milestone.","https:\u002F\u002Fgithub.com\u002Fsnewhouse\u002Faa-ma-forge\u002Fblob\u002Fmain\u002Fclaude-code\u002Fskills\u002Fverify-impl\u002FSKILL.md",[],[153,154,132,155,156,157,158,159,160,161,162,163,164,165,166,133,167,168,169,170],"impl","verify impl","adversarial","post","panel","via","critical","review","context7","up","evidence","reviewer","parallel","adr","audit","code","tdd","milestone",{"skillNo":172,"name":173,"nameZh":6,"description":174,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":175,"categories":176,"keywords":181,"publishedAt":39},"01M6MZ4K7CC9PMJ1KEY3F53RS1","understand-codebase","Onboard to a new, inherited, or shared codebase. Read it, understand it, map it, and learn its conventions, versioning, tests, tech stack, rules (AGENTS.md \u002F CLAUDE.md \u002F .cursorrules \u002F etc.), build\u002Frun\u002FCI, integrations, security posture, and repo health — then produce an honest pros\u002Fcons verdict, a \"contribute safely\" playbook, and an \"add a feature\" playbook, written to ONBOARDING.md at the repo root plus a .claude\u002Fonboarding\u002F set of deep-dives — and optionally author an AGENTS.md if one is missing, or review and propose improvements to an existing one. Tiered (Quick \u002F Standard \u002F Deep). Reuses codemem (index + diagrams), gsd-map-codebase, system-mapping, code-intelligence, impact-analysis rather than re-implementing them; Deep tier runs a TeamCreate agent-team. Keywords: new codebase, shared codebase, inherited code, onboard, understand this repo, how do I contribute, how do I add a feature, ramp up, get oriented, ONBOARDING.md, AGENTS.md, codebase walkthrough, joining a project.","https:\u002F\u002Fgithub.com\u002Fsnewhouse\u002Faa-ma-forge\u002Fblob\u002Fmain\u002Fclaude-code\u002Fskills\u002Funderstand-codebase\u002FSKILL.md",[177,178],{"categoryNo":109,"categoryName":110,"taxonomyType":82,"taxonomyTypeDesc":83},{"categoryNo":179,"categoryName":180,"taxonomyType":114,"taxonomyTypeDesc":115},"01JBSEEDCAT000000000000038","人力资源",[182,183,184,162,185,35,186,187,188,189,190,191,192,193,194,195,196,197,198,199],"understand codebase","codebase","understand","walkthrough","SET","ci","learn","diagrams","repo health","implementing","re","quick","impact","get","project","deep","shared","map",{"skillNo":201,"name":202,"nameZh":6,"description":203,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":204,"categories":205,"keywords":206,"publishedAt":39},"01M6MZ4D1ZC8MTW064QXY6WC76","token-compression","Output token compression for AA-MA workflows. Reduces response tokens by 40-75% while preserving full technical accuracy. Three intensity levels mapped to execution modes: lite (HITL), full (general), ultra (AFK). Auto-activates during AA-MA execution based on task Mode field. Manual activation via \u002Fcompress lite|full|ultra.","https:\u002F\u002Fgithub.com\u002Fsnewhouse\u002Faa-ma-forge\u002Fblob\u002Fmain\u002Fclaude-code\u002Fskills\u002Ftoken-compression\u002FSKILL.md",[],[207,208,209,210,211,212,213,119,214,215,158,216,217,218,219,136,220,221,222,223],"compression","token compression","token","workflows","output","modes","accuracy","mode","manual","intensity","tokens","hitl","three","general","auto","technical","execution"]