with one click
cc-investigate
// Use when a bug, regression, broken task, or unexpected behavior needs root-cause investigation, reproducible evidence, and a frozen repair handoff before cc-do resumes coding.
// Use when a bug, regression, broken task, or unexpected behavior needs root-cause investigation, reproducible evidence, and a frozen repair handoff before cc-do resumes coding.
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | cc-investigate |
| version | 1.3.0 |
| description | Use when a bug, regression, broken task, or unexpected behavior needs root-cause investigation, reproducible evidence, and a frozen repair handoff before cc-do resumes coding. |
| triggers | ["帮我查这个 bug","先别修先找根因","debug this bug","investigate this regression","why is this broken","root cause this","先调查再修"] |
| reads | ["PLAYBOOK.md","CHANGELOG.md","references/investigation-contract.md","assets/ANALYSIS_TEMPLATE.md","assets/TASKS_TEMPLATE.md","assets/TASK_MANIFEST_TEMPLATE.json","../cc-roadmap/scripts/locate-roadmap-item.sh","../cc-roadmap/scripts/sync-roadmap-progress.sh"] |
| writes | [{"path":"devflow/changes/<change-key>/planning/analysis.md","durability":"durable","required":true},{"path":"devflow/changes/<change-key>/planning/tasks.md","durability":"durable","required":true},{"path":"devflow/changes/<change-key>/planning/task-manifest.json","durability":"durable","required":true},{"path":"devflow/changes/<change-key>/change-meta.json","durability":"durable","required":true}] |
| effects | ["source roadmap progress sync when investigation freezes, reroutes, or diagnoses a roadmap mismatch"] |
| entry_gate | ["Read the current bug report, existing requirement artifacts, relevant code, tests, and recent history before forming any hypothesis.","Assign the change key by running `cc-devflow next-change-key --prefix FIX --description \"<short bug name>\"`. Use both output lines: first is changeId for task-manifest, second is the full changeKey for the directory.","Build a runnable feedback loop, confirm it matches the reported symptom, then freeze the evidence chain before proposing repair tasks.","Record persistent debug session state: active hypothesis, probes, cleanup status, and next evidence action.","Search prior investigations, TODO/backlog signals, and recent fixes in the affected area before declaring the bug novel.","For multi-component, deep-stack, or flaky symptoms, record boundary probes, backward trace, or condition-wait evidence before declaring the root cause.","For performance regressions, collect a baseline or profile signal before treating logs as evidence.","Do not write production code here; this stage ends with planning/analysis.md plus executable repair tasks for cc-do.","Before exit, locate the source RM in `devflow/roadmap.json`, `devflow/ROADMAP.md`, optional `devflow/BACKLOG.md`, or legacy `devflow/roadmap-tracking.json`; the repair handoff must not leave roadmap progress stale."] |
| exit_criteria | ["planning/analysis.md records symptom, reproduction, evidence chain, boundary probes or backward trace when applicable, pattern analysis, tested hypotheses, confirmed root cause, and repair boundary.","diagnose-only outcomes clearly stop before implementation while preserving root cause, owner, and next action.","workflow forensics classify artifact, git, state, or tool failures before repair tasks are generated.","planning/tasks.md and planning/task-manifest.json are explicit enough that cc-do can repair the bug without chat memory.","The source roadmap item has been synchronized with the investigation outcome, or `planning/analysis.md` and `change-meta.json` record why no roadmap update is valid.","The honest next step is cc-do, cc-plan, or roadmap."] |
| reroutes | [{"when":"The issue is actually a new feature, a scope redesign, or a product decision instead of a bug investigation.","target":"cc-plan"},{"when":"The discussion expands into project sequencing or roadmap priority instead of one broken requirement.","target":"roadmap"},{"when":"Root cause and repair boundary are already frozen.","target":"cc-do"}] |
| recovery_modes | [{"name":"repro-reset","when":"The current conversation cannot state a stable reproduction path or the symptom evidence is stale.","action":"Drop the narrative, rebuild the reproduction from canonical artifacts and fresh output, then restate the symptom before testing hypotheses."},{"name":"re-open-investigation","when":"New execution evidence disproves the current root-cause contract or widens the suspected blast radius.","action":"Reopen planning/analysis.md, update the evidence chain, and regenerate repair tasks only after the new root cause is frozen."}] |
| tool_budget | {"read_files":11,"search_steps":6,"shell_commands":7} |
[PROTOCOL]: 变更时同步更新
version、CHANGELOG.md、相关模板/脚本引用,然后检查CLAUDE.md
cc-investigate 是 bug 路径里的 Investigate,也可以理解成 Debug Plan。
它不是直接修 bug 的地方,而是替代原来 bug 场景下那种混在 cc-do 里的临场 planning。它先把症状压成证据,再把证据压成根因,再把根因压成一个可执行的修复 handoff。
一句话:
cc-plan -> cc-do -> cc-check -> cc-actcc-investigate -> cc-do -> cc-check -> cc-act所以现在仓库里有两条闭环:
PDCAIDCA,如果你更喜欢口语,也可以把它理解成 DDCA写入任何 durable Markdown 或 JSON metadata 前,先运行 cc-devflow config resolve --format policy。
Output language 是机器约束,planning/analysis.md、planning/tasks.md 和 change-meta.json 必须记录并遵守它。agent_preferences 是用户偏好建议,只影响表达方式和结构选择,不覆盖本 Skill 的工作流边界。PLAYBOOK.mdCHANGELOG.mdreferences/investigation-contract.mdassets/ANALYSIS_TEMPLATE.mdassets/TASKS_TEMPLATE.mdassets/TASK_MANIFEST_TEMPLATE.jsoncc-do 连续修补失败,怀疑上游根因判断错了如果问题其实是在问“应该做什么功能”或“范围是否要变”,别硬调试,回 cc-plan。
NO REPAIR WITHOUT A FROZEN ROOT-CAUSE CONTRACT
cc-investigate 可以跑复现、读代码、查日志、加临时探针、证伪假设,但不能把“可能是”写成 repair task。
根因合同必须同时回答:
先判断你面对的是哪一类调查现实:
| 现实状态 | 先走什么路径 |
|---|---|
| 症状真实,但还没有稳定复现 | reproduce-first,先把现象钉死 |
| 已有复现但信号慢 / 松 / 偶然 | feedback-loop,先把 pass/fail loop 做快、准、可复跑 |
| 明显是 regression | diff-trace,先查最近变化 |
| 多组件链路断裂 | boundary-probe,先记录每个边界的输入、输出、配置和状态 |
| 报错点很深或坏值来源不明 | backward-trace,从 symptom site 一直追到 original trigger |
| 同仓库有相似可用路径 | reference-compare,先列出 working vs broken differences |
| flaky / sleep / timeout 类问题 | condition-wait,先找真实等待条件,不先加大延时 |
| 症状已知,但修复边界可能扩大范围 | contract-check,先判是否还属于当前 requirement |
| 错误类型陌生,像框架 / 依赖 / 平台问题 | pattern-research,先做脱敏外部调研 |
| 同一区域反复坏 | history-trace,先查 prior investigations 和最近修复 |
| 看起来像 bug,实则是未定义行为或新需求 | 直接 reroute 到 cc-plan |
| 用户只要根因报告、不要求修复 | diagnose-only,停止在报告与 next action,不生成完成态实现任务 |
| 失败来自 workflow / artifact / git / state 断裂 | workflow-forensics,先分类坏在文件、状态、工具、权限还是流程 |
先说“这是什么类问题”,再说“我要怎么修”。没有分类的 debug,最后都会变成乱打补丁。
planning/analysis.md, planning/tasks.md, planning/task-manifest.json, and change-meta.json, then run the final roadmap progress sync for the source RM.cc-plan; strategy questions go to roadmap; only confirmed repair handoff goes to cc-do.cc-investigate 只允许产出 4 个主文件:
planning/analysis.md
planning/tasks.md
planning/analysis.mdplanning/task-manifest.json
change-meta.json
cc-investigate 不写生产代码,不在这里偷跑 cc-do。
diagnose-only 仍然写 planning/analysis.md,但 planning/tasks.md 只能包含证据交接、
监控、人工动作或明确的 reroute;不能把“已经诊断”伪装成“已经修复”。
planning/design.md / planning/analysis.md / planning/tasks.md / planning/task-manifest.json,不要假设自己是第一位调查者。Boundary Probe Matrix:每个边界的输入、输出、配置 / 环境、状态和 pass/failBackward Trace Chain:immediate failure site、caller chain、bad value origin、original triggerdevflow/changes/*/planning/analysis.md、TODOS.md、backlog、report-card findingdevflow/specs/、roadmap/backlog handoff、历史 planning/design.md / planning/analysis.md 或 change-meta.json,把领域词汇和已冻结决策当成契约证据Reference Comparison,列出 working path、broken path、差异和被接受 / 排除的假设falsification method、expected observation、actual observationDiagnostic Instrumentation Plan:probe tag、probe location、question answered、command、expected signal、cleanup requirement[DEBUG-FIX123-a4f2],进入 cc-do 前用前缀 grep 清理或转正planning/analysis.mdplanning/tasks.md + planning/task-manifest.json + change-meta.jsonlocate-roadmap-item.sh 定位 source RM;找不到时在 analysis.md 和 change-meta.json.roadmapSync 写 no-source-rmimplementation drift:回写 source RM 为 Repair planned 或等价调查完成状态,绑定 FIX-*,进度保持在可执行修复前的真实百分比missing spec truth:回写 source RM 的 expected spec delta 或 follow-up,必要时 reroute 到 cc-planroadmap mismatch:不要直接进入修复;先把 mismatch 写回 roadmap / backlog,下一步写 roadmap 或 cc-plansync-roadmap-progress.sh 更新 devflow/roadmap.json,并重新生成 devflow/ROADMAP.md / devflow/BACKLOG.mdcc-docc-plancc-plan 或 cc-do,但不得标记实现完成不要从空白猜测开始。先把 bug 放进一个可检查的模式:
| Pattern | Signature | First place to inspect |
|---|---|---|
| race condition | 间歇性、时序相关、重试后消失 | 并发写、锁、队列、共享状态 |
| null propagation | TypeError / NoMethod / undefined access | nullable 输入、默认值、边界 guard |
| state corruption | 数据不一致、部分更新、顺序错乱 | transaction、callback、hook、副作用 |
| integration failure | timeout、unexpected response、协议不匹配 | API boundary、service config、schema |
| configuration drift | 本地可用、CI/生产失败 | env、feature flag、版本、路径、权限 |
| stale cache | 清缓存后恢复、旧状态复现 | browser / CDN / Redis / build cache |
| resource leak | OOM、句柄增长、慢性崩溃 | lifecycle、subscription、retention、cleanup |
| performance regression | 变慢、CPU / IO / 查询耗时升高、吞吐下降 | baseline、profiler、query plan、bisect |
| trust boundary drift | LLM / 用户输入 / 外部响应被当成可信 | validation、escaping、policy gate |
| timing guess / flaky wait | sleep / setTimeout / timeout 增大后偶尔通过 | 真实完成条件、事件、文件、状态或队列计数 |
模式分析不是结论,只是定位第一批证据的索引。
多组件链路不要先猜。先记录每个边界的事实:
pass / fail / unknown只有一个边界先失败时,后续调查才收缩到那个组件。多个边界都异常时,优先找共同上游,不在下游堆补丁。
报错点很深时,不准只在 symptom site 加 guard。analysis.md 必须追到:
找不到 original trigger 时,根因还没有冻结,只能继续调查或进入 escalation。
同仓库或参考实现有相似可用路径时,先对照再假设:
不要用“看起来差不多”跳过差异。小差异也可能是根因。
临时日志、断言、探针只能用于回答一个明确问题:
探针不能变成修复。进入 cc-do 前,要么删除,要么明确写入 repair task 的清理 / 转正方式。
根因调查首先依赖一个可信 loop:
把 loop 当成调查产品来迭代。已有 loop 但信号差时,先优化它:
flaky bug 的目标不是立刻 100% 复现,而是提高复现率直到可调试。可以循环 100 次、并行触发、加压力、缩小时序窗口或做 differential loop;如果失败率仍低到不可证伪,先写 Evidence Request,不要继续猜。
没有 loop 时,不能把代码阅读当成根因。只能写 Evidence Request:需要可复现环境、HAR、日志 dump、core dump、带时间戳录屏,或临时生产探针权限。
进入 repair handoff 前,必须说明回归测试缝隙是否正确:
遇到 flaky、sleep、timeout、重试后消失:
如果调查证明是环境、外部服务或时序窗口,不要假装代码根因:
rootCauseClass: code / config / environment / external / timingwhy not code root causemonitoring or future evidence neededoperator handling after fix这类结论仍然需要本地证据支撑;“没有根因”通常只是调查不完整。
同一区域反复坏是架构味道,不是巧合。形成根因前至少查:
git log --oneline -20 -- <affected-files>rg -n "<error-keyword>|<module>|<capability>" devflow/changesTODOS.md、backlog、roadmap 中的相关未解决项report-card.json finding 和 planning/analysis.md如果命中过往调查,写入 analysis.md 的 Prior Investigations,包括是否复发、根因是否同类、这次是否说明结构问题。
外部调研只在本地证据不足、错误类型陌生、或像依赖 / 框架 / 平台 bug 时使用。
调研前必须脱敏:
researchEvidence 写明原因调研结论只能作为候选假设,不能直接变成 confirmed root cause。必须回到本仓库复现或代码证据验证。
形成根因假设后,先锁定最小调查 / 修复边界:
affectedModuleallowedFilesforbiddenFilesblastRadiusFilesblastRadiusRisk: low / medium / high如果修复预计触碰超过 5 个文件,默认说明这可能不是单点 bug:
cc-plan。根因冻结后必须写一句后验判断:什么结构、测试 seam、capability invariant、operator guard 或文档会让这个 bug 更早暴露或根本不出现。
cc-plan 或后续 backlog。三次假设失败后,不准继续硬猜。analysis.md 必须写:
continue-with-new-hypothesis / instrument-and-wait / human-review / reroute-cc-plancc-do 不需要二次调查planning/tasks.md 只包含修复任务,不夹带新需求cc-plan,理由写清楚,不假装还能继续 patchFIX-*、调查状态、spec diagnosis 和 next action 不能停留在聊天里。CHANGELOG.mdreferences/investigation-contract.mdassets/ANALYSIS_TEMPLATE.mdassets/TASKS_TEMPLATE.mdassets/TASK_MANIFEST_TEMPLATE.jsonscripts/bootstrap-analysis.sh../cc-roadmap/scripts/locate-roadmap-item.sh../cc-roadmap/scripts/sync-roadmap-progress.shplanning/tasks.md 必须足够让 cc-do 在脱离当前对话后继续推进。cc-plan。devflow/roadmap.json 为真相源,devflow/ROADMAP.md / devflow/BACKLOG.md 只是投影;不要再写旧式 devflow/roadmap/* 路径。planning/analysis.md 已冻结症状、复现、证据链、根因和修复边界planning/tasks.md / planning/task-manifest.json 可直接交给 cc-docc-do、cc-plan 或 roadmapPLAYBOOK.mdCHANGELOG.mdreferences/investigation-contract.md