$ recombobulate _
home / tips / use-promptid-to-trace-all-activity-from-a-single-user-prompt
0

Use prompt.id to Trace All Activity from a Single User Prompt

bagwaa @bagwaa · Mar 26, 2026 · Performance
use-promptid-to-trace-all-activity-from-a-single-user-prompt

When a user submits a prompt, Claude might make multiple API calls and run several tools. Debugging gets messy fast. The prompt.id attribute links every event back to the prompt that triggered it.

# Enable event export
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_LOGS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317

Every event emitted while processing a single prompt shares the same UUID v4 prompt.id. Filter your logs backend by a specific prompt.id and you'll get the complete chain: the user_prompt event, every api_request, and all tool_result events in sequence.

This is especially useful for debugging slow prompts. You can see exactly which tool calls took the longest, how many API roundtrips were needed, and where errors occurred. The event.sequence attribute gives you ordering within the session.

Note that prompt.id is intentionally excluded from metrics (it would create unbounded cardinality). Use it for event-level analysis and audit trails only.

One prompt, one ID, a complete trace of everything Claude did.


via Claude Code Docs — Monitoring Usage

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Filter Test Output with a PreToolUse Hook to Cut Token Costs

A PreToolUse hook can intercept test runner commands and filter output to show only failures, cutting thousands of tokens from Claude's context.

bagwaa @bagwaa · 3 hours ago
0
Move Specialised CLAUDE.md Instructions into Skills to Shrink Context

CLAUDE.md loads into every message. Move workflow-specific instructions into skills that load on demand to reduce token costs across your session.

bagwaa @bagwaa · 3 hours ago
0
Add Custom Compaction Instructions to Preserve Key Context

Pass custom instructions to /compact so Claude preserves test output, code changes, and other context that matters to your workflow.

bagwaa @bagwaa · 4 hours ago