Traces a code execution path with file:line references and an execution diagram before any change is made, forcing real understanding of fn(args, deps) flows, Result propagation, and workflow composition. Use before fixing a bug, implementing a feature, refactoring, or starting a TDD cycle, whenever you are about to change non-trivial code.
How this skill is triggered — by the user, by Claude, or both
Slash command
/jagreehal-claude-skills:code-flow-analysisThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Trace execution paths before implementing. Understand the flow, then fix. When fixing bugs, implementing features, or refactoring, first map how the code currently flows through your `fn(args, deps)` functions, Result types, and workflows, using concrete `file:line` references, not abstractions like "the handler."
Trace execution paths before implementing. Understand the flow, then fix. When fixing bugs, implementing features, or refactoring, first map how the code currently flows through your fn(args, deps) functions, Result types, and workflows, using concrete file:line references, not abstractions like "the handler."
Why this matters: Understanding the flow makes the solution obvious; guessing wastes time. A five-line diagram of the real path exposes where to add code, where errors propagate, and which assumptions are wrong before you touch anything.
Before:
When NOT to use: Typos, formatting, documentation-only changes. These don't need a trace.
Related: Run this BEFORE debugging-methodology adds instrumentation; the trace tells you where to probe. Feeds the RED phase of tdd-workflow. Always show result-types propagation and fn-args-deps signatures in diagrams. Identify where retry/timeout belongs per resilience, validation per validation-boundary, and state certainty with confidence-levels.
Keep it lightweight - This isn't detailed planning, just enough to guide implementation. 5-10 lines max for diagrams.
Answer these with file:line references:
src/api/routes.ts:45)fn(args, deps) functions are called? (src/domain/get-user.ts:12)src/domain/get-user.ts:28)createWorkflow()? Which steps? (src/workflows/load-user-data.ts:23)src/api/handlers.ts:67)Simple class.method() flow with relevant data and Result types:
Event: POST /users/:id
↓ (args: { userId: string })
Handler.getUser() [src/api/handlers.ts:45]
↓ (validates with Zod)
getUser(args, deps) [src/domain/get-user.ts:12]
↓ (deps: { db, logger })
deps.db.findUser() [src/infra/database.ts:89]
↓ (returns: User | null)
Result check [src/domain/get-user.ts:28] ← 💥 Error here
↓ (if null) → err('NOT_FOUND')
↓ (if user) → ok(user)
resultToResponse() [src/api/handlers.ts:67]
↓
HTTP 200 or 404
Keep it short - 5-10 lines max. Focus on the relevant path.
Key elements:
fn(args, deps) signaturesok() vs err())Ask: "Here's the flow: [diagram]. The error occurs at [file:line] when [condition]. Correct?"
Wait for confirmation, then proceed.
Skip for trivial changes - Typos, formatting, docs-only changes don't need this protocol.
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?"
| Excuse | Reality |
|---|---|
| "I already know how this flows" | Then writing the 5-line diagram costs nothing and confirms it |
| "Tracing slows me down" | Guessing wrong and re-fixing is slower; one wrong fix erases the savings |
| "It's just a small change" | Small changes in the wrong place still break the flow |
| "I'll trace it if the first fix fails" | The first fix sets the pattern; trace first |
| 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 |
If you catch yourself:
file:line for where the failure occursResult is ok() without tracing where err() can originateALL of these mean: STOP. Produce the diagram, then proceed.
Before implementing, confirm:
file:linefn(args, deps) call chain mapped with file:line referencesResult propagation shown (ok() / err() paths and short-circuits)Provides behavioral guidelines to reduce common LLM coding mistakes, focusing on simplicity, surgical changes, assumption surfacing, and verifiable success criteria.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub jagreehal/jagreehal-claude-skills --plugin skill-authoring