skills/root-cause-tracing/SKILL.md
Use when errors occur deep in execution and you need to trace back to find the original trigger - systematically traces bugs backward through call stack to identify source of invalid data
npx skillsauth add timequity/vibe-coder root-cause-tracingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Bugs often manifest deep in the call stack. 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.
Error: database query failed with null user_id
What code directly causes this?
await db.query('SELECT * FROM orders WHERE user_id = ?', [userId]);
OrderService.getOrders(userId)
→ called by OrderController.list()
→ called by router.get('/orders')
→ called by auth middleware
What value was passed?
userId = nullWhere did the problem originate?
// Auth middleware bug: didn't handle expired tokens
if (token.expired) {
// Missing: return error response
// Falls through with req.user = undefined
}
When you can't trace manually, add instrumentation:
async function getOrders(userId: string) {
const stack = new Error().stack;
console.error('DEBUG getOrders:', {
userId,
typeOfUserId: typeof userId,
stack,
});
// ... rest of function
}
Run and capture:
npm test 2>&1 | grep 'DEBUG getOrders'
Symptom: .git created in source directory during tests
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 too early
Found immediate cause
↓
Can trace one level up? → YES → Trace backwards
↓ ↓
NO Is this the source?
↓ ↓
NEVER fix just YES → Fix at source
the symptom ↓
Add validation at each layer
↓
Bug impossible
NEVER fix just where the error appears. Trace back to find the original trigger.
console.error() not logger - logger may be suppressednew Error().stack shows complete call chainUsed by:
Pairs with:
development
Hidden quality gate that runs before showing "Done!" to user - ensures all tests pass, build succeeds, and requirements met before claiming completion
data-ai
Use when about to claim work is complete or fixed - requires running verification commands and confirming output before making any success claims
tools
Generate UI components from natural language descriptions. Use when: user asks for a page, component, or UI element. Triggers: "create page", "add component", "show form", "make button", "страница", "компонент", "форма".
content-media
10 ready-to-use themes with colors and fonts for consistent styling. Use when: applying visual themes to pages, components, or design systems. Triggers: "theme", "color palette", "color scheme", "fonts", "branding", "visual identity", "design system colors".