在复杂执行链路中逆向追踪错误根因,定位异常数据或错误触发点。
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "root-cause-tracing" 技能: 1. 下载 https://raw.githubusercontent.com/microsoft/FluidFramework/main/.agency/plugins/nori/skills/root-cause-tracing/SKILL.md 2. 保存为 ~/.claude/skills/root-cause-tracing/SKILL.md 3. 装好后重载技能,告诉我可以用了
请帮我做根因追踪:某个接口最终返回了错误的用户状态。请从报错点开始,沿调用链向前追踪,标出每一层输入输出、关键状态变化,并指出最可能的源头问题;如果信息不足,请建议应添加哪些日志或断点。
一份按调用链逆向展开的排查结果,包含可疑环节、证据和建议补充的观测点。
我发现下游报表中的订单金额异常,请帮我从异常结果倒推到数据写入源头,分析可能在哪个处理步骤引入了错误值,并给出验证每个假设的方法。
一份数据流逆向分析,说明错误值可能出现的位置、原因及验证步骤。
程序在深层函数调用中崩溃,但表面报错信息不明显。请帮我基于调用栈逐层回溯,找出最早出现异常状态的位置,并提出最小化复现和修复建议。
一份根因定位报告,包含最早异常点、复现思路与修复建议。
Bugs often manifest deep in the call stack (git init in wrong directory, file created in wrong location, database opened with wrong path). Your instinct is to fix where the error appears, but that's treating a symptom.
Core principle: Trace backward through the call chain until you find the original trigger, then fix at the source.
digraph when_to_use {
"Bug appears deep in stack?" [shape=diamond];
"Can trace backwards?" [shape=diamond];
"Fix at symptom point" [shape=box];
"Trace to original trigger" [shape=box];
"Bug appears deep in stack?" -> "Can trace backwards?" [label="yes"];
"Can trace backwards?" -> "Trace to original trigger" [label="yes"];
"Can trace backwards?" -> "Fix at symptom point" [label="no - dead end"];
}
Use when:
Error: git init failed in /Users/jesse/project/packages/core
What code directly causes this?
await execFileAsync('git', ['init'], { cwd: projectDir });
WorktreeManager.createSessionWorktree(projectDir, sessionId)
→ called by Session.initializeWorkspace()
→ called by Session.create()
→ called by test at Project.create()
What value was passed?
projectDir = '' (empty string!)cwd resolves to process.cwd()Where did empty string come from?
const context = setupCoreTest(); // Returns { tempDir: '' }
Project.create('name', context.tempDir); // Accessed before beforeEach!
When you can't trace manually, add instrumentation:
// Before the problematic operation
async function gitInit(directory: string) {
const stack = new Error().stack;
console.error('DEBUG git init:', {
directory,
cwd: process.cwd(),
nodeEnv: process.env.NODE_ENV,
stack,
});
await execFileAsync('git', ['init'], { cwd: directory });
}
Critical: Use console.error() in tests (not logger - may not show)
Run and capture:
npm test 2>&1 | grep 'DEBUG git init'
Analyze stack traces:
If something appears during tests but you don't know which test:
Use the bisection script: @find-polluter.sh
./find-polluter.sh '.git' 'src/**/*.test.ts'
Runs tests one-by-one, stops at first polluter. See script for usage.
Symptom: .git created in packages/core/ (source code)
Trace chain:
git init runs in process.cwd() ← empty cwd parametercontext.tempDir before beforeEach{ tempDir: '' } initiallyRoot cause: Top-level variable initialization accessing empty value
Fix: Made tempDir a getter that throws if accessed before beforeEach
Also added validation at multiple layers:
digraph principle {
"Found immediate cause" [shape=ellipse];
"Can trace one level up?" [shape=diamond];
"Trace backwards" [shape=box];
"Is this the source?" [shape=diamond];
"Fix at source" [shape=box];
…
将长期复杂任务拆分为可执行小步骤,减少上下文超限与遗漏
通过结构化追问与方案比较,把模糊想法梳理成可执行设计。
帮助你严谨评估代码评审意见,澄清疑点后再决定是否采纳与实现
用四阶段系统化排查框架定位缺陷根因,再制定可靠修复方案。
在编写或修改测试时识别反模式,避免错误 mock 与污染生产代码。
帮助你实现与迭代界面和交互体验,完成前端集成与设计优化。
系统化排查测试失败、构建中断与异常运行问题,帮助快速恢复开发进度
帮助你为复杂问题编写调试测试并反复验证,快速定位异常根因。
帮助你定位常见故障、兼容性问题并诊断状态机异常
帮助开发者排查 VS Code 遥测中的未处理错误并定位根因。
通过层层追问与假设检验,帮助澄清需求、计划与设计中的关键不确定性。