Use prompt.id 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.
Log in to leave a comment.
A PreToolUse hook can intercept test runner commands and filter output to show only failures, cutting thousands of tokens from Claude's context.
CLAUDE.md loads into every message. Move workflow-specific instructions into skills that load on demand to reduce token costs across your session.
Pass custom instructions to /compact so Claude preserves test output, code changes, and other context that matters to your workflow.