src/autoskillit/skills_extended/investigate/SKILL.md
Deep investigation of errors, bugs, or codebase questions without making any code changes. Use when user mentions investigate, understand, explore, analyze, or pastes error tracebacks. Spawns parallel subagents for comprehensive exploration.
npx skillsauth add talont-org/autoskillit investigateInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Perform deep codebase investigation without making any changes. This skill uses parallel subagents to explore multiple aspects simultaneously.
Deep analysis mode is activated when ANY of the following conditions are met:
--depth deep flag is present in ARGUMENTS--depth deep via the skill_commandWhen deep analysis mode is active, all subagents spawned via the Task tool always use model: "sonnet". The main skill session model is controlled by the recipe or user — typically opus[1m] for the main session in deep mode.
Deep analysis mode is never enabled by default. When none of the activation conditions above are met, the skill routes to Standard Mode (Steps 1–4).
If the ARGUMENTS contain a GitHub issue reference, call fetch_github_issue via the MCP
tool before beginning any analysis. Use the returned content field as the investigation topic.
Detection — scan ARGUMENTS for any of these patterns:
https://github.com/{owner}/{repo}/issues/{N}
(e.g. https://github.com/acme/project/issues/42){owner}/{repo}#{N} (e.g. acme/project#42)#N or N when github.default_repo is configuredGitHub Issue: followed by a URL or shorthandBehavior:
fetch_github_issue and use the
returned content as the complete investigation topic.GitHub Issue: {url} line (added by the pipeline
orchestrator) → call fetch_github_issue for that URL and append the returned content
as supplementary context appended after the investigation topic.include_comments: true for full context.fetch_github_issue returns success: false, log the failure and proceed with the
raw ARGUMENTS as-is.NEVER:
{{AUTOSKILLIT_TEMP}}/investigate/ directoryrun_in_background: true is prohibited)ALWAYS:
model: "sonnet" when spawning all subagents via the Task tool{{AUTOSKILLIT_TEMP}}/investigate/ directory (relative to the current working directory){{AUTOSKILLIT_TEMP}}/investigate/...
save path to absolute by prepending the full CWD:
investigation_path = /absolute/cwd/{{AUTOSKILLIT_TEMP}}/investigate/{filename}.md
This token is MANDATORY — the pipeline cannot proceed without it.Path-existence guard: Before issuing a Read call on a path that is not guaranteed to
exist (e.g., plan file arguments, {{AUTOSKILLIT_TEMP}}/investigate/ reports, external file references), use
Glob or ls to confirm the path exists first. This prevents ENOENT errors that cascade into
sibling parallel-call cancellations.
Identify what needs investigation:
Spawn explore subagents to investigate different aspects simultaneously (some aspects may and should require multiple subagents):
Core Implementation
Dependencies & Consumers
Test Coverage
Error Context (if error investigation)
Similar Patterns
Architecture Context
External Research (Web Search)
Design Intent
git log --follow on the mechanism's primary file(s) to find the introducing commitAfter subagents complete, consolidate into structured findings:
Before writing the report, check whether the root cause identified in Step 3 has been investigated or fixed before. This catches recurring bugs where a prior fix was incomplete, symptom-only, or applied at the wrong layer. Zero overhead for first-occurrence bugs: if nothing matches, skip the analysis subagent and record a single-line result.
Derive the Claude project log directory from the current working directory:
PROJECT_PATH=$(pwd)
LOG_DIR="$HOME/.claude/projects/-${PROJECT_PATH//\//-}"
LOG_DIR="${LOG_DIR//--/-}"
Search for .jsonl files containing prior /autoskillit:investigate invocations, excluding subagent log subdirectories (*/subagents/*) so prior subagent conversations are not double-counted:
find "$LOG_DIR" -name "*.jsonl" -not -path "*/subagents/*" -print0 | \
xargs -0 grep -l '/autoskillit:investigate' 2>/dev/null
For each matching log file, extract the investigation topic, root cause conclusion, and affected components by scanning for keywords "root cause", "Root Cause", "fix", and "summary" in assistant messages. Compare against the current investigation's root cause and affected components — overlapping components or error patterns indicate a recurrence.
Using the affected components from Step 3, extract the primary source file paths. Then search bounded recent history (last 100 commits) for commits whose messages signal a prior fix or revert on those files:
{AFFECTED_FILES}expands to a space-separated list of file paths relative to the repo root (e.g.src/autoskillit/execution/headless.py tests/execution/test_headless.py). Pass each path as a separate argument — do not wrap the list in quotes as a single string.
git log --oneline -100 --format="%H %s" \
--grep="fix\|revert\|remove\|replace" -- {AFFECTED_FILES}
For each matching commit, read the diff to check for symbol-level overlap with the current root cause:
git show {HASH} -- {AFFECTED_FILES}
Cross-reference: if a commit message references the same error type, component name, or function that the current investigation identified as the root cause, treat it as a prior fix for the same or a closely related issue.
If Part A or Part B found matches, spawn a single subagent (using model: "sonnet" via the Task tool) to:
git show {commit_hash}If neither Part A nor Part B produced matches, skip the subagent entirely and record: "No prior investigations or fixes found for this root cause." This guarantees zero overhead for first-occurrence bugs.
When prior fixes are found and the analysis shows the root cause is recurring, explicitly flag: "This is a recurring pattern — consider running /autoskillit:rectify for architectural immunity after resolving the immediate issue."
Write findings to: {{AUTOSKILLIT_TEMP}}/investigate/investigation_{topic}_{YYYY-MM-DD_HHMMSS}.md (relative to the current working directory)
Report structure:
# Investigation: {Topic}
**Date:** {YYYY-MM-DD}
**Scope:** {What was investigated}
**Mode:** {Standard | Deep Analysis}
## Summary
{One paragraph overview}
## Root Cause
{If error investigation - the actual source}
## Affected Components
- {file1}: {role} [SUPPORTED / NEEDS-EVIDENCE]
- {file2}: {role} [SUPPORTED / NEEDS-EVIDENCE]
## Data Flow
{How data moves through the system}
## Test Gap Analysis
{Why existing tests didn't catch this}
## Similar Patterns
{How similar scenarios are handled elsewhere}
## Design Intent Findings
{Per-mechanism analysis from the Design Intent subagent:}
- {mechanism_1}: Introduced in {commit_hash} ({date}) — {stated purpose}. Callers: {caller list}. Documented constraints: {any ADR/architecture.md references}.
- {mechanism_2}: ...
{If no mechanisms were specifically targeted:}
No specific mechanisms flagged for design intent analysis.
## Historical Context
{If prior fixes found:}
- Prior investigation dates and report paths
- Prior fix commits/PRs with hashes and summaries
- Analysis of why prior fixes were insufficient
- Whether this represents a recurring pattern (flag for /autoskillit:rectify)
{If no prior history:}
No prior investigations or fixes found for this root cause.
## External Research
{Relevant findings from web search - library bugs, known issues, documentation insights}
{Include source URLs for reference}
## Scope Boundary
**Investigated:** {What was actually explored in this investigation}
**Not yet explored:** {Areas identified but not yet investigated — may warrant follow-up}
## Recommendations
{Suggested approaches - NOT code changes}
{In deep analysis mode: single recommendation, not a menu of options}
{Include killed alternatives with reasons if deep mode}
## Breakage Analysis {Deep mode only — omit in standard mode}
{Deep mode only — adversarial breakage analysis for removal/change recommendations:}
- Recommendation: {recommendation text}
- Breakage surface: {components that would break, with file paths}
- Prior reverts: {any revert history on this mechanism}
- Downstream contract violations: {contracts that depend on this mechanism}
- Risk level: {LOW / MEDIUM / HIGH}
{If standard mode or no removal/change recommendations:}
{Omit this section entirely.}
After writing the report file, emit the structured output token as the very last line of your text output:
IMPORTANT: Emit the structured output tokens as literal plain text with no markdown formatting on the token names. Do not wrap token names in
**bold**,*italic*, or any other markdown. The adjudicator performs a regex match on the exact token name — decorators cause match failure.
investigation_path = {absolute_path_to_investigation_report_file}
When deep analysis mode is activated, Steps D1–D6 replace standard Steps 1–3.5. Step 4 (Write Report) is still executed at the end of D5, and Step D6 adds post-report validation before emitting investigation_path.
Parse the investigation target (same as Step 1). Then propose an adaptive batch plan:
Headless auto-approve: Check the AUTOSKILLIT_HEADLESS environment variable. If set to a truthy value (1, true, yes), automatically approve the proposed batch plan without prompting the user. In interactive mode (AUTOSKILLIT_HEADLESS unset or falsy), present the plan and await user confirmation before proceeding to D2.
Launch a minimum of 5 parallel subagents (model: "sonnet") covering:
git log --follow, caller tracing, and architecture doc checks on the mechanisms under investigation — identical to the Standard Mode Design Intent vector but with deep mode evidence standardsSimultaneously with Batch 1 subagents, run historical recurrence check (Step 3.5 Parts A+B) in parallel. After Batch 1 completes, produce inter-batch synthesis: summarize confirmed findings, open questions, and new investigative leads.
After inter-batch synthesis, run Part C of Step 3.5 conditionally: if Parts A+B found prior history, spawn the conditional analysis subagent. Otherwise skip and proceed to D3.
For each subsequent batch (Batch 2, Batch 3, ...):
## Design Intent Findings in the final report (do not replace prior findings).Early termination: When all findings across all open questions are SUPPORTED (backed by direct code evidence) and no new investigative leads have emerged in the last batch, stop iterating and proceed to D4.
Empty batch handling: If a batch produces no new findings (all subagents report the same conclusions as prior batches), treat it as an early termination signal and proceed to D4.
Fires when ANY finding across any batch is marked NEEDS-EVIDENCE.
Spawn one adversarial subagent (model: "sonnet") whose role is to disconfirm the primary hypothesis:
If counterevidence is found: Return to D3 for one additional deepening batch focused on reconciling the contradiction.
If no counterevidence is found: The hypothesis stands. Proceed to D5.
Spawn solution-space subagents to enumerate candidate fixes. For each candidate, spawn one blast radius subagent (model: "sonnet") to assess:
After blast radius analysis, converge to a single recommendation — the highest-confidence, lowest-blast-radius candidate with direct code evidence. Kill alternative options and document why each was rejected.
Adversarial Breakage Analysis: After converging to a single recommendation, assess whether it proposes removal, replacement, or any action whose execution would eliminate, reduce, or supersede the function of an existing mechanism. If so, spawn one adversarial breakage subagent (model: "sonnet") per such recommendation:
git log --oneline --grep="revert" -- {mechanism_files}The adversarial breakage subagent is distinct from the D4 challenge round. D4 asks "is the root cause correct?" (epistemological — fires on NEEDS-EVIDENCE findings). D5 breakage asks "what breaks if we follow this recommendation?" (consequentialist — fires on removal/change recommendations). Both are required in deep mode.
If the recommendation does not propose removal or change of an existing mechanism (e.g., it proposes adding new code only), skip adversarial breakage analysis for that recommendation.
After writing the report (Step 4), spawn 2–3 independent validator subagents (model: "sonnet") with distinct roles:
If any validator identifies errors or gaps, apply in-place corrections to the report before emitting investigation_path. The structured output token is emitted after all validation and correction is complete.
Use this template for each Explore subagent in standard mode:
Investigate {specific aspect} of {target}.
Focus on:
1. {Specific question 1}
2. {Specific question 2}
3. {Specific question 3}
This is a research task - DO NOT modify any code.
Report your findings in a structured format.
Use this template for the Design Intent subagent in both standard and deep modes:
Investigate the design intent and dependency chain of {mechanism} in {target}.
Investigation tasks:
1. Run `git log --follow` on {file_path(s)} to find the introducing commit
2. Read the introducing commit message and diff to extract the stated purpose
3. Trace all callers and dependents — map every component that relies on this mechanism
4. Check architecture docs (architecture.md, CLAUDE.md, ADRs) for documented design constraints
5. Produce a design intent finding: what this mechanism is for, what introduced it, and what depends on it
Evidence standards:
- Cite the introducing commit hash and date
- List specific caller file paths and line numbers
- Reference any architecture doc sections that mention this mechanism
- Mark finding as SUPPORTED (direct evidence) or NEEDS-EVIDENCE (inferred)
This is a research task - DO NOT modify any code.
Report your findings in a structured format with explicit evidence citations.
Use this template for each subagent in deep mode batches:
Investigate {specific aspect} of {target}.
Context from prior batches:
{Summary of confirmed findings and open questions from previous batch inter-batch synthesis}
Focus on:
1. {Specific question 1}
2. {Specific question 2}
3. {Specific question 3}
Evidence standards:
- Cite specific file paths and line numbers for all code claims
- Include log timestamps for any log-based findings
- Mark each finding as SUPPORTED (direct evidence), UNSUPPORTED (contradicted), or NEEDS-EVIDENCE (not yet confirmed)
This is a research task - DO NOT modify any code.
Report your findings in a structured format with explicit evidence citations.
Use this template for the D4 challenge round subagent:
PRIMARY HYPOTHESIS: {primary hypothesis from D3 synthesis}
SUPPORTING EVIDENCE:
{All evidence collected across all batches that supports the hypothesis}
YOUR ROLE: You are an adversarial reviewer. Your task is NOT to confirm the hypothesis.
Your task is to find counterevidence — code paths, behaviors, data, or reasoning that
CONTRADICTS or WEAKENS the primary hypothesis.
Specifically:
1. Search for code paths that would NOT exhibit the described behavior
2. Look for prior fix commits that may have already addressed this root cause
3. Assess prior-fix falsifiability: if prior fixes exist, determine whether they actually
addressed this root cause or only a surface symptom
4. Identify any assumptions in the hypothesis that are not backed by direct code evidence
If you find counterevidence, report it explicitly with citations.
If you cannot find counterevidence after thorough search, report "No counterevidence found."
This is a research task - DO NOT modify any code.
Use this template for D6 validator subagents:
REPORT PATH: {absolute path to investigation report}
YOUR ROLE: {Factual Accuracy Validator | Recommendation Soundness Validator | Gap Analysis Validator}
Factual Accuracy Validator tasks:
- Read the full report
- Cross-check every factual claim against the actual codebase (use file reads, symbol lookups)
- Flag any claim that is incorrect, imprecise, or not backed by direct code evidence
- Propose corrections for any inaccuracies found
Recommendation Soundness Validator tasks:
- Read the Recommendations section of the report
- Assess whether the recommendation is implementable without introducing new bugs
- Assess whether the scope is correct (not too narrow, not too broad)
- Flag any risk surface the recommendation introduces
Gap Analysis Validator tasks:
- Read the Scope Boundary section of the report
- Identify any areas listed as "not yet explored" that are actually relevant to the root cause
- Identify any areas NOT listed that should have been explored
- Report whether the investigation coverage is sufficient for the stated findings
Report your findings in a structured format. If corrections are needed, state them explicitly.
This is a research task - DO NOT modify any code.
Use this template for the D5 adversarial breakage subagent (deep mode only):
RECOMMENDATION: {recommendation text}
TARGET MECHANISM: {mechanism being removed/changed/superseded}
DESIGN INTENT: {summary from Design Intent subagent findings for this mechanism}
YOUR ROLE: You are a breakage analyst. Your task is NOT to evaluate the recommendation's
merit. Your task is to determine what would break if this recommendation is followed.
Investigation tasks:
1. Trace the mechanism's full dependency chain: callers, importers, flag consumers,
test fixtures that depend on its behavior
2. Check git history for prior revert patterns on this mechanism:
`git log --oneline --grep="revert" -- {mechanism_files}`
3. Identify downstream components whose contracts or invariants rely on this mechanism
4. Assess whether the recommendation accounts for all dependents found in steps 1-3
Report a breakage surface analysis:
- Components that would break (with file paths and line numbers)
- Prior reverts of similar changes (with commit hashes)
- Downstream contract violations
- Overall breakage risk: LOW (no dependents) / MEDIUM (dependents exist, manageable) / HIGH (critical path dependents)
This is a research task - DO NOT modify any code.
development
Generate YAML recipes for .autoskillit/recipes/. Use when user says "make script skill", "generate script", "script a workflow", "write a script", "create a script", "new recipe", "write a pipeline", or when loaded by other skills for script formatting.
data-ai
Create Uncertainty Representation visualization planning spec showing error bar definitions, distribution-aware alternatives, and multi-seed variance protocols. Statistical lens answering "How is uncertainty honestly represented?"
data-ai
Create Temporal Dynamics visualization planning spec showing axis scaling (linear vs log), smoothing disclosure, epoch/step alignment, run aggregation (mean + variance bands), early-stopping markers, and wall-clock vs step-count x-axis. Temporal lens answering "Are training dynamics shown clearly and honestly?"
data-ai
Create Narrative Story Arc visualization planning spec showing visual consistency across the report (same color = same model everywhere), logical figure progression, redundant figure detection, and narrative dependency between figures. Narrative lens answering "Do the figures tell a coherent story across the report?"