Concept: Bugs are rarely where they explode. The explosion (Stack Trace) is just where the bad data finally violated a constraint.
The Protocol
Do not fix the line in the stack trace yet. Follow the data upstream.
Step 1: Identify the "Contraband"
What specific value caused the crash?
Example: A null user ID.
Example: An empty string "" where a date was expected.
Example: A value of -1 in a price field.
Step 2: The Upstream Walk (The "5 Whys")
Open your IDE. Use "Find Usages" or "Call Hierarchy."
Level 0 (Crash Site):processPayment(user.id) -> Crashed because user.id is null.
Question: Who called processPayment?
Level 1:CheckoutService.submitOrder called it.
Question: Where did CheckoutService get the user object?
Level 2: It was passed in from SessionManager.getCurrentUser().
Question: Why did SessionManager return a user object with a null ID?
Level 3:SessionManager hydrated it from the Redis Cache.
Question: Why is the data in Redis corrupt?
Level 4 (Root Cause): The LoginHandler wrote the user to Redis before the database generated the ID.
Step 3: Verify the Origin
Hypothesis: The bug is in LoginHandler (Level 4), not processPayment (Level 0).
Test: Fix the LoginHandler ordering.
Result: The crash at Level 0 disappears because the data is now correct.
Common Traps
The "Null Check" Trap: Adding if (user.id == null) return; at Level 0 fixes the crash, but it creates a "Zombie Order" (an order that fails silently). Do not do this.
The "Sanitizer" Trap: Cleaning the string at Level 1 hides the fact that the database at Level 5 is corrupt.
Rule: Fix the data generation, not the data consumption.
1---2name: root-cause-tracing3description: Root Cause tracing4---5# Technique: Root Cause Tracing67**Concept:** Bugs are rarely where they explode. The explosion (Stack Trace) is just where the bad data finally violated a constraint.89## The Protocol1011**Do not fix the line in the stack trace yet.** Follow the data upstream.1213### Step 1: Identify the "Contraband"14What specific value caused the crash?15* *Example:* A `null` user ID.16* *Example:* An empty string `""` where a date was expected.17* *Example:* A value of `-1` in a price field.1819### Step 2: The Upstream Walk (The "5 Whys")20Open your IDE. Use "Find Usages" or "Call Hierarchy."21221. **Level 0 (Crash Site):** `processPayment(user.id)` -> Crashed because `user.id` is null.23 * *Question:* Who called `processPayment`?242. **Level 1:** `CheckoutService.submitOrder` called it.25 * *Question:* Where did `CheckoutService` get the `user` object?263. **Level 2:** It was passed in from `SessionManager.getCurrentUser()`.27 * *Question:* Why did `SessionManager` return a user object with a null ID?284. **Level 3:** `SessionManager` hydrated it from the Redis Cache.29 * *Question:* Why is the data in Redis corrupt?305. **Level 4 (Root Cause):** The `LoginHandler` wrote the user to Redis *before* the database generated the ID.3132### Step 3: Verify the Origin33* **Hypothesis:** The bug is in `LoginHandler` (Level 4), not `processPayment` (Level 0).34* **Test:** Fix the `LoginHandler` ordering.35* **Result:** The crash at Level 0 disappears because the data is now correct.3637## Common Traps38* **The "Null Check" Trap:** Adding `if (user.id == null) return;` at Level 0 fixes the crash, but it creates a "Zombie Order" (an order that fails silently). **Do not do this.**39* **The "Sanitizer" Trap:** Cleaning the string at Level 1 hides the fact that the database at Level 5 is corrupt.4041**Rule:** Fix the data generation, not the data consumption.
Run npx skillmds@latest add harshahosur81/root-cause-tracing in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Root Cause tracing It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
harshahosur81 (@harshahosur81) published this skill. Their other Agent Skills are listed on their SkillMD profile.