Trace code through the stack — upward to entry points, downward to data, or laterally across boundaries. Use when the user asks "where does this get called from", "what calls this method", "trace this through the stack", "how does this request flow", "where does this data come from", "follow this through the code", or pastes/selects a piece of code and wants to understand where it fits in the larger system.
67
84%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Given a piece of code, a symbol, or a file reference, trace it through the stack and produce a diagram showing where it sits, what calls it, and what it depends on.
The input is one of:
InvoiceService#create, POST /invoices)app/services/invoice_service.rb:42)If no input is provided, ask: "What code do you want to trace? Paste a snippet, name a method or class, or give a file path."
Identify the framework before tracing — conventions differ significantly:
| Framework | Detection Signal |
|---|---|
| Rails | Gemfile contains rails; has app/, db/schema.rb |
| Django | pyproject.toml or requirements.txt contains django |
| FastAPI/Flask | pyproject.toml or requirements.txt contains fastapi or flask |
| Laravel | composer.json contains laravel/framework |
| Next.js | package.json contains next; has pages/ or app/ dir |
| Node/Express | package.json exists; app.js or server.js entry point |
| Go | go.mod exists |
| Elixir/Phoenix | mix.exs exists |
| .NET | *.csproj or *.sln exists |
Find the actual source before tracing:
grep/find to locate the definitionRead the located code closely before tracing.
Determine what layer the code belongs to. Use the detected stack's conventions:
| Layer | Rails example | Django example | Node example |
|---|---|---|---|
| Entry point / route | config/routes.rb | urls.py | app.js route |
| Controller / handler | app/controllers/ | views.py | route handler |
| Service / business logic | app/services/ | services/ | src/services/ |
| Model / domain | app/models/ | models.py | ORM model |
| Data access | ActiveRecord query | QuerySet | repository |
| Background job | app/jobs/ | Celery task | queue worker |
| Serializer / presenter | app/serializers/ | DRF serializer | DTO |
| View / template | app/views/ | templates/ | JSX component |
| External integration | app/services/*_client.rb | integrations/ | API client |
Follow references/playbook.md for the full trace procedures, including detailed steps for each direction, handling of inheritance/polymorphism/god objects, and how to handle ambiguous traces with multiple entry points.
Summary:
Trace upward (toward the entry point / caller):
Trace downward (toward data and dependencies):
Trace laterally (cross-cutting concerns):
If the trace gets complex — deep inheritance, polymorphic dispatch, god objects, or dynamically-generated methods — read the "Handling Common Complexity" section in playbook.md before continuing.
If the input could belong to multiple flows — read "When the Trace Is Ambiguous" in playbook.md and ask the user to clarify before tracing.
Present a vertical stack diagram, then a prose walkthrough.
[Entry point] e.g. POST /invoices → InvoicesController#create
↓
[Controller/Handler] e.g. InvoicesController#create
↓
[Service/Logic] e.g. InvoiceService#create
↓ (async)
[Background Job] e.g. SendInvoiceEmailJob
↓
[Model/Data] e.g. Invoice.create!, LineItem.insert_all
↓
[External/Storage] e.g. Stripe API, PostgreSQLUse ↓ for synchronous calls, ↓ (async) for background/async handoffs, → for lateral triggers (callbacks, events). Use actual names from the codebase — not generic placeholders.
After the diagram, write 3–5 sentences explaining how data flows through these layers for this specific code path. Note any non-obvious hops, authorization points, or side effects.
Use clickable [file:line](path/to/file#Lline) links for every layer cited.
Want to go deeper?
End with 2–3 specific follow-up suggestions based on the trace — e.g.:
cb80143
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.