home / skills / shotaiuchi / dotclaude / team-debug

team-debug skill

/dotclaude/skills/team-debug

This skill automatically forms and launches a debug team of investigators to analyze bugs via parallel hypothesis verification and consolidate root causes.

npx playbooks add skill shotaiuchi/dotclaude --skill team-debug

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
5.9 KB
---
name: team-debug
description: Agent Teamsでバグ原因の並列仮説検証チームを自動構成・起動
argument-hint: "[--issue N | --pr N | --commit REF | --diff | path | text]"
user-invocable: true
disable-model-invocation: true
---

# Debug Team

Create an Agent Team with automatically selected investigators to analyze and identify root causes of bugs through parallel hypothesis verification.

## Instructions

1. **Analyze the bug** (error message, stack trace, file, or issue) to understand the symptom
2. **Generate hypotheses** for multiple independent root causes
3. **Select appropriate investigators** based on the selection matrix below
4. **Create the agent team** with only the selected investigators
5. Have them share evidence and produce a consolidated root cause analysis

## Step 0: Scope Detection

Parse `$ARGUMENTS` to determine the analysis target.
See `references/agent-team/scope-detection.md` for full detection rules.

| Flag | Scope | Action |
|------|-------|--------|
| `--pr <N>` | PR | `gh pr diff <N>` + `gh pr view <N> --json title,body,files` |
| `--issue <N>` | Issue | `gh issue view <N> --json title,body,comments` |
| `--commit <ref>` | Commit | `git show <ref>` or `git diff <range>` |
| `--diff` | Unstaged changes | `git diff` |
| `--staged` | Staged changes | `git diff --staged` |
| `--branch <name>` | Branch diff | `git diff main...<name>` |
| Path pattern | File/Directory | `Glob` + `Read` |
| Free text | Description | Use as context for analysis |
| (empty or ambiguous) | Unknown | Ask user to specify target |

## Step 1: Bug Analysis

Before spawning any teammates, analyze the target to determine the bug type:

| Signal | Type |
|--------|------|
| `NullPointerException`, `TypeError`, wrong return values, incorrect conditions | Logic Bug |
| Inconsistent data, stale cache, corrupted state, unexpected side effects | State Bug |
| Intermittent failures, timing-dependent, thread/coroutine issues, deadlocks | Race Condition |
| `OutOfMemoryError`, leaks, high CPU, resource exhaustion, handle leaks | Memory/Resource |
| API failures, serialization errors, version mismatches, protocol errors | Integration |
| Works locally but fails in CI/prod, missing env vars, permission errors | Config/Env |
| Mixed signals | Analyze dominant patterns and apply multiple types |

## Step 2: Hypothesis Generation

Based on the bug analysis, generate 3-7 independent hypotheses for the root cause. Each hypothesis should be:

- Specific and testable
- Independent from other hypotheses (can be verified in parallel)
- Assigned to the most appropriate investigator

## Step 3: Investigator Selection Matrix

| Investigator | Logic Bug | State Bug | Race Condition | Memory/Resource | Integration | Config/Env |
|:-------------|:---------:|:---------:|:--------------:|:---------------:|:-----------:|:----------:|
| Stack Trace Analyzer | Always | Always | Always | Always | Always | Always |
| State Inspector | If stateful | Always | Always | If state-related | If stateful | Skip |
| Concurrency Investigator | Skip | If async | Always | If thread-related | If async | Skip |
| Data Flow Tracer | Always | Always | If data-dependent | Skip | Always | Skip |
| Environment Checker | Skip | Skip | Skip | Skip | If env-dependent | Always |
| Dependency Auditor | If version-related | Skip | Skip | If library-related | Always | Always |
| Reproduction Specialist | Always | Always | Always | Always | Always | Always |

### Selection Rules

- **Always**: Spawn this investigator unconditionally
- **Skip**: Do not spawn this investigator
- **Conditional**: Spawn only if the condition is met based on bug analysis

When uncertain, **include the investigator** (prefer thoroughness over efficiency).

## Step 4: Team Creation

Spawn only the selected investigators using the **Task tool** (`subagent_type: "general-purpose"`).

**Execution Rules:**
- Send ALL Task tool calls in a **single message** for parallel execution
- Each subagent runs in its own context and returns findings to the lead (main context)
- Provide each subagent with the full target context (error messages, stack traces, file contents, etc.) in the prompt
- The lead (main context) is responsible for synthesis — do NOT spawn a subagent for synthesis

1. **Stack Trace Analyzer**: Analyze error messages, stack traces, exception chains, and error propagation paths to pinpoint failure locations.

2. **State Inspector**: Examine application state, variable values, data structures, and state transitions to find unexpected state corruption.

3. **Concurrency Investigator**: Check for race conditions, deadlocks, thread safety issues, shared mutable state, and timing-dependent bugs.

4. **Data Flow Tracer**: Trace data from input to failure point, checking transformations, boundary conditions, type conversions, and null propagation.

5. **Environment Checker**: Verify configuration, environment variables, file permissions, network connectivity, and platform-specific behaviors.

6. **Dependency Auditor**: Check dependency versions, breaking changes, incompatibilities, known bugs in libraries, and transitive dependency conflicts.

7. **Reproduction Specialist**: Attempt to identify minimal reproduction steps, isolate the trigger conditions, and verify the bug is consistent.

## Workflow

1. Lead analyzes the bug symptoms and generates hypotheses
2. Each selected investigator pursues their hypothesis independently
3. Investigators share evidence and cross-validate findings
4. Lead synthesizes a root cause analysis with confidence levels:
   - High confidence: Strong evidence chain, reproducible
   - Medium confidence: Partial evidence, likely but not proven
   - Low confidence: Hypothesis consistent with symptoms but unverified

## Output

The lead produces a final root cause analysis report including:
- Bug type detected and investigators selected (with reasoning)
- Root cause with confidence level and evidence chain
- Alternative hypotheses considered and their status
- Recommended fix approach with implementation guidance

Overview

This skill automatically composes and launches a parallel investigator team to find root causes of bugs using Agent Teams. It analyzes the target (PR, issue, commit, diff, or free-text), generates independent hypotheses, selects investigators via a selection matrix, and runs them in parallel. The lead agent synthesizes findings into a consolidated root-cause report with confidence levels and remediation guidance.

How this skill works

The skill parses CLI arguments to detect the analysis scope, then inspects error messages, stack traces, files, and context to classify the bug type. It generates 3–7 testable hypotheses, chooses investigators per the matrix (Always/Conditional/Skip), and spawns only the selected subagents in a single parallel Task call. Each investigator returns evidence; the lead synthesizes results, assigns confidence, and recommends fixes.

When to use it

  • A CI failure or flaky test with stack traces or logs
  • A new bug report (issue or PR) requiring root-cause isolation
  • When multiple independent causes are plausible and parallel testing saves time
  • To verify and cross-check hypotheses quickly before coding a fix
  • When you need a structured, evidence-driven RCA with confidence levels

Best practices

  • Provide full context: error messages, stack traces, changed files, and relevant env details
  • Run scope detection flags (--pr, --issue, --commit, --diff, --staged, --branch) to target analysis precisely
  • Generate clear, independent, testable hypotheses so investigators run in parallel without overlap
  • Favor thoroughness when uncertain: include conditional investigators rather than skipping them
  • Return investigator outputs and artifacts to the lead for a single synthesized report

Example use cases

  • Investigate a failing GitHub Actions job by passing --pr <N> to analyze PR diffs and logs
  • Diagnose a production NullPointerException from a recent deploy by supplying commit ref and stack trace
  • Analyze intermittent timeouts or deadlocks with a focus on concurrency and state inspectors
  • Audit integration failures with dependency and environment checks for version or config mismatches
  • Quickly triage a developer-reported logic bug by spawning stack-trace, data-flow, and reproduction specialists

FAQ

What input formats are supported for scope detection?

Supports PRs, issues, commits, diffs (staged/unstaged), branch diffs, file paths, and free-text descriptions. Use the corresponding flags for best results.

How are investigators selected?

Selection follows a matrix: some investigators are spawned unconditionally, some are skipped, and others are conditional based on detected bug type. When unsure, include the investigator.

How does parallel execution work?

All Task tool calls for subagents are sent in a single message so investigators run in parallel. Each subagent receives the full target context and returns findings to the lead for synthesis.