Trace code execution path before implementing fixes. Forces understanding of fn(args, deps) flows, Result types, and workflow composition. Prevents guessing by requiring file:line references and execution diagrams.
Traces execution paths before implementing fixes. Forces understanding of fn(args, deps) flows, Result types, and workflow composition with file:line references and execution diagrams. Activates before bugs, features, or refactors to prevent guessing.
/plugin marketplace add jagreehal/jagreehal-claude-skills/plugin install jagreehal-claude-skills@jagreehal-marketplaceThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Trace execution paths before implementing. Understand the flow, then fix.
Map the execution path before changing code. When fixing bugs, implementing features, or refactoring, you must first understand how the code currently flows through your fn(args, deps) functions, Result types, and workflows.
Before:
Skip for: Typos, formatting, documentation-only changes.
Answer these with file:line references:
src/api/routes.ts:45)fn(args, deps) functions are called? (src/domain/get-user.ts:12)createWorkflow()? Which steps? (src/workflows/load-user-data.ts:23)src/domain/get-user.ts:28)src/api/handlers.ts:67)Show the flow with Result types and deps:
HTTP Request: POST /users/:id
↓ (args: { userId: string })
Handler.getUser() [src/api/handlers.ts:45]
↓ (validates with Zod schema)
getUserSchema.safeParse() [src/api/handlers.ts:48]
↓ (parsed.data: { userId: string })
getUser(args, deps) [src/domain/get-user.ts:12]
↓ (deps: { db: Database, logger: Logger })
deps.db.findUser() [src/infra/database.ts:89]
↓ (returns: User | null)
Result check [src/domain/get-user.ts:28]
↓ (if null) → err('NOT_FOUND')
↓ (if user) → ok(user)
resultToResponse() [src/api/handlers.ts:67]
↓ (maps Result → HTTP)
HTTP 200 or 404
Key elements:
fn(args, deps) signaturesok() vs err())Ask: "Here's the execution flow: [diagram]. The error occurs at [file:line] when [condition]. Correct?"
Wait for confirmation before proceeding.
When tracing, identify:
argsdeps are injected at each step// Trace shows:
getUser(args: { userId }, deps: { db, logger })
↓
createUser(args: { name, email }, deps: { db, logger, mailer })
↓
// Question: Why does createUser need mailer but getUser doesn't?
// Answer: Each function declares only what it uses (per fn-args-deps)
Show Result propagation:
getUser() → Result<User, 'NOT_FOUND' | 'DB_ERROR'>
↓
createWorkflow({ getUser })
↓
step(() => getUser(...)) → unwraps Result
↓
if err → short-circuits, returns err
if ok → continues to next step
Trace through createWorkflow():
workflow(async (step) => {
const user = await step(() => getUser(...)); // Step 1
const posts = await step(() => getPosts(...)); // Step 2 (skipped if Step 1 err)
return { user, posts }; // Only if all ok
})
Problem: getUser returns err('DB_ERROR') but database is working.
❌ WRONG (guessing): "I'll add retry logic to getUser."
✅ RIGHT (tracing first):
Trace:
GET /users/:id → Handler.getUser [src/api/handlers.ts:45]getUser(args, deps) [src/domain/get-user.ts:12]catch block returns err('DB_ERROR') [src/domain/get-user.ts:28]deps.db.findUser is mocked in tests, real DB in integrationDiagram:
Handler.getUser() [src/api/handlers.ts:45]
↓
getUser(args, deps) [src/domain/get-user.ts:12]
↓
deps.db.findUser() [src/infra/database.ts:89]
↓ (throws Error)
catch block [src/domain/get-user.ts:28] ← 💥 Returns err('DB_ERROR')
↓
But: Error message is "Connection timeout", not "Connection refused"
Verify: "The error occurs in the catch block, but the actual error is a timeout, not a connection failure. The function is catching all errors as 'DB_ERROR'. Should we distinguish timeout vs connection errors?"
Now the fix is clear: Add specific error handling for timeout vs connection errors, or add timeout to the workflow level (per resilience patterns).
Request: "Add email validation to user creation."
❌ WRONG: "I'll add validation inside createUser function."
✅ RIGHT:
Trace current flow:
POST /users
↓
Handler.createUser() [src/api/handlers.ts:67]
↓
createUserSchema.safeParse() [src/api/handlers.ts:70] ← Validation happens here
↓
createUser(args, deps) [src/domain/create-user.ts:15]
↓
deps.db.saveUser() [src/infra/database.ts:102]
Diagram shows: Validation already happens at boundary (per validation-boundary pattern).
Verify: "Email validation should be in the Zod schema at the boundary, not inside createUser. The schema is at [file:line]. Should I add email validation there?"
❌ "I'll fix the validation error" (didn't trace where it occurs) ✅ "Let me trace where validation fails... [diagram]. The error is at [file:line] when [condition]. Correct?"
❌ "I'll add retry logic" (didn't check if retry exists at workflow level) ✅ "Tracing the flow... [diagram]. Retry should be at workflow level per resilience patterns, not inside the function. Correct?"
| Situation | What to Trace |
|---|---|
| Bug fix | Error location, Result flow, deps chain |
| Feature | Entry point, function chain, where to add code |
| Refactor | Current flow, what changes, impact on callers |
| Performance | Slow path, external calls, workflow steps |
Remember: Understanding the flow makes the solution obvious. Guessing wastes time.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.