agentleFS
giulio-leonegiulio-leone/vscode-agent-skills/skills/advanced-debugging/SKILL.md

advanced-debugging

Skill1 starsChanged 11 months agoMITView on GitHub

State-of-the-art debugging agent with hypothesis-driven analysis, automatic code instrumentation, git worktree isolation, and browser automation. Use when debugging errors, stack traces, unexpected behavior, performance issues, failed tests, race conditions, or hard-to-reproduce bugs.

  • Deletes or force-pushes

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Regression Test: Ensure no side effects

    line 109
  2. Distinctive:

    When resolving a bug, ALWAYS provide:

    line 152
  3. Distinctive:

    If after systematic analysis no solution is found:

    line 175

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

🔍 Advanced Debugging System

A systematic, hypothesis-driven debugging approach with automatic instrumentation and isolated testing capabilities.

Quick Reference

TaskCommand
Instrument fileRun scripts/instrument.ts <file>
Analyze logsRun scripts/analyze-logs.ts <logfile>
Create worktreeRun scripts/worktree.ts create <name>
Cleanup worktreeRun scripts/worktree.ts cleanup <name>
Generate hypothesis reportFollow "Hypothesis Generation" section

Core Methodology

Phase 0: Hypothesis Generation (MANDATORY FIRST STEP)

NEVER attempt fixes before generating at least 3 hypotheses.

## 🔮 Bug Hypotheses

### Hypothesis 1: [Name] - Probability: [High/Medium/Low]
- **Suspected Cause**: [specific description]
- **Evidence Needed**: [what logs/tests to add]
- **Verification Method**: [how to confirm]

### Hypothesis 2: [Name] - Probability: [High/Medium/Low]
- **Suspected Cause**: [specific description]
- **Evidence Needed**: [what logs/tests to add]
- **Verification Method**: [how to confirm]

### Hypothesis 3: [Name] - Probability: [High/Medium/Low]
- **Suspected Cause**: [specific description]
- **Evidence Needed**: [what logs/tests to add]
- **Verification Method**: [how to confirm]

Phase 1: Information Gathering

  1. Read the full error - Extract error type, message, stack trace
  2. Identify error category:
    • TYPE_ERROR - TypeScript/type issues
    • RUNTIME_ERROR - Execution failures
    • NETWORK_ERROR - API/fetch issues
    • DATABASE_ERROR - Prisma/SQL issues
    • BUILD_ERROR - Compilation/bundle issues
    • STATE_ERROR - React state/hydration issues

Phase 2: Stack Trace Analysis

Error Analysis Template:
┌─────────────────────────────────────────────┐
│ ERROR: [error message]                       │
├─────────────────────────────────────────────┤
│ Type: [error type]                          │
│ First Project File: [file:line]             │
│ Call Chain: fn1 → fn2 → fn3                 │
│ Suspected Origin: [description]             │
└─────────────────────────────────────────────┘

Phase 3: Automatic Instrumentation

See INSTRUMENTATION.md for detailed patterns.

Quick instrumentation markers:

// 🔍 DEBUG markers for easy identification and cleanup
console.log('🔍 DEBUG [LOCATION]:', { timestamp: new Date().toISOString(), /* context */ });

Cleanup pattern:

grep -rn "🔍 DEBUG" --include="*.ts" --include="*.tsx" src/

Phase 4: Isolated Testing with Git Worktrees

For complex bugs, test hypotheses in parallel:

# Create isolated environment
git worktree add ../debug-hypothesis-1 -b debug/h1-[description]

# After finding solution
git worktree remove ../debug-hypothesis-1
git branch -D debug/h1-[description]

See WORKTREES.md for multi-hypothesis workflows.

Phase 5: Fix-Verify-Document Cycle

  1. Minimal Fix: Change only what's necessary
  2. Verify: Reproduce original scenario
  3. Regression Test: Ensure no side effects
  4. Document: Comment non-obvious fixes

Error Pattern Quick Reference

See references/ERROR_PATTERNS.md for comprehensive patterns.

Common Next.js Patterns

ErrorLikely CauseQuick Fix
Hydration mismatchServer/client content differsAdd suppressHydrationWarning or fix data
Cannot read property of undefinedMissing null checkAdd optional chaining ?.
Module not foundImport path issueCheck tsconfig paths
NEXT_REDIRECTRedirect in wrong contextUse redirect() only in Server Components

Common Prisma Patterns

ErrorLikely CauseQuick Fix
P2002Unique constraint violationCheck existing data
P2025Record not foundVerify ID exists
Connection refusedDB not runningCheck DATABASE_URL

Feedback Loop Integration

For UI bugs, use browser automation:

// Playwright verification loop
{
  action: 'navigate', url: 'http://localhost:3000/[page]'
}
{
  action: 'console_messages', errorsOnly: true
}
{
  action: 'screenshot', fullPage: true
}

Output Template

When resolving a bug, ALWAYS provide:

## 🐛 Debug Report

### 🔴 Problem Identified
[Clear description of the bug]

### 🔍 Root Cause
[Main cause with evidence]

### ✅ Solution Applied
[Fix with explanation]

### 🧪 Verification
[How to confirm fix works]

### 🛡️ Prevention
[How to avoid in future]

Escalation Criteria

If after systematic analysis no solution is found:

  1. Summarize attempts made
  2. List remaining hypotheses
  3. Suggest next investigative steps
  4. Request additional context

Safety Constraints

  • ❌ NO production data modification without confirmation
  • ❌ NO destructive commands (rm -rf, DROP DATABASE) without confirmation
  • ❌ NO ignoring warnings that indicate future problems
  • ✅ ALWAYS ask confirmation for invasive fixes

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.