Skills for Claude Code CLI such as full stack dev Cloudflare, React, Tailwind v4, and AI integrations.
Python aianthropicautomationclaude-codeclaude-skillscloudflaredevtoolsproductivityreactskillstailwindvite
feat(skills): Add deep-debug multi-agent investigation pattern
Jez24022c26e3fb
diff --git a/skills/deep-debug/README.md b/skills/deep-debug/README.mdnew file mode 100644index 00000000..5a50ea7b--- /dev/null+++ b/skills/deep-debug/README.md@@ -0,0 +1,33 @@+# Deep Debug Skill++Multi-agent investigation pattern for stubborn bugs that resist normal debugging.++## Origin++This skill emerged from a real debugging session where:+- We went in circles for ~30 minutes guessing at causes (caching? stream parsing?)+- User showed Network tab screenshot revealing **2 fetch requests** (the actual evidence)+- Launched 3 parallel agents that found the root cause in ~5 minutes+- Fix was a React useCallback dependency issue++## Key Insight++**Evidence before hypotheses.** The Network tab screenshot broke the loop. We should have gathered that evidence earlier using Chrome MCP tools.++## When to Invoke++- "I'm stuck on this bug"+- "We've tried multiple things and nothing works"+- "This is going in circles"+- "Can you do a deep investigation?"+- `/deep-debug`++## Requirements++- Chrome MCP tools (for browser bugs) - `mcp__claude-in-chrome__*`+- Access to spawn sub-agents: `debugger`, `code-reviewer`, `Explore`++## See Also++- Built-in `debugger` agent - Single-agent debugging+- `skills/agent-development/SKILL.md` - Agent patterns and when to delegatediff --git a/skills/deep-debug/SKILL.md b/skills/deep-debug/SKILL.mdnew file mode 100644index 00000000..1d0f2382--- /dev/null+++ b/skills/deep-debug/SKILL.md@@ -0,0 +1,194 @@+---+name: deep-debug+description: |+ Multi-agent investigation for stubborn bugs. Use when: going in circles debugging, need to investigate browser/API interactions, complex bugs resisting normal debugging, or when symptoms don't match expectations. Launches parallel agents with different perspectives and uses Chrome tools for evidence gathering.+user-invocable: true+---++# Deep Debug - Multi-Agent Investigation++**Status**: Production Ready+**Last Updated**: 2026-02-02+**Dependencies**: Chrome MCP tools (optional), debugger agent, code-reviewer agent++---++## When to Use++- **Going in circles** - You've tried multiple fixes but nothing works+- **Browser + API interaction bugs** - Need to see Network tab, console logs+- **Symptoms don't match expectations** - Something deeper is wrong+- **Complex state management bugs** - React hooks, closures, race conditions++## Quick Start++```+/deep-debug [description of the bug]+```++Or invoke naturally:+- "I'm stuck on this bug, can you do a deep investigation?"+- "This bug is resisting normal debugging"+- "I need you to really dig into this"++---++## The Process++### Phase 1: Gather Evidence (Before Hypothesizing)++**For browser-related bugs**, use Chrome MCP tools:++```typescript+// Get network requests (look for duplicates, failures, timing)+mcp__claude-in-chrome__read_network_requests++// Get console logs (errors, warnings, debug output)+mcp__claude-in-chrome__read_console_messages++// Get page state+mcp__claude-in-chrome__read_page+```++**For backend bugs**, gather:+- Error logs and stack traces+- Request/response payloads+- Database query logs+- Timing information++### Phase 2: Launch Parallel Investigation (3 Agents)++Launch these agents simultaneously with the gathered evidence:++#### Agent 1: Execution Tracer (debugger)+```+Task(subagent_type="debugger", prompt="""+EVIDENCE: [paste network/console evidence]++Trace the execution path that leads to this bug. Find:+1. Where the bug originates+2. What triggers it+3. The exact line/function causing the issue++Focus on TRACING, not guessing.+""")+```++#### Agent 2: Pattern Analyzer (code-reviewer)+```+Task(subagent_type="code-reviewer", prompt="""+EVIDENCE: [paste evidence]++Review the relevant code for common bug patterns:+- React useCallback/useMemo dependency issues+- Stale closures+- Race conditions+- State update ordering+- Missing error handling++Find patterns that EXPLAIN the evidence.+""")+```++#### Agent 3: Entry Point Mapper (Explore)+```+Task(subagent_type="Explore", prompt="""+EVIDENCE: [paste evidence]++Map all entry points that could trigger this behavior:+- All places [function] is called+- All event handlers involved+- All state updates that affect this++Find if something is being called MULTIPLE TIMES or from UNEXPECTED places.+""")+```++### Phase 3: Cross-Reference Findings++After agents complete, look for:++| Signal | Meaning |+|--------|---------|+| All 3 agree on root cause | High confidence - fix it |+| 2 agree, 1 different | Investigate the difference |+| All 3 different | Need more evidence |++### Phase 4: Verify Fix++After implementing the fix, re-gather the same evidence to confirm:+- Network tab shows expected behavior+- Console has no errors+- State updates correctly++---++## Real Example: Duplicate API Calls Bug++### Evidence Gathered+Network tab showed **2 fetch requests** for the same message.++### Parallel Investigation Results++| Agent | Finding |+|-------|---------|+| debugger | `state.messages` in useCallback deps causes callback recreation |+| code-reviewer | Same finding + explained React pattern causing it |+| Explore | Verified UI layer wasn't double-calling (ruled out) |++### Root Cause (Consensus)+`sendMessage` useCallback had `state.messages` in dependency array. Every state update recreated the callback, causing duplicate calls during React re-renders.++### Fix+Use `stateRef` to access current state without including in dependencies:+```typescript+const stateRef = useRef(state);+stateRef.current = state;++const sendMessage = useCallback(async (text) => {+ // Use stateRef.current instead of state+ const messages = stateRef.current.messages;+ // ...+}, [/* state.messages removed */]);+```++---++## Common Bug Patterns This Catches++### React Hook Issues+- `state` in useCallback dependencies causing recreation+- Missing dependencies causing stale closures+- useEffect running multiple times++### API/Network Issues+- Duplicate requests (visible in Network tab)+- Race conditions between requests+- CORS failures+- Timeout handling++### State Management Issues+- State updates not batching correctly+- Optimistic updates conflicting with server response+- Multiple sources of truth++---++## Chrome Tools Quick Reference++| Tool | Use For |+|------|---------|+| `read_network_requests` | See all fetch/XHR calls, duplicates, failures |+| `read_console_messages` | Errors, warnings, debug logs |+| `read_page` | Current DOM state |+| `javascript_tool` | Execute debug code in page context |++---++## Tips for Success++1. **Evidence first, hypotheses second** - Don't guess until you have concrete data+2. **Network tab is gold** - Most frontend bugs show symptoms there+3. **Parallel agents save time** - 3 perspectives at once vs sequential guessing+4. **Cross-reference findings** - Agreement = confidence+5. **Verify with same evidence** - Confirm fix with same tools that found bugdiff --git a/skills/deep-debug/rules/chrome-evidence-tools.md b/skills/deep-debug/rules/chrome-evidence-tools.mdnew file mode 100644index 00000000..3f1e12bb--- /dev/null+++ b/skills/deep-debug/rules/chrome-evidence-tools.md@@ -0,0 +1,77 @@+# Chrome MCP Tools for Evidence Gathering++Use these tools to gather concrete evidence BEFORE forming hypotheses.++## Network Evidence++| Tool | Use For |+|------|---------|+| `mcp__claude-in-chrome__read_network_requests` | All fetch/XHR calls, timing, status codes |++**What to look for:**+- Same URL appearing multiple times → **Duplicate calls bug**+- Failed requests (4xx, 5xx status) → **API/CORS error**+- Unexpected request timing → **Race condition**+- Missing requests → **Call never made**+- Request payload wrong → **Data serialization bug**++**Example finding:**+```+Name: bigcolour (4.6 kB)+Name: bigcolour (3.9 kB) ← TWO requests = duplicate call bug!+```++## Console Evidence++| Tool | Use For |+|------|---------|+| `mcp__claude-in-chrome__read_console_messages` | Errors, warnings, debug output |++**Useful patterns:**+- `pattern: "error"` - Filter to errors only+- `pattern: "[L2Chat]"` - Filter to app-specific logs+- No pattern - Get everything++**What to look for:**+- Unhandled promise rejections+- React hook warnings+- CORS errors+- "X is undefined" errors++## Page State Evidence++| Tool | Use For |+|------|---------|+| `mcp__claude-in-chrome__read_page` | Current DOM structure |+| `mcp__claude-in-chrome__javascript_tool` | Execute debug code in page context |++**Useful debug snippets:**+```javascript+// Check React state (if using React DevTools)+$r.state++// Check localStorage+JSON.stringify(localStorage)++// Check if element exists+document.querySelectorAll('.some-class').length++// Check event listeners+getEventListeners(document.body)+```++## Evidence Gathering Sequence++1. **First**: `read_network_requests` - Shows API-level issues+2. **Second**: `read_console_messages` - Shows client-side errors+3. **If needed**: `javascript_tool` - Inspect runtime state++## When Evidence Is Sufficient++You have enough evidence when you can answer:+- What action triggers the bug?+- What network requests are made?+- Are there any errors in console?+- What's the timing sequence?++Then launch parallel agents with this evidence attached.diff --git a/skills/deep-debug/rules/evidence-first.md b/skills/deep-debug/rules/evidence-first.mdnew file mode 100644index 00000000..faf847ad--- /dev/null+++ b/skills/deep-debug/rules/evidence-first.md@@ -0,0 +1,47 @@+# Evidence-First Debugging++## The Anti-Pattern++Going in circles guessing: "Maybe it's caching?" → "Maybe stream parsing?" → "Maybe React re-renders?"++This wastes time because each guess requires:+1. Forming a hypothesis+2. Making a change+3. Testing+4. Finding it didn't work+5. Repeat++## The Pattern++1. **Gather concrete evidence** (Network tab, console logs, page state)+2. **Let evidence guide hypotheses** - the data tells you where to look+3. **Launch parallel agents with evidence attached** - test multiple hypotheses at once++## Corrections++| If doing this... | Do this instead... |+|------------------|-------------------|+| Guessing at causes without data | Use Chrome tools to gather evidence first |+| Trying fixes one at a time | Launch parallel agents to test multiple hypotheses |+| Looking at code without symptoms | Start from observable symptoms, trace backward |+| Assuming you know the cause | Let the Network tab / console prove it |++## Real Example++**Wrong approach** (what we did first):+- "Maybe it's caching" → Disabled caching → Still broken+- "Maybe stream parsing" → Fixed text-end handler → Still broken+- "Maybe React re-renders" → Added logging → Still broken++**Right approach** (what finally worked):+- Looked at Network tab → Saw TWO fetch requests+- That evidence pointed directly to duplicate API calls+- Parallel agents found: `state.messages` in useCallback deps+- Fixed in one attempt++## When to Invoke This Pattern++- You've tried 2+ fixes and nothing worked+- You're not sure what's causing the bug+- The symptom doesn't match your mental model+- You're debugging browser ↔ API interactionsdiff --git a/skills/deep-debug/rules/parallel-agents.md b/skills/deep-debug/rules/parallel-agents.mdnew file mode 100644index 00000000..1235ad40--- /dev/null+++ b/skills/deep-debug/rules/parallel-agents.md@@ -0,0 +1,79 @@+# Parallel Agent Coordination++Launch three agents simultaneously, each with a different investigative perspective.++## The Three Perspectives++| Agent | Role | What It Finds |+|-------|------|---------------|+| `debugger` | Execution Tracer | Where bug originates, what triggers it, call sequence |+| `code-reviewer` | Pattern Analyzer | Common anti-patterns, code smells, known bug patterns |+| `Explore` | Entry Point Mapper | All call sites, unexpected callers, duplicate triggers |++## Why Parallel?++- **Faster**: 3 hypotheses tested in the time of 1+- **Different perspectives**: One agent might miss what another catches+- **Cross-validation**: Agreement = confidence++## Prompt Requirements++Each agent prompt MUST include:++1. **The evidence** - Paste network/console output directly+2. **Specific focus** - What this agent should investigate+3. **Agreement request** - Ask if findings align with evidence++**Bad prompt:**+> "Debug this bug"++**Good prompt:**+> "EVIDENCE: Network tab shows 2 fetch requests for same URL.+> Trace the execution path from user click to API call.+> Find where/why the call is made twice."++## Launching Agents++Use a single message with multiple Task tool calls:++```+Task(subagent_type="debugger", prompt="EVIDENCE: [paste]...")+Task(subagent_type="code-reviewer", prompt="EVIDENCE: [paste]...")+Task(subagent_type="Explore", prompt="EVIDENCE: [paste]...")+```++## Cross-Reference Signals++| Finding Pattern | Confidence | Action |+|-----------------|------------|--------|+| All 3 agents agree on root cause | **High** | Implement fix |+| 2 agree, 1 finds something different | **Medium** | Investigate the difference |+| All 3 find different things | **Low** | Need more evidence |+| None find anything | **Blocked** | Wrong area - gather new evidence |++## Common Findings by Agent++### debugger typically finds:+- Exact line/function causing issue+- Trigger sequence (click → handler → API call → duplicate)+- Timing-related bugs++### code-reviewer typically finds:+- React useCallback/useMemo dependency issues+- Stale closure bugs+- Missing error handling+- Race conditions++### Explore typically finds:+- Function called from multiple places+- Missing guards/early returns+- Unexpected event handlers+- Duplicate registrations++## After Agents Complete++1. **Read all three findings**+2. **Identify consensus** - What do they agree on?+3. **Investigate disagreements** - Sometimes the outlier is right+4. **Implement fix** based on consensus+5. **Verify** using same evidence tools (Network tab should show fix worked)diff --git a/skills/deep-debug/templates/investigation-report.md b/skills/deep-debug/templates/investigation-report.mdnew file mode 100644index 00000000..1ebe33f5--- /dev/null+++ b/skills/deep-debug/templates/investigation-report.md@@ -0,0 +1,124 @@+# Bug Investigation Report++Use this template to document deep-debug investigations for future reference.++---++## Problem Summary++- **Symptom**: [What the bug looks like to users]+- **Impact**: [Who/what is affected, severity]+- **Frequency**: [Always, sometimes, specific conditions]+- **First noticed**: [When did this start?]++---++## Evidence Gathered++### Network Tab+```+[Paste relevant network requests]+[Note: duplicates, failures, timing issues]+```++### Console Logs+```+[Paste relevant errors/warnings]+```++### Page State+```+[Any relevant DOM or app state observations]+```++### Key Observation+> [The single most important piece of evidence that pointed to the root cause]++---++## Hypotheses Tested++Before parallel investigation, what was tried?++| Hypothesis | Test | Result |+|------------|------|--------|+| [e.g., Caching issue] | [Disabled cache] | [Still broken] |+| [e.g., Stream parsing] | [Fixed text-end] | [Still broken] |++---++## Parallel Investigation Results++| Agent | Finding | Confidence |+|-------|---------|------------|+| debugger | [What it found] | [High/Med/Low] |+| code-reviewer | [What it found] | [High/Med/Low] |+| Explore | [What it found] | [High/Med/Low] |++### Consensus+[What did multiple agents agree on?]++### Disagreements+[Any conflicting findings? How were they resolved?]++---++## Root Cause++**Technical explanation:**+[What was actually causing the bug]++**Why it wasn't obvious:**+[Why initial hypotheses missed this]++**Pattern to watch for:**+[How to recognize this bug pattern in the future]++---++## Fix Applied++**Files modified:**+- `path/to/file.ts` - [What changed]+- `path/to/other.ts` - [What changed]++**Code change:**+```diff+- [old code]++ [new code]+```++**Why this fixes it:**+[Explain the connection between fix and root cause]++---++## Verification++**Evidence after fix:**+- Network tab shows: [Expected behavior]+- Console shows: [No errors / expected logs]+- User experience: [Bug no longer occurs]++**Regression risk:**+[Any concerns about the fix causing other issues?]++---++## Lessons Learned++1. [What to do differently next time]+2. [Pattern to add to rules/knowledge base]+3. [Tools/techniques that helped]++---++## Time Spent++- Initial guessing: [X minutes]+- Evidence gathering: [X minutes]+- Parallel investigation: [X minutes]+- Fix implementation: [X minutes]+- **Total**: [X minutes]++*Note: Evidence-first approach typically saves 50%+ of debugging time.*diff --git a/skills/deep-debug/templates/parallel-agent-prompts.md b/skills/deep-debug/templates/parallel-agent-prompts.mdnew file mode 100644index 00000000..f4fa87b3--- /dev/null+++ b/skills/deep-debug/templates/parallel-agent-prompts.md@@ -0,0 +1,108 @@+# Parallel Agent Prompts++Ready-to-use prompts for the three investigation agents. Copy, paste evidence, and launch.++---++## Agent 1: Execution Tracer (debugger)++```+EVIDENCE:+[Paste network requests / console logs here]++BUG SYMPTOM:+[Describe what's happening]++---++Trace the execution path that leads to this bug:++1. Where does the bug originate? (file:line)+2. What triggers it? (user action, state change, timing)+3. What's the exact sequence of calls?+4. Where could the duplicate/error/issue be introduced?++Focus on TRACING the evidence backward to source code, not guessing.+Report your findings with file paths and line numbers.+```++---++## Agent 2: Pattern Analyzer (code-reviewer)++```+EVIDENCE:+[Paste evidence here]++FILES TO REVIEW:+[List the most relevant files]++---++Analyze these files for common bug patterns that would explain the evidence:++React/Hook Issues:+- useCallback/useMemo with wrong dependencies+- State variables in dependency arrays causing recreation+- Stale closures capturing old values+- useEffect running more times than expected++Async/Timing Issues:+- Race conditions between async operations+- Missing abort/cleanup on unmount+- State updates after unmount++State Management:+- Multiple sources of truth+- Optimistic updates conflicting with server response+- State update ordering problems++Find patterns that EXPLAIN the evidence. Don't just list potential issues - connect them to what we observed.+```++---++## Agent 3: Entry Point Mapper (Explore)++```+EVIDENCE:+[Paste evidence showing the problematic behavior]++FUNCTION/COMPONENT:+[Name the function or component involved]++---++Map all entry points that could trigger [function name]:++1. All places it's called from (grep for function name)+2. All event handlers that might trigger it+3. All useEffect hooks that reference it+4. All state updates that affect it++Looking for:+- Is it being called from multiple places?+- Are there duplicate event handlers?+- Is something triggering it unexpectedly?+- Are there missing guards that should prevent duplicate calls?++Report all call sites with file:line references.+```++---++## How to Use++1. **Gather evidence first** using Chrome tools+2. **Copy the relevant prompt** above+3. **Paste your evidence** into the EVIDENCE section+4. **Launch all three** in a single message:++```+Task(subagent_type="debugger", prompt="[prompt 1 with evidence]")+Task(subagent_type="code-reviewer", prompt="[prompt 2 with evidence]")+Task(subagent_type="Explore", prompt="[prompt 3 with evidence]")+```++5. **Wait for all to complete**+6. **Cross-reference findings** - look for consensus