root-cause-tracing
Skill3 starsChanged 2 days agoApache-2.0View on GitHub
Trace a bug that surfaces deep in the call stack (git init in the wrong directory, file written to the wrong path, DB opened with the wrong cwd) BACKWARD through every caller until the ORIGINAL trigger is found, then fix at the source — never only where the error appears. Method — observe the symptom -> immediate cause -> what called this -> what value was passed -> original trigger (e.g. an empty projectDir resolving to process.cwd()); add stack-trace instrumentation (new Error().stack + cwd + env, console.error in tests) BEFORE the dangerous operation when manual tracing stalls; bisect test pollution by running tests one at a time to find the first polluter. Use when a stack trace shows a long call chain, when it is unclear where invalid data originated, when you must find which test or code path triggers a side effect, or whenever you feel the urge to patch the symptom site. Pair with defense-in-depth after the source fix.
- Reads credentials
16 other projects use a version of this, 11 of them edited.
Adopted by
Most recently taken up by
- PracticalSwan/agent-skillsedited, first seen Nov 16, 2026
- kazemcodes/skill-treetheir own version, first seen Nov 8, 2026
- ZacheryGlass/.claudeedited, first seen Nov 1, 2026
- OpenxIntelligence/Coding-Agent-Skillsedited, first seen Nov 1, 2026
- I-Onlabs/claude-code-skillsedited, first seen Oct 25, 2026
- davidanthonyn/claude-skillsedited, first seen Oct 20, 2026
Used with
Projects with it also use verification-before-completion, dispatching-parallel-agents and 8 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
OpenAISkillverification-before-completion
Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always
Also in 6 projects that use this
OpenAISkilldispatching-parallel-agents
Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies
Also in 4 projects that use this
SentrySkillskill-creator
Create new agent skills following the Agent Skills specification. Use when asked to "create a skill", "add a new skill", "write a skill", "make a skill", "build a skill", or scaffold a new skill with SKILL.md. Guides through requirements, writing, registration, and verification.
Also in 6 projects that use this
MicrosoftSkillmcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
Also in 3 projects that use this
BlockSkillfrontend-design
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
Also in 4 projects that use this
- +5 more from openai
Other versions16 projects use a version of this.
Word for word · 0
None found.
Edited · 11
- microsoft/FluidFramework★ 5k90% same
- ZacheryGlass/.claude★ 59933% same
- fimoklei/pm-ai-playbook★ 4293% same
- PracticalSwan/agent-skills★ 2565% same
- I-Onlabs/claude-code-skills★ 493% same
- OpenxIntelligence/Coding-Agent-Skills★ 493% same
- Crumbgrabber/llm_system_template_agents_skills_patterns_tools_prompts★ 389% same
- kntism/skills★ 193% same
- susomejias/skills★ 193% same
- davidanthonyn/claude-skills★ 093% same
1 more not listed
Wrote their own version · 5
- withzombies/hyperpowers★ 80same name
- allanninal/claude-code-skills★ 1same name
- kazemcodes/skill-tree★ 1same name
- liujiarui0918/claude-code-codex-strongest★ 1same name
- matthewharrilal/claude-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository37 other files it gives its agents.
- docs/manual/agents.mdAGENTS.md
- ablate-combined-changesSkill
- agent-supervisor-methodologySkill
- benchmark-comparisonSkill
- browser-vlm-acceptanceSkill
- claim-verificationSkill
- claude-code-best-practicesSkill
- code-attributionSkill
- comms-connectSkill
- condition-based-waitingSkill
- conference-intelligenceSkill
- deep-research-methodologySkill
- defense-in-depthSkill
- detect-deployment-thrashingSkill
- directory-cross-examinationSkill
- doc-freshness-auditorSkill
- eval-harnessSkill
- github-comment-managerSkill
- github-deep-researchSkill
- github-issue-responseSkill
- harness-setupSkill
- issue-closure-strategistSkill
- issue-quality-assessmentSkill
- k8s-configmap-runtime-patchSkill
- k8s-config-persistence-trapSkill
- maintainer-profilingSkill
- measure-before-theorizeSkill
- multi-phase-optimization-campaignSkill
- phase-trackerSkill
- pptx-slide-creationSkill
- pr-issue-scannerSkill
- public-root-reproducibilitySkill
- repo-organizerSkill
- technique-versioning-workflowSkill
- wrong-layer-debuggingSkill
- wrong-theory-cascade-preventionSkill
- youtube-transcriberSkill
The file
We split this skill into the rules it gives an agent
7 rules. 3 are common, 0 are distinctive, and 4 are very specific to this project.
3
Common
Most of the 15 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Common: line 72
When you can't trace manually, add instrumentation:
- Very specific: line 89
Critical: Use console.error() in tests (not logger - may not show)
- Common: line 97
Look for test file names
- Common: line 103
If something appears during tests but you don't know which test:
- Very specific: line 105
Use the bisection script find-polluter.sh in this directory:
- Very specific: line 121
Test accessed context.tempDir before beforeEach
- Very specific: line 162
In tests: Use console.error() not logger - logger may be suppressed
“Common” is measured: kept by at least 6 in 10 of the 15 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Root Cause Tracing
Overview
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.
When to Use
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];
"BETTER: Also add defense-in-depth" [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"];
"Trace to original trigger" -> "BETTER: Also add defense-in-depth";
}Use when:
- Error happens deep in execution (not at entry point)
- Stack trace shows long call chain
- Unclear where invalid data originated
- Need to find which test/code triggers the problem
The Tracing Process
1. Observe the Symptom
Error: git init failed in <path>2. Find Immediate Cause
What code directly causes this?
await execFileAsync('git', ['init'], { cwd: projectDir });3. Ask: What Called This?
WorktreeManager.createSessionWorktree(projectDir, sessionId)
→ called by Session.initializeWorkspace()
→ called by Session.create()
→ called by test at Project.create()4. Keep Tracing Up
What value was passed?
projectDir = ''(empty string!)- Empty string as
cwdresolves toprocess.cwd() - That's the source code directory!
5. Find Original Trigger
Where did empty string come from?
const context = setupCoreTest(); // Returns { tempDir: '' }
Project.create('name', context.tempDir); // Accessed before beforeEach!Adding Stack Traces
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:
- Look for test file names
- Find the line number triggering the call
- Identify the pattern (same test? same parameter?)
Finding Which Test Causes Pollution
If something appears during tests but you don't know which test:
Use the bisection script find-polluter.sh in this directory:
./find-polluter.sh '.git' 'src/**/*.test.ts'Runs tests one-by-one, stops at first polluter. See script for usage.
Real Example: Empty projectDir
Symptom: .git created in packages/core/ (source code)
Trace chain:
git initruns inprocess.cwd()← empty cwd parameter- WorktreeManager called with empty projectDir
- Session.create() passed empty string
- Test accessed
context.tempDirbefore beforeEach - setupCoreTest() returns
{ tempDir: '' }initially
Root cause: Top-level variable initialization accessing empty value
Fix: Made tempDir a getter that throws if accessed before beforeEach
Also added defense-in-depth:
- Layer 1: Project.create() validates directory
- Layer 2: WorkspaceManager validates not empty
- Layer 3: NODE_ENV guard refuses git init outside tmpdir
- Layer 4: Stack trace logging before git init
Key Principle
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];
"Add validation at each layer" [shape=box];
"Bug impossible" [shape=doublecircle];
"NEVER fix just the symptom" [shape=octagon, style=filled, fillcolor=red, fontcolor=white];
"Found immediate cause" -> "Can trace one level up?";
"Can trace one level up?" -> "Trace backwards" [label="yes"];
"Can trace one level up?" -> "NEVER fix just the symptom" [label="no"];
"Trace backwards" -> "Is this the source?";
"Is this the source?" -> "Trace backwards" [label="no - keeps going"];
"Is this the source?" -> "Fix at source" [label="yes"];
"Fix at source" -> "Add validation at each layer";
"Add validation at each layer" -> "Bug impossible";
}NEVER fix just where the error appears. Trace back to find the original trigger.
Stack Trace Tips
In tests: Use console.error() not logger - logger may be suppressed
Before operation: Log before the dangerous operation, not after it fails
Include context: Directory, cwd, environment variables, timestamps
Capture stack: new Error().stack shows complete call chain
Real-World Impact
From debugging session (2025-10-03):
- Found root cause through 5-level trace
- Fixed at source (getter validation)
- Added 4 layers of defense
- 1847 tests passed, zero pollution
<!-- imported on 2026-10-31 by tools/import-skills.py from a native Claude Code instance's skill library; the source site's names, ids, hosts and paths are scrubbed to <placeholders>; its other files were not copied -->Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

