deep-trace
Trace ลึกตาม execution flow, logs, metrics, หรือ distributed trace
SKILL.mddeep-trace/SKILL.md
GitHubGoal
Trace deeply along the path of execution, data flow, request lifecycle, logs, metrics, or distributed traces to find anomalies
Scope
Use when you need to know how the code runs, where data flows, what a request passes through, or where an error occurs
Best for async timing, race conditions, distributed systems, data pipelines, or request paths
Not for general root-cause hunting — use /deep-debug
Not for pure performance analysis — use /run-profiler
Execute
1. Define Trace Target
Goal: Identify what to trace
- Pin down the target: function, request, event, variable, error, latency spike
- Identify the entry point and the expected exit point
- Identify the boundaries to cross: process, network, database, queue, service
- Run
/deep-thinkingif the trace target is complex
2. Choose Trace Source
Goal: Pick the right data source
- If logs exist → use structured logs to find a correlation id or request id
- If metrics exist → look at dashboards for spikes or patterns
- If distributed traces exist → use the trace id to follow the path
- If there is no telemetry → use code reading:
/search-files-patterns,/use-astgrep - If runtime behavior is needed → add temporary instrumentation
3. Instrument If Needed
Goal: Add visibility when the trace is unclear
- Add temporary structured logs: function name, input, output, state
- Add temporary metrics for duration or count
- Add trace spans if using OpenTelemetry or an observability tool
- Mark the instrumentation as temporary — it must be removed once tracing is done
- Never leave permanent
console.log
4. Reproduce And Capture
Goal: Produce repeatable trace data
- Build a reproduction case for the target
- Run it and capture logs, metrics, traces
- Use the same correlation id or request id
- Record timestamp, environment, input
- If the trace is unstable → repeat 3-5 times
5. Follow The Path
Goal: Follow the path of execution or data
- Start at the entry point and go to the exit point
- Record every step: function, service, database, queue, external API
- Check the state/variables that change at each step
- Identify async points, awaits, callbacks, event loop cycles
- Use
/use-astgrepor/search-files-patternsto find the call graph
6. Identify Boundary Crossings
Goal: Find where data or control crosses a boundary
- Identify network calls: HTTP, gRPC, message queue
- Identify database operations: query, transaction, migration
- Identify process boundaries: microservices, workers, edge functions
- Check serialization/deserialization, encoding, timeout, retry
- Identify clock, ordering, concurrency boundaries
7. Pinpoint Anomaly
Goal: Find the anomaly in the trace
- Compare the expected flow with the actual flow
- Look for delays, missing events, duplicated events, unexpected errors
- Look for state that doesn't match expectations
- Diff or compare side-by-side a once-working flow with the broken one
- Run
/analyze-root-cause-analysisif a causal chain is needed
8. Fix And Verify
Goal: Fix the problem and confirm the trace is correct again
- Run
/resolve-errorsfor a targeted fix - If changing the flow structure → run
/deep-analyzefirst - Remove the temporary instrumentation
- Re-run the reproduction case and capture a new trace
- Verify the flow matches the expected one again
- Run the full test suite to confirm
Rules
1. One Trace At A Time
- Follow a single target per trace session
- Don't trace multiple things at once
- Record every step for reproducibility
2. Structured Telemetry
- Use structured logs, not ad-hoc prints
- Use correlation id / request id / trace id
- Don't add permanent telemetry without a reason
3. Tool First
- Use existing observability before adding logs
- Use
/search-files-patternsand/use-astgrepto trace in code - Use
/run-profilerif a latency breakdown is needed
4. Boundary Aware
Give priority to boundary crossings
Check network, database, serialization, concurrency
Don't overlook async or event-driven flows
Use /watch-browser fix if needed
Use /report if needed
Use /follow-tool-git if needed
Expected Outcome
- A step-by-step list of the execution or data flow
- The anomaly point with evidence
- The causal chain of the problem
- A clearly targeted fix
- Reproducible trace data
- Regression tests to prevent the broken flow from recurring