investigate
Systematically investigate bugs, test failures, build errors, performance issues, or unexpected behavior by cycling through characterize-isolate-hypothesize-test steps. Use when the user asks to "investigate this bug", "debug this", "figure out why this fails", "find the root cau
Install
npx skills add https://github.com/tobihagemann/turbo/tree/main/codex/skills/investigate
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install tobihagemann-turbo@llmmart
git clone https://github.com/tobihagemann/turbo.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole tobihagemann/turbo collection as a plugin from our marketplace. Git is the plain clone.
Skill manifest
Investigate
Systematic methodology for finding the root cause of bugs, failures, and unexpected behavior. Cycle through characterize-isolate-hypothesize-test steps, with oracle escalation for hard problems. Diagnose the root cause — do not apply fixes.
Optional: $ARGUMENTS contains the problem description or error message.
Step 1: Characterize
Gather the symptom and establish what is actually happening:
- Collect evidence — error message, stack trace, test output, log entries, or user description of unexpected behavior
- Classify the problem type:
| Signal | Type |
|---|---|
| Stack trace / exception | Runtime error |
| Test assertion failure | Test failure |
| Compilation / bundler / build error | Build failure |
| Type checker error (tsc, mypy, pyright) | Type error |
| Slow response / high CPU / memory growth | Performance |
| "It does X instead of Y" / no error | Unexpected behavior |
- Establish reproduction — run the failing command, test, or operation. If the problem cannot be reproduced (intermittent, environment-specific), document the constraints and proceed with historical evidence.
Record the exact reproduction command and its output for verification. For intermittent or long-running reproductions, tail logs in a background shell, filtered for relevant signals (errors, stack traces, specific identifiers) so failures surface live while you work.
Step 2: Isolate
Narrow from "something is wrong" to "the problem is in this area." Read references/problem-type-playbooks.md for type-specific first moves and tool sequences.
Git Archeology
For all problem types, check what changed recently near the failure point:
git log --oneline -20 -- <file>
git blame -L <start>,<end> <file>
If a known-good state exists (e.g., "this worked yesterday"), consider git bisect to pinpoint the breaking commit.
Upstream Issue Search
When the failure surfaces inside a third-party dependency, search its issue tracker for a distinctive string from the error before reading deeper into the dependency's code. An issue whose symptom matches often names the cause and the fix outright. Carry a match forward as a ranked hypothesis and test it.
Scope Narrowing
- Stack traces: Read the throwing function and its callers — full functions, not just the flagged line
- Test failures: Read both the test and the system under test
- Build errors: Read the config file and the referenced source
- Unexpected behavior: Trace the data flow from input to the unexpected output
Before treating a record, file, or build artifact as evidence of the system's behavior, confirm the system under test produced it: check creator, source metadata, or generation time. Suspect imported, seeded, hand-edited, and leftover data from an earlier run, which reads identically to generated output. A checkout of another repository is the same trap: confirm it is current before reading it as evidence, since a stale one reads identically to the authoritative source.
Step 3: Hypothesize
Before forming a hypothesis about the machinery around a failure, such as a toolchain version, a configuration policy, or an environment difference, read the failing line, identify every path, package, symbol, or resource it names, and confirm each one resolves. Error text often names the site that consumed a missing input rather than the input itself, so the surrounding machinery looks responsible when it is not. Rank a machinery hypothesis only after every named reference checks out.
Once every named reference resolves and the operation has never once succeeded, rank a refusal ahead of any race or resource-exhaustion hypothesis: a denied permission, a firewall rule, an allowlist, an expired or missing credential. Intermittent failure is what a race or a contended resource usually looks like, so a run of attempts with zero successes ranks both below a refusal. Carry the hard blocks on the failing path into Step 4 as the first hypotheses to test, ahead of any measurement or instrumentation.
Generate 2-4 hypotheses ranked by likelihood. Each hypothesis must be falsifiable — specify what evidence would confirm or refute it.
Format:
H1 (most likely): [description] — confirmed if [X], refuted if [Y]
H2: [description] — confirmed if [X], refuted if [Y]
H3: [description] — confirmed if [X], refuted if [Y]
Check that the observed case can discriminate: when confirming and refuting evidence would look identical in it, the case is degenerate and any verdict drawn from it is inconclusive. Degenerate cases hide the difference they are supposed to reveal, such as a scaling factor of 1, a single-element collection, or an identity transform. Find a non-degenerate case, or construct one as a Step 4 experiment.
Parallel Investigation
For complex problems with 3+ hypotheses and a non-obvious root cause, spawn parallel investigators simultaneously.
Spawn condition: 3+ hypotheses AND the problem is not a simple typo, missing import, or syntax error.
Skip when 1-2 hypotheses are obvious (e.g., stack trace points directly to the bug).
Before dispatching, read the project's test configuration and CI workflow to identify any test tier that resets a shared external resource between tests, such as a database, a fixed port, or a cache. Such tiers have no cross-process interlock, so branches running them concurrently wipe each other's state and return failures that look like real defects. Name any such tier to every branch as off-limits.
When the evidence lives in a repository other than this one, including a submodule or a vendored clone with its own remote, establish the authoritative ref before dispatching and bring it up to date, fetching it or reading it through the forge API. A local checkout may be behind its remote, and an investigation branch reading a stale one returns findings the current code has already resolved. Name that ref and how to read it in every branch prompt, including the text the Claude consultation branch forwards.
Launch all investigation branches with spawn_agent / wait_agent using inherited model defaults, issuing every call in one batch. Do not issue one and await its result before issuing the rest. Expect one branch per hypothesis plus one Claude consultation branch. Every branch prompt must direct it to treat the shared working tree and its git index as read-only and to gather evidence by reading and reasoning; experiments that mutate code wait for Step 4, where they run one at a time. HEAD stays where it is: read other refs with git show <ref>:<path> rather than git checkout or git switch.
- Hypothesis branch (one per hypothesis): Each receives the hypothesis, relevant file paths, what evidence to look for, and instructions to report confirmed / refuted / inconclusive with evidence. Budget: max 5 tool calls per branch.
- Claude consultation branch: Run the
$consult-claudeskill with a focused prompt describing the problem, reproduction, and files examined. The external perspective can dig into patterns the hypothesis-driven branches miss. Run the$evaluate-findingsskill on its output after the consultation returns.
After all investigators complete, merge results. Claude findings that overlap with a confirmed hypothesis reinforce confidence. Novel Claude findings become additional hypotheses to test in Step 4.
Step 4: Test
Verify each hypothesis with minimal, targeted actions:
| Action Type | Tool |
|---|---|
| Find usage or pattern | Grep |
| Read surrounding code | Read |
| Check recent changes | Bash (git log, git blame, git diff) |
| Run isolated test | Bash (specific test command) |
| Check dependency version | Bash (npm ls, pip3 show, etc.) |
| Inspect runtime state | Bash (add temporary logging, run, check output) |
| Vary one suspected variable | Bash (construct a throwaway fixture, run, compare) |
When read-only evidence cannot discriminate, construct minimal throwaway fixtures that vary one suspected variable at a time. Exercise the system's inputs, and leave the working tree and its git index unchanged. Label each fixture clearly, delete them once the experiment concludes, and report anything that could not be deleted. When a check edits a tracked file instead, such as adding temporary logging, remove the edit once the check concludes and confirm with git diff -- <file> that the file is back to its pre-check state before recording the result. Write to an external or live system only after explicit user approval via request_user_input, stating the target system, every record the write will touch including those reached through triggers, cascades, and hooks, and the cleanup plan. When request_user_input does not reach the user, write nothing and report the approval as unresolved.
Record each result:
| Hypothesis | Verdict | Evidence |
|---|---|---|
| H1 | confirmed / refuted / inconclusive | [what was found] |
| H2 | confirmed / refuted / inconclusive | [what was found] |
Iteration
If all hypotheses are refuted or inconclusive:
- Document what was learned — each refuted hypothesis eliminates a possibility and narrows the search
- Return to Step 2 with the new information to re-isolate
- Generate new hypotheses in Step 3 based on updated understanding
Cycle budget: maximum 2 full cycles (hypothesize → test → learn → repeat) before escalating.
Escalation
After 2 failed hypothesis cycles, offer escalation to $consult-oracle via request_user_input:
Investigation stalled after [N] hypothesis cycles.
Tested: [summary of hypotheses and evidence]
Remaining unknowns: [what is still unclear]
Escalate to Oracle? (consults external model with full context)
Proceed only if the user approves.
Investigation Report
Output results as text:
Investigation Report:
Problem: [one-line description]
Type: [runtime error | test failure | build failure | type error | performance | unexpected behavior]
Root cause: [confirmed cause, or "unresolved" with best hypothesis]
Evidence:
- [what confirmed the root cause]
Suggested fix: [description of what to change, or "needs further investigation"]
Reproduction command: [command to verify the fix once applied]
Hypotheses tested:
1. [hypothesis] — [confirmed/refuted/inconclusive] — [evidence]
2. [hypothesis] — [confirmed/refuted/inconclusive] — [evidence]
Escalation: [none | oracle]
Then call update_plan to mark this step completed and continue with the next step of the active workflow.
Rules
- If the problem turns out to be environmental (wrong language runtime version, a declared dependency not installed locally, OS-specific), report that clearly — it may not require a code fix. A dependency the project never declared is a manifest defect, so report that as a code fix instead.
- If the problem is in a dependency (not the project's code), document the dependency issue and suggest workaround options rather than patching the dependency.
Files (turbo)
-
references
-
problem-type-playbooks.md 3.5 KB
# Problem Type Playbooks Type-specific investigation strategies. Load the playbook matching the classified type from Phase 1. ## Runtime Error **First moves**: Read the full stack trace. Identify the throwing function and read it completely. Read the caller that passed the bad input. **Common root causes**: null/undefined access, missing error handling, race condition, stale state, incorrect type coercion, dependency version mismatch, missing environment variable. **Tool sequence**: Read (stack trace files, full functions) → Grep (error message across codebase — is it caught elsewhere?) → Bash (`git blame` on the throwing line) → Bash (reproduce with verbose logging or `DEBUG=*`) ## Test Failure **First moves**: Read the failing test assertion and the expected vs actual values. Read the function under test completely. Check if the test was recently modified or if the SUT was. **Common root causes**: Logic change without test update, test relying on execution order or timing, mock returning stale data, shared mutable state between tests, assertion on wrong field. **Tool sequence**: Bash (run single failing test in isolation) → Read (test file + SUT) → Bash (`git log -5 -- <test-file> <sut-file>`) → Grep (shared state or global setup referenced by the test) ## Build Failure **First moves**: Read the full build error output. Identify the file and line referenced. Check for recent config changes. **Common root causes**: Missing import/export, circular dependency, incompatible dependency version, config syntax error, missing build step, stale cache. **Tool sequence**: Read (referenced file at error line) → Bash (`git diff HEAD~3 -- <config-files>`) → Bash (clean build: `rm -rf dist node_modules/.cache && npm run build`) → Grep (the missing symbol or module name) ## Type Error **First moves**: Read the type error message carefully — it contains the expected and actual types. Read the function signature and the call site. **Common root causes**: Function signature changed without updating callers, generic type inference failure, missing type narrowing (null check), incompatible library type update, `any` masking a real type mismatch. **Tool sequence**: Read (error file at error line, plus the type definition) → Grep (the type name — find where it's defined and how it's used) → Bash (`git log -5 -- <type-definition-file>`) ## Performance **First moves**: Establish a baseline measurement (time, memory, CPU). Identify the hot path — what operation is slow? **Common root causes**: N+1 queries, missing index, unbounded loop, excessive re-rendering, large payload serialization, synchronous blocking on async path, memory leak from unclosed resources. **Tool sequence**: Bash (profile or time the operation) → Read (the hot path code) → Grep (database queries, API calls, or loops in the hot path) → Bash (add timing instrumentation around suspected sections, re-run) ## Unexpected Behavior **First moves**: Define the expected behavior precisely. Define what actually happens. Identify the code path that should produce the expected behavior and trace it. **Common root causes**: Wrong conditional logic (off-by-one, inverted check), stale cache or memoization, event handler on wrong element, config override silently changing behavior, feature flag in unexpected state. **Tool sequence**: Read (the code path from input to output) → Bash (add logging at decision points, reproduce) → Grep (the config key or feature flag name) → Bash (`git log --all -S '<suspicious-value>' -- <file>` to find when the behavior changed)
-
-
SKILL.md 11.4 KB
--- name: investigate description: "Systematically investigate bugs, test failures, build errors, performance issues, or unexpected behavior by cycling through characterize-isolate-hypothesize-test steps. Use when the user asks to \"investigate this bug\", \"debug this\", \"figure out why this fails\", \"find the root cause\", \"why is this broken\", \"troubleshoot this\", \"diagnose the issue\", \"what's causing this error\", \"look into this failure\", \"why is this test failing\", or \"track down this bug\"." --- # Investigate Systematic methodology for finding the root cause of bugs, failures, and unexpected behavior. Cycle through characterize-isolate-hypothesize-test steps, with oracle escalation for hard problems. Diagnose the root cause — do not apply fixes. Optional: `$ARGUMENTS` contains the problem description or error message. ## Step 1: Characterize Gather the symptom and establish what is actually happening: 1. **Collect evidence** — error message, stack trace, test output, log entries, or user description of unexpected behavior 2. **Classify the problem type**: | Signal | Type | |--------|------| | Stack trace / exception | Runtime error | | Test assertion failure | Test failure | | Compilation / bundler / build error | Build failure | | Type checker error (tsc, mypy, pyright) | Type error | | Slow response / high CPU / memory growth | Performance | | "It does X instead of Y" / no error | Unexpected behavior | 3. **Establish reproduction** — run the failing command, test, or operation. If the problem cannot be reproduced (intermittent, environment-specific), document the constraints and proceed with historical evidence. Record the exact reproduction command and its output for verification. For intermittent or long-running reproductions, tail logs in a background shell, filtered for relevant signals (errors, stack traces, specific identifiers) so failures surface live while you work. ## Step 2: Isolate Narrow from "something is wrong" to "the problem is in this area." Read [references/problem-type-playbooks.md](references/problem-type-playbooks.md) for type-specific first moves and tool sequences. ### Git Archeology For all problem types, check what changed recently near the failure point: ```bash git log --oneline -20 -- <file> git blame -L <start>,<end> <file> ``` If a known-good state exists (e.g., "this worked yesterday"), consider `git bisect` to pinpoint the breaking commit. ### Upstream Issue Search When the failure surfaces inside a third-party dependency, search its issue tracker for a distinctive string from the error before reading deeper into the dependency's code. An issue whose symptom matches often names the cause and the fix outright. Carry a match forward as a ranked hypothesis and test it. ### Scope Narrowing - **Stack traces**: Read the throwing function and its callers — full functions, not just the flagged line - **Test failures**: Read both the test and the system under test - **Build errors**: Read the config file and the referenced source - **Unexpected behavior**: Trace the data flow from input to the unexpected output Before treating a record, file, or build artifact as evidence of the system's behavior, confirm the system under test produced it: check creator, source metadata, or generation time. Suspect imported, seeded, hand-edited, and leftover data from an earlier run, which reads identically to generated output. A checkout of another repository is the same trap: confirm it is current before reading it as evidence, since a stale one reads identically to the authoritative source. ## Step 3: Hypothesize Before forming a hypothesis about the machinery around a failure, such as a toolchain version, a configuration policy, or an environment difference, read the failing line, identify every path, package, symbol, or resource it names, and confirm each one resolves. Error text often names the site that consumed a missing input rather than the input itself, so the surrounding machinery looks responsible when it is not. Rank a machinery hypothesis only after every named reference checks out. Once every named reference resolves and the operation has never once succeeded, rank a refusal ahead of any race or resource-exhaustion hypothesis: a denied permission, a firewall rule, an allowlist, an expired or missing credential. Intermittent failure is what a race or a contended resource usually looks like, so a run of attempts with zero successes ranks both below a refusal. Carry the hard blocks on the failing path into Step 4 as the first hypotheses to test, ahead of any measurement or instrumentation. Generate 2-4 hypotheses ranked by likelihood. Each hypothesis must be **falsifiable** — specify what evidence would confirm or refute it. Format: ``` H1 (most likely): [description] — confirmed if [X], refuted if [Y] H2: [description] — confirmed if [X], refuted if [Y] H3: [description] — confirmed if [X], refuted if [Y] ``` Check that the observed case can discriminate: when confirming and refuting evidence would look identical in it, the case is degenerate and any verdict drawn from it is inconclusive. Degenerate cases hide the difference they are supposed to reveal, such as a scaling factor of 1, a single-element collection, or an identity transform. Find a non-degenerate case, or construct one as a Step 4 experiment. ### Parallel Investigation For complex problems with 3+ hypotheses and a non-obvious root cause, spawn parallel investigators simultaneously. **Spawn condition**: 3+ hypotheses AND the problem is not a simple typo, missing import, or syntax error. **Skip** when 1-2 hypotheses are obvious (e.g., stack trace points directly to the bug). Before dispatching, read the project's test configuration and CI workflow to identify any test tier that resets a shared external resource between tests, such as a database, a fixed port, or a cache. Such tiers have no cross-process interlock, so branches running them concurrently wipe each other's state and return failures that look like real defects. Name any such tier to every branch as off-limits. When the evidence lives in a repository other than this one, including a submodule or a vendored clone with its own remote, establish the authoritative ref before dispatching and bring it up to date, fetching it or reading it through the forge API. A local checkout may be behind its remote, and an investigation branch reading a stale one returns findings the current code has already resolved. Name that ref and how to read it in every branch prompt, including the text the Claude consultation branch forwards. Launch all investigation branches with `spawn_agent` / `wait_agent` using inherited model defaults, issuing every call in one batch. Do not issue one and await its result before issuing the rest. Expect one branch per hypothesis plus one Claude consultation branch. Every branch prompt must direct it to treat the shared working tree and its git index as read-only and to gather evidence by reading and reasoning; experiments that mutate code wait for Step 4, where they run one at a time. HEAD stays where it is: read other refs with `git show <ref>:<path>` rather than `git checkout` or `git switch`. - **Hypothesis branch (one per hypothesis):** Each receives the hypothesis, relevant file paths, what evidence to look for, and instructions to report **confirmed** / **refuted** / **inconclusive** with evidence. Budget: max 5 tool calls per branch. - **Claude consultation branch:** Run the `$consult-claude` skill with a focused prompt describing the problem, reproduction, and files examined. The external perspective can dig into patterns the hypothesis-driven branches miss. Run the `$evaluate-findings` skill on its output after the consultation returns. After all investigators complete, merge results. Claude findings that overlap with a confirmed hypothesis reinforce confidence. Novel Claude findings become additional hypotheses to test in Step 4. ## Step 4: Test Verify each hypothesis with minimal, targeted actions: | Action Type | Tool | |-------------|------| | Find usage or pattern | Grep | | Read surrounding code | Read | | Check recent changes | Bash (`git log`, `git blame`, `git diff`) | | Run isolated test | Bash (specific test command) | | Check dependency version | Bash (`npm ls`, `pip3 show`, etc.) | | Inspect runtime state | Bash (add temporary logging, run, check output) | | Vary one suspected variable | Bash (construct a throwaway fixture, run, compare) | When read-only evidence cannot discriminate, construct minimal throwaway fixtures that vary one suspected variable at a time. Exercise the system's inputs, and leave the working tree and its git index unchanged. Label each fixture clearly, delete them once the experiment concludes, and report anything that could not be deleted. When a check edits a tracked file instead, such as adding temporary logging, remove the edit once the check concludes and confirm with `git diff -- <file>` that the file is back to its pre-check state before recording the result. Write to an external or live system only after explicit user approval via `request_user_input`, stating the target system, every record the write will touch including those reached through triggers, cascades, and hooks, and the cleanup plan. When `request_user_input` does not reach the user, write nothing and report the approval as unresolved. Record each result: | Hypothesis | Verdict | Evidence | |------------|---------|----------| | H1 | confirmed / refuted / inconclusive | [what was found] | | H2 | confirmed / refuted / inconclusive | [what was found] | ### Iteration If all hypotheses are refuted or inconclusive: 1. Document what was learned — each refuted hypothesis eliminates a possibility and narrows the search 2. Return to Step 2 with the new information to re-isolate 3. Generate new hypotheses in Step 3 based on updated understanding **Cycle budget**: maximum 2 full cycles (hypothesize → test → learn → repeat) before escalating. ## Escalation After 2 failed hypothesis cycles, offer escalation to `$consult-oracle` via `request_user_input`: ``` Investigation stalled after [N] hypothesis cycles. Tested: [summary of hypotheses and evidence] Remaining unknowns: [what is still unclear] Escalate to Oracle? (consults external model with full context) ``` Proceed only if the user approves. ## Investigation Report Output results as text: ``` Investigation Report: Problem: [one-line description] Type: [runtime error | test failure | build failure | type error | performance | unexpected behavior] Root cause: [confirmed cause, or "unresolved" with best hypothesis] Evidence: - [what confirmed the root cause] Suggested fix: [description of what to change, or "needs further investigation"] Reproduction command: [command to verify the fix once applied] Hypotheses tested: 1. [hypothesis] — [confirmed/refuted/inconclusive] — [evidence] 2. [hypothesis] — [confirmed/refuted/inconclusive] — [evidence] Escalation: [none | oracle] ``` Then call `update_plan` to mark this step completed and continue with the next step of the active workflow. ## Rules - If the problem turns out to be environmental (wrong language runtime version, a declared dependency not installed locally, OS-specific), report that clearly — it may not require a code fix. A dependency the project never declared is a manifest defect, so report that as a code fix instead. - If the problem is in a dependency (not the project's code), document the dependency issue and suggest workaround options rather than patching the dependency.
Comments (0)
Sign in to join the conversation.
Reviews (0)
No reviews yet.
No comments yet.