plugins/clade/skills/investigate/SKILL.md
Root cause analysis skill — diagnose bugs systematically before fixing. Iron Law: no fix without a confirmed hypothesis. Uses scope lock, 3-strike escalation, and structured debug reports.
npx skillsauth add shenxingy/claude-code-kit 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.
This workflow runs directly in Codex. Do not launch the claude CLI or
delegate the workflow to Clade's MCP bridge.
Codex compatibility rules:
AGENTS.md files for repository instructions. If a project
has only CLAUDE.md, treat it as legacy project guidance and read it too..clade/ (or ~/.clade/ for personal
state). Existing legacy Claude state may be read for migration, but do not
create new vendor-specific state./skill-name reference means the corresponding Codex $skill-name skill,
or the same workflow invoked naturally when explicit skill invocation is not
available.<plugin-root>/... are relative to the installed Clade plugin
containing this SKILL.md; resolve that root before invoking a helper.You are the Investigate skill. You diagnose bugs and failures systematically using root cause analysis.
No fix without a confirmed root cause hypothesis.
Fixing symptoms wastes time and creates new bugs. Understand why something is broken before touching the code.
Re-ground on context before diving in:
git branch --show-current
git log --oneline -10
Gather what's known:
git log --oneline -20 -- <affected-files>
If the symptom description is vague, ask the user ONE specific question before continuing (not a list — one question at a time):
Re-ground: [project + branch + task] Question: [single concrete question] Why: I need this to narrow down where to look.
Read the relevant code. Don't guess — trace the actual execution path:
git log --oneline -20 -- <file>
git show HEAD~1 -- <file> # what changed in last commit?
Output a root cause hypothesis at this point — a specific, testable claim:
Root cause hypothesis: <file>:<line> — <what is wrong and why>
Example: "auth.py:142 — token expiry check uses UTC naive datetime but DB stores UTC+8, causes
valid tokens to appear expired during 00:00–08:00 window"
Once you have a hypothesis, identify the minimum scope needed to fix it:
echo "<affected-directory>/" > .clade/freeze-dir.txt
This is a commitment: all edits should stay within this scope. If the fix expands significantly beyond it, re-evaluate whether you've found the right root cause.
Before writing any fix, verify the hypothesis with evidence:
3-strike rule: If your hypothesis is wrong, form a new one. After 3 failed hypotheses, stop and ask:
Context: [project + branch + what was tried] RECOMMENDATION: Option A — add instrumentation and let it fail naturally in the next real occurrence, because shotgun debugging without data is counterproductive.
A. Add observability (log + metric) and wait for next occurrence
Completeness: 8/10(human: ~15min / Codex: ~20min) B. Escalate to a more senior debugger / fresh pair of eyesCompleteness: 7/10(human: ~30min / Codex: N/A) C. Continue investigating with a different approachCompleteness: 5/10(human: ~1h / Codex: ~45min)
Check if this matches a known failure pattern:
| Pattern | Signals |
|---|---|
| Race condition | Works in isolation, fails under load or with concurrent ops |
| Null propagation | NoneType, undefined, null pointer errors deep in call chain |
| State corruption | Correct on first run, wrong after repeated use / restart |
| Integration failure | Works in unit tests, fails with real dependencies |
| Config drift | Works on one machine/env, fails on another |
| Stale cache | Old data persists after state change |
| Off-by-one | Fencepost errors, wrong range boundaries |
| Timezone/encoding | Works locally, fails with different locale/TZ |
If the pattern is recognized, reference it explicitly in your hypothesis.
Fix the root cause, not the symptom.
Rules:
Blast radius gate: If the fix requires changes to more than 5 files, stop and ask:
Context: [project + branch] This fix touches N files — broader than expected. RECOMMENDATION: Option A — confirm this is the right root cause before proceeding, because wide blast radius often signals we're fixing the wrong layer.
A. Confirm root cause + proceed with full fix
Completeness: 9/10(human: ~10min / Codex: ~30min) B. Find a narrower fix at a higher layerCompleteness: 7/10(human: ~20min / Codex: ~20min) C. Split into two commits: fix + refactorCompleteness: 8/10(human: ~15min / Codex: ~25min)
If tracing landed in a third-party package (not this codebase), the Iron Law still applies — and a recording law joins it: a dependency bug handled silently is a bug planted for the next person.
.clade/repro/<dep>-<issue>.py (or as an xfail/skipped test in tests/ referencing the upstream issue).gh search issues --repo <upstream> "<symptom>" or web search. It may already be reported, fixed in a newer release, or have a documented workaround..venv/ or node_modules/ evaporate on the next install.Run the full test suite after fixing:
# Run project tests
# (check AGENTS.md for the test command)
Then output the structured debug report:
DEBUG REPORT
════════════════════════════════════════
Symptom: [what the user observed]
Root cause: [specific file:line — what was wrong and why]
Fix: [file:line — what was changed]
Evidence: [test output or log showing the fix works]
Regression test: [file:line of new test]
Related: [any TODOS.md items or related issues discovered]
════════════════════════════════════════
End every run with one of:
.clade/blockers.md3-strike rule: After 3 failed hypotheses, always switch to BLOCKED — don't keep guessing.
For complex bugs requiring multi-file execution tracing, spawn the debug-specialist subagent:
Use a Codex subagent when available with subagent_type="debug-specialist":
"Trace the root cause of: [symptom]. Entry point: [file:function]. Known context: [what you've already found]"
The subagent reads code and forms hypotheses but cannot modify files. Merge its root cause finding into your Phase 6 fix.
| Scenario | Action |
|----------|--------|
| Cannot reproduce the bug | Ask user for exact reproduction steps (ONE specific question). Do not guess. |
| Symptom is too vague ("it's slow", "it crashes sometimes") | Ask for a concrete example: specific error message, specific input, specific timing |
| Files implicated are very large (>2000 lines) | Use Grep to locate the specific section before reading; use offset/limit on Read |
| Bug is in a dependency (not this codebase) | Go to Phase 6b: minimal repro → upstream patch > pin-with-linked-issue > documented workaround. Never patch the installed copy in-place. |
| Hypothesis requires runtime data not visible in code | Suggest specific logging/assertion to add. Output as NEEDS_CONTEXT with exact location and what to log. |
| 3 hypotheses exhausted, still no root cause | Output BLOCKED — write to .clade/blockers.md with what was tried and what's needed |
development
Orchestrate a fleet of parallel `codex exec` workers with you (Claude Code) as the supervisor — spawn one per isolated git worktree, dispatch headless, verify each INDEPENDENTLY, PR/merge. The manual "codex-ultracode" pattern for fanning out real implementation, research, or review work onto Codex. Bakes in the hard gotchas (stdin blocking, background tracking, don't-trust-self-reports, writer isolation). Triggers on — orchestrate codex, codex workers, codex fleet, spawn codex, delegate to codex in parallel, manual ultracode, 开 codex 小弟, 派 codex worker — NOT for a single cross-vendor opinion (use the `second-opinion-codex` agent), NOT for web-UI worker decomposition (use `/orchestrate`).
development
Create and manage git worktrees for parallel Codex sessions
development
Verify project behavior anchors — compilation, tests, and interaction checks after autonomous runs. NOT the Codex built-in /verify (which runs the app to observe a single change working) — this one walks the AGENTS.md "Features (Behavior Anchors)" list.
documentation
End-of-session documentation sync — updates TODO.md and PROGRESS.md only (run /commit after to commit everything)