skills/trace/SKILL.md
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.
npx skillsauth add rolemodel/rolemodel-skills traceInstall 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.
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, PostgreSQL
Use ↓ 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.:
testing
Verify what Ruby versions actually exist and install a specific Ruby via rbenv. Use BEFORE asserting that any Ruby version does or doesn't exist (e.g., "Ruby 4.0 isn't out yet", "the latest Ruby is 3.x", "Ruby X.Y.Z doesn't exist"). Also use when the user asks "what's the latest Ruby", "is Ruby X out", "does Ruby X.Y exist", "install Ruby", "switch to Ruby X", "what Ruby is installed", or mentions a specific Ruby version you're unsure about. Claude's training data may be out of date — run `check.sh` first.
tools
Pick the single highest-priority unresolved Sentry issue and hand it off to a fixer skill. Use when triaging Sentry errors, running automated issue triage, or when asked to fix the top Sentry issue in a project.
tools
Find and fix issues from Sentry using MCP. Use when asked to fix Sentry errors, debug production issues, investigate exceptions, or resolve bugs reported in Sentry. Methodically analyzes stack traces, breadcrumbs, traces, and context to identify root causes.
development
Perform comprehensive code audits of Ruby on Rails applications based on thoughtbot best practices. Use this skill when the user requests a code audit, code review, quality assessment, or analysis of a Rails application. The skill analyzes the entire codebase focusing on testing practices (RSpec), security vulnerabilities, code design (skinny controllers, domain models, PORO with ActiveModel), Rails conventions, database optimization, and Ruby best practices. Outputs a detailed markdown audit report grouped by category (Testing, Security, Models, Controllers, Code Design, Views) with severity levels (Critical, High, Medium, Low) within each category.