Seeing Inside Claude Code: How claude-trace Reveals Every Prompt and API Call
claude-trace intercepts Claude Code’s Anthropic API calls, logs them to .jsonl, and generates a self‑contained HTML report that displays system prompts, tool definitions, tool outputs, and full request/response details, with options to include all requests or index the logs for searchable summaries.
Many users of Claude Code wonder exactly what hidden system prompts, tool definitions, context, and request parameters are sent to the Anthropic model. The author recommends the open‑source utility claude-trace to answer these questions.
claude-traceworks by intercepting Claude Code’s requests to the Anthropic API, recording them as .jsonl logs and automatically generating a self‑contained HTML report. The report can be opened directly in a browser without starting any additional service.
By default the tool keeps only the more complete, analytically valuable conversations, discarding fragmented requests. Users who need a full dump can add the --include-all-requests flag to capture every API call.
The source code also redacts sensitive request headers, so tokens are not exposed in the logs, making the tool safer to use.
The most valuable aspects of claude-trace are:
You can view Claude Code’s system prompt, tool definitions, tool output, and the raw request/response payloads—crucial for anyone studying agent workflows.
The generated HTML file is self‑contained; double‑clicking it opens a visual log view in the browser.
For long‑term recording, the --index option scans the .claude-trace/ directory, uses Claude CLI to create conversation titles, summaries, and an index page (at the cost of extra tokens).
Installation is straightforward via npm: npm install -g @mariozechner/claude-trace Typical usage commands include:
# Start Claude Code with logging
claude-trace
# Record all API requests (default records only complete dialogs)
claude-trace --include-all-requests
# Run Claude with specific model
claude-trace --run-with chat --model sonnet-3.5
# Show help
claude-trace --help
# Extract OAuth token
claude-trace --extract-token
# Generate HTML report from a .jsonl file
claude-trace --generate-html logs.jsonl report.html
# Generate HTML with all requests
claude-trace --generate-html logs.jsonl --include-all-requests
# Generate searchable index and summary
claude-trace --indexThe final logs are saved in the project directory as .claude-trace/log-YYYY-MM-DD-HH-MM-SS.{jsonl,html}. The .jsonl file is suitable for archival or further processing, while the .html file can be opened directly.
When opened, the HTML report shows a visual log view of the entire conversation, making it far easier to read than raw logs. Users can navigate through the dialogue, switch between different views, and drill down to see system prompts, tool definitions, and detailed request/response payloads.
Seeing the system prompt is especially valuable because it reveals the hidden constraints and role definitions that Claude Code injects into the model—information that is otherwise a black box. The report also displays tool definitions and parameters, allowing developers to understand exactly which tools the agent can call and under what conditions.
Beyond curiosity, the detailed request and response logs are useful for debugging abnormal behavior, tracing how much context was added, and inspecting how tool output is incorporated into the final prompt.
From an implementation perspective, claude-trace injects interception logic into Claude Code at runtime, captures the outbound API calls, and assembles the data into a readable report. It therefore provides a systematic way to observe the execution flow of AI coding agents.
For researchers studying AI agents or developers debugging Claude Code, claude-trace offers a practical window into the hidden layers of prompts, tool interactions, and API payloads, turning guesswork into concrete, inspectable data.
In summary, the tool’s greatest value lies not merely in exposing hidden content but in enabling systematic observation of how Claude Code and similar agents operate, providing both ordinary users and developers with deeper insight and a reliable debugging aid.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
