investigate
Validate user claims against codebase and git history, trace to root cause, and propose a fix
- License 许可
- MIT
- 最近更新
- 2026-11-10
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- investigate
- type
- debugging
- version
- v0.3
- description
- Validate user claims against codebase and git history, trace to root cause, and propose a fix
- argument-hint
- <error, bug description, user observations, or issue URL> [--ui] [--data] [--plan]
02 资源文件 1
- 参考文档CHANGELOG.md582 B
03 SKILL.md 正文
Investigate
Given a bug report, error message, unexpected behavior, or user observations about what they think is wrong, validate claims against the codebase and git history, trace to root cause, and propose a fix.
Process
- Parse the input from
$ARGUMENTS:- Error message or stack trace → extract file paths, line numbers, error types
- Bug description → identify the expected vs. actual behavior
- User claims/observations → extract each specific claim to validate (e.g., "I think the auth middleware is stripping the header," "this worked before the last deploy," "the database query is returning stale data")
- Issue URL → fetch the issue details via
gh - Check for
--planflag → if present, force plan output mode (write fix steps totasks/todo.mdinstead of applying inline) - Check for
--uior--dataflag → if present, skip auto-detection and use that investigation strategy (see step 1b) - If no arguments provided, ask the user what to investigate.
1b. Select investigation strategy:
If --ui or --data flag is set, use that strategy directly. Otherwise, auto-detect from the input:
- UI strategy (
--ui): Use when the problem is visual — layout, spacing, animation, transitions, skeleton/loading states, theming, colors, popovers, positioning, truncation, responsive behavior, CSS.- Signal words: skeleton, animation, spacing, popover, transition, theme, truncated, glitch, dead space, detached, pop-in, flickering, layout, positioning, z-index, overflow.
- Data strategy (
--data): Use when the problem is wrong values, stale state, sync mismatches, timers, counters, missing data, or data pipeline issues.- Signal words: countdown, percentage, usage, sync, stale, timer, refresh, reset, missing data, wrong number, out of sync, not updating, mismatch.
- General strategy (default): Use for errors/crashes (stack traces, console errors, server errors), behavioral bugs (wrong flow, missing options, incorrect form behavior), and anything ambiguous.
If the input contains signals from multiple strategies (e.g., "the countdown shows wrong AND the animation glitches"), start with the data strategy — wrong data is more commonly the root cause that manifests as a visual symptom.
-
Gather context (varies by strategy):
All strategies:
- Read
CLAUDE.mdfor project conventions. - Check
git log --oneline -20for recent changes that may have introduced the issue. - If the user references specific files, commits, or timeframes, read those directly.
UI strategy — start from the component tree:
- Identify the component(s) rendering the affected area.
- Read the component file(s) and their styles (CSS modules, Tailwind classes, styled-components).
- Trace the render path: parent → child → conditional renders → animation/transition logic.
- Check for CSS specificity conflicts, z-index stacking, overflow rules, and layout model issues (flex/grid).
- If the component uses loading/skeleton states, trace the state transition that swaps skeleton → content.
Data strategy — start from the data pipeline:
- Identify the data source (API, store, local state, timer, computed value).
- Trace the data flow: source → transformations → state management → component prop.
- Check for stale caches, missing refresh triggers, incorrect timer intervals, timezone/epoch issues.
- Compare the expected value computation against the actual one — read the business logic, not just the display.
- If multiple components show the same data differently, find where they diverge in the pipeline.
General strategy — start from the symptom:
- If a stack trace is available, start from the crash site and read those files.
- If behavioral, identify the relevant feature area and read entry points.
- Read
-
Validate user claims (when the user provides observations or hypotheses):
- Extract each distinct claim the user has made.
- For each claim, verify it against the codebase and git history:
- Read the files the user references — does the code behave as they describe?
- Check
git log,git diff, andgit blameon relevant files — does the history support their timeline? - If the user says "this used to work" or "this changed recently," use
git log --all -- <file>andgit diff <commit range>to verify.
- Classify each claim as: confirmed, partially correct (right intuition, wrong detail), or not supported by evidence.
- Report findings before proceeding to trace — the user's mental model may be off, and correcting it early saves time.
-
Trace the issue:
- Follow the execution path from the symptom to the source.
- Read only the files in the chain — do not explore the full codebase.
- UI strategy: trace component tree → styles → layout → animation/transition → render lifecycle. Check for CSS conflicts, missing keys, layout thrashing, and transition timing.
- Data strategy: trace data source → transform → store → subscription → render. Check for stale closures, missing dependency arrays, incorrect comparisons, cache invalidation, and timer drift.
- General strategy: check for null/undefined, wrong types, missing env vars, stale imports, race conditions, schema mismatches, config drift.
- If the initial strategy hits a dead end, pivot to the other strategy — a "UI bug" may have a data root cause, and vice versa.
- If the issue was introduced by a recent commit, identify which one with
git logorgit bisectlogic. - If user claims were partially correct or unsupported, trace from the actual evidence rather than the user's hypothesis.
-
Verify the hypothesis:
- Look for test coverage of the affected code path.
- Check if the bug is reproducible from the code alone (no need to run the app unless necessary).
- If there are related tests, run them to confirm the current state.
-
Propose the fix and request permission:
- Write a concise proposed fix covering the files to change, the intended implementation, and the tests or acceptance checks to run.
- Ask the user for explicit permission before editing files, applying patches, running write-capable generation commands, or otherwise implementing the fix.
- Do not implement from this skill until the user approves.
- If the user approves, continue to step 6a.
- If the user does not approve or has not responded, stop after reporting the investigation findings and proposed fix.
6a. Apply or plan the approved fix:
- Determine fix mode:
- If
--planflag is set → plan mode (always write totasks/todo.md) - If fix requires 3+ discrete steps across multiple files → plan mode
- Otherwise → inline mode (apply fix directly)
- If
- Inline mode (default for single contained fixes):
- Write the minimal code change that fixes the root cause.
- If tests exist, update them. If not, write a test that would have caught this.
- Run the relevant tests to confirm the fix works and no regressions.
- Plan mode (multi-step fixes or
--planflag):- Do NOT apply code changes. Proceed to step 7.
- Write fix steps to
tasks/todo.md(plan mode only):- Read existing
tasks/todo.mdif present — do NOT overwrite existing content. - Append a new section:
## Investigation Fix: [concise title of the issue] - [ ] Step description — `file/path.ext` — why this change is needed - [ ] Step description — `file/path.ext` — why this change is needed ... - [ ] Verify: run [specific test command or acceptance criterion] - Each item must specify: what to change, which file, and why.
- Final item must be an acceptance criterion (run tests, verify behavior).
- Order steps by dependency — changes that other steps depend on come first.
- Read existing
Output
Strategy Used
- Mode: UI / Data / General (and whether auto-detected or flag-forced)
- Pivoted: Yes/No — if the initial strategy didn't find the root cause and a different layer was the actual source
User Claims Validated
For each claim the user made:
- Claim: What the user said
- Verdict: Confirmed / Partially correct / Not supported
- Evidence: What the code or git history actually shows
(Skip this section if the input was a plain error message or stack trace with no user hypotheses.)
Root Cause
- Location:
file:line - What's wrong: One-sentence explanation
- Introduced by: commit hash or "pre-existing" if not recent
- Relationship to user's theory: How this connects to (or diverges from) what the user suspected
Proposed Fix
(Shown before implementation approval)
- Files to modify and why
- Implementation outline
- Tests or acceptance checks to run
- Explicit permission question before any implementation
Fix Applied
(Shown in inline mode after implementation approval)
- Files modified and what changed
- Test results
Fix Steps Written
(Shown in plan mode — replaces "Fix Applied")
- Written to
tasks/todo.mdunder## Investigation Fix: [title] - Number of steps and summary
- Consume the approved fix-step artifact with the project executor to apply the steps sequentially
Prevention
- What test or check would have caught this earlier
Constraints
- Do not refactor unrelated code while fixing the bug.
- Do not guess — if you can't trace the root cause, say so and list what you've ruled out.
- Always validate user claims before assuming they're correct — the user's observations are a starting point, not ground truth.
- Do not implement fixes without explicit user permission after reporting the investigation findings and proposed fix.
- Always run tests after applying an approved fix (inline mode).
- If the fix requires changes outside the current project (infra, env vars, external service), document what's needed instead of attempting it.
- Do not write to
docs/debug-changelog.md— that is/debug's domain. - Do not write to
tasks/todo.mdfor single-step fixes unless--planis explicitly set.
Default Shipping Contract
Follow the shared shipping contract convention in CLAUDE.md.
04 同仓库更多 Skills
source-checkout-allowed
Valid source-checkout-only fixture.
deck-install-valid
Valid deck install fixture.
codex-pack-guard-valid
Valid Codex Pack Availability Guard fixture.
codex-missing-skill-valid
Valid Codex missing skill fallback fixture.
codex-base-skill-fallback-valid
Valid Codex base skill fallback fixture.
claude-pack-guard-valid
Valid Claude Pack Availability Guard fixture.