This is stage 2 of a three-stage bug workflow: it reads the issue report from stage 1, digs into actual code to find root cause, and presents you with 2-3 fix options before touching anything. The workflow is opinionated about not guessing. It forces file:line pinpointing, requires walking through the failure path versus normal path to find where things diverge, and won't let you skip to implementation without choosing a repair strategy. You'd trigger it after cs-issue-report confirms a bug is real. The checkpoint design is interesting: it makes you review root cause and pick a fix approach before moving to stage 3, which keeps you from autopilot merge disasters.
npx -y skills add liuzhengdongfortest/codestable --skill cs-issue-analyze --agent claude-codeInstalls into .claude/skills of the current project.
开始任何判断或动作前,先读取 .codestable/attention.md;缺失则视为骨架不完整,提示先补齐或运行 cs-onboard,不要回退到外部 AI 入口文件。
用户已把问题描述清楚,你的活是通过实际读代码找根因——不是脑子里推断、不是在报告基础上猜。读代码是核心动作,跳过它写出来的分析没价值。
分析完不直接动手——给用户看 2-3 种修复方案让 TA 选。原因:根因往往有多种修法,影响面 / 副作用 / 改动范围各不相同,这是用户该拍板的事。
共享路径与命名约定看
.codestable/reference/shared-conventions.md第 0 节和cs-issue的"文件放哪儿"。
{slug}-report.md,确认 doc_type=issue-report 且 status=confirmed,5 节都有内容。不完整 / 状态不对 → 回 cs-issue-report。cs-issue-report 已判走标准路径就按标准路径走,不二次改判{slug}-analysis.md 已存在则检查 5 节哪些已填:
status=draft → 跳到 checkpoint.codestable/attention.md.codestable/ 发现可用输入,按需取用:architecture/(涉及跨模块时读 ARCHITECTURE.md)、compound/(用 search-yaml.py 搜相关 trick / explore / learning,命中在分析开头标注引用)、requirements/(涉及能力边界时读)每步都要真正读代码不要靠推测。
按报告"涉及模块 / 复现步骤"用 Grep / Glob 找:搜函数名 / 类名 / 文件名;沿调用链追溯(用户入口往下找);重点看条件分支 / 边界值 / 状态更新 / 异步 / 数据流转。
记关键位置:{文件}:{行号} — {这里干什么}。
对照复现步骤把代码执行路径走一遍:用户触发什么 → 调哪个函数 → 数据怎么流 → 哪里分叉走错。描述"正常路径"和"失败路径"的分叉点。分叉点 = 根因候选。
单一 vs 多个根因;多个根因列出主次。
根因分类:
为什么复核:report 阶段给的是基于现象的判断,分析后看到了影响面——往往发现问题比看上去严重或没那么严重。
列 2-3 种方向,每种说明:做什么(改哪里、怎么改)/ 优点 / 缺点和风险 / 影响面(会动哪些文件、影响其他功能吗)。
推荐方案:在 2-3 种里挑一种说明理由(通常:改动范围最小 + 根因最直接 + 副作用最少)。
---
doc_type: issue-analysis
issue: {issue 目录名}
status: draft
root_cause_type: logic | state-pollution | data-format | concurrency | config | missing-guard
related: [{slug-report.md 相对路径}]
tags: []
---
# {问题简述} 根因分析
## 1. 问题定位
| 关键位置 | 说明 |
|---|---|
| `{文件}:{行号}` | {干什么,为什么有问题} |
## 2. 失败路径还原
**正常路径**:{用户做 A → 调用 B → 数据经过 C → 结果 D(符合期望)}
**失败路径**:{用户做 A → 调用 B → 在 C 处因为 E 走了错误分支 → 结果 F(不符合期望)}
**分叉点**:`{文件}:{行号}` — {为什么这里走错}
## 3. 根因
**根因类型**:{...}
**根因描述**:{一段话说清为什么会发生,要能让没看过代码的人理解}
**是否有多个根因**:{是 / 否。是的话列出主次}
## 4. 影响面
- **影响范围**:{只影响报告场景 / 还会影响 X、Y、Z}
- **潜在受害模块**:{列出可能被波及的}
- **数据完整性风险**:{有 / 无。有的话说明}
- **严重程度复核**:{维持 P? / 调整为 P?,理由}
## 5. 修复方案
### 方案 A:{方案名}
- **做什么**:{改哪里、怎么改}
- **优点**:{...}
- **缺点 / 风险**:{...}
- **影响面**:{会动哪些文件,会影响其他功能吗}
### 方案 B:{方案名}
- ...
### 推荐方案
**推荐方案 {A / B}**,理由:{改动范围最小 / 根因最直接 / 副作用最少 + 具体说明}
写完后别直接开始修:
doc_type=issue-analysis / issue 一致){文件}:{行号})status: confirmed告诉用户:"根因分析已就绪,方案已确认。下一步阶段 3 修复验证,触发 cs-issue-fix。"
别自己顺手改代码——跨阶段无停顿往下跑会让用户来不及把关。
cursor/plugins
github/awesome-copilot
alirezarezvani/claude-skills
microsoft/win-dev-skills