- Trace Claude Code sessions: Log your Claude Code sessions to Braintrust, including session, turn, model call, tool, and subagent spans.
- Connect to the Braintrust MCP server: Let Claude Code access your Braintrust projects, experiments, logs, and other data during a session.
Trace Claude Code sessions
Thetrace-claude-code plugin traces your Claude Code sessions to Braintrust by observing Claude Code, not by proxying it:
- Claude Code talks to its model provider directly.
- Hooks notify the plugin when sessions start, prompts arrive, tools run, and sessions finish.
- The plugin uses the
btCLI to build and send traces to Braintrust. - Authentication happens through
bt login. The plugin never handles credentials. - If the plugin or
bthas a problem, Claude Code keeps working. However, you won’t see traces until the setup is fixed.
Set up tracing
trace-claude-code before v2.0.1? See Upgrade.Install Claude Code
Install bt and authenticate
bt CLI, so install it and authenticate:Configure the plugin
bt is installed and authenticated, run the following command:- Terminal
- Desktop app
- Adds the Braintrust plugin marketplace.
- Installs
trace-claude-codethrough Claude Code’s plugin manager. - Selects a project.
- Enables tracing.
Restart Claude Code
Log a test trace
What gets traced
Claude Code traces in Braintrust include:- Session spans with the session ID, workspace, hostname, username, operating system, Claude Code version, model, and Git repository metadata.
- Turn spans with prompts and final responses.
- Model call spans with prompts, completions, token metrics, and errors.
- Tool spans with inputs, outputs, approval state, and tool names.
- Skill metadata when a turn loads skills.
- Subagent spans nested under the turn that started the subagent.
braintrust.plugin.claude-code, and the session span records the plugin version as trace_claude_code_version.
Settings
bt trace setup claude saves your tracing configuration to ~/.claude/braintrust.json. These saved settings control where traces go during normal Claude Code sessions.
- Credentials are stored by
bt, not the configuration file. Authenticate withbt loginorBRAINTRUST_API_KEY. See credential precedence. - To use different settings for one launched session without changing saved configuration, use
bt trace run.
Common workflows
Use custom settings for one run
Use custom settings for one run
bt trace run:~/.claude/braintrust.json.Trace saved Claude Code sessions
Trace saved Claude Code sessions
--parent. See bt trace import for details, including following a live session with --attach.Resume a Claude Code session
Resume a Claude Code session
Upgrade
To get the latestbt and trace-claude-code, follow these steps. If you are upgrading from trace-claude-code before v2.0.1, the steps also cover the required migration.
Update bt
bt before updating trace-claude-code.bt version with bt auth commands, review the CLI migration guide. It explains how saved logins carry over, how profiles and organizations changed, and which commands replaced the old auth commands.bt update updates installs made with the standalone shell or PowerShell installer. If you installed with mise or npm, update bt with that package manager instead. If a Windows install older than bt v0.17.0 cannot update itself, rerun the PowerShell installer.Authenticate bt
trace-claude-code uses bt for tracing and authentication. If you haven’t authenticated with bt, run bt login. You can also authenticate with BRAINTRUST_API_KEY.Run setup
trace-claude-code and writes the latest tracing settings.BRAINTRUST_CC_PROJECT environment variable. If you are upgrading from one of these versions, find its value under env in ~/.claude/settings.json or your project’s .claude/settings.local.json, or in your shell profile. In the command above, replace my-project with that value. If you did not set the variable, use claude-code, the old default. bt trace setup does not migrate this value automatically.Migrate settings from a plugin version before v2.0.1
env in ~/.claude/settings.json or your project’s .claude/settings.local.json, or in your shell profile:Troubleshooting
Traces do not appear
Traces do not appear
- Confirm the plugin is installed and enabled: run
claude plugin listand check thattrace-claude-codeappears. - Verify
btis installed and current:bt --version(v0.16.0 or later). - Verify
btis authenticated: runbt status. If it shows no active login, runbt login. - Verify tracing is enabled: in
~/.claude/braintrust.json, confirm thattrace_to_braintrustistrueandroute.destinationnames the intended project. - Check the background process:
bt trace statusshows whether the tracing daemon is running. - Restart Claude Code after any configuration change.
Connect to the Braintrust MCP server
Claude Code can use Braintrust’s MCP server to access your projects, experiments, and logs. Thebraintrust plugin connects Claude Code to that server.
Set up the MCP server
Install Claude Code
Add the Braintrust plugin marketplace
braintrust plugin is available to install.- Terminal
- Desktop app
Install the plugin
braintrust from the marketplace you just added.- Terminal
- Desktop app
Set your API key
BRAINTRUST_API_KEY. You only need to set it in one location.- Terminal
- Desktop app
CLI flag (--settings)
CLI flag (--settings)
Local project settings (.claude/settings.local.json)
Local project settings (.claude/settings.local.json)
Global settings (~/.claude/settings.json)
Global settings (~/.claude/settings.json)
Shell profile (~/.zshrc or ~/.bashrc)
Shell profile (~/.zshrc or ~/.bashrc)
Verify the setup
/mcp to verify Braintrust is installed and accessible.Use MCP tools
Once configured, Claude Code can access Braintrust data through the MCP server. You can fetch experiment results, query logs, log data, and more. For the full list of available tools, see the MCP documentation. Example prompts in Claude Code:- “Show me my recent Braintrust experiments”
- “Query the last 10 logged requests with errors”
- “What’s the average latency for the summarizer prompt today?”
- “Compare accuracy scores between my two latest experiments”
Troubleshooting
Braintrust MCP tools do not appear
Braintrust MCP tools do not appear
- Confirm the plugin is installed and enabled: run
claude plugin listand check thatbraintrustappears. - Restart Claude Code after installing the plugin or changing configuration.
- Run
/mcpin Claude Code to see available MCP servers.
MCP authentication fails
MCP authentication fails
- Verify your API key is correct (no extra spaces).
- Check the location where you set the key:
~/.claude/settings.json(global),.claude/settings.local.json(project), or your shell profile. Keys set in a settings file are passed to the plugin rather than to your terminal, so they won’t appear in your shell environment. - Claude Code reads the key at startup, so exit any running sessions and start a new one after changing it.
- Ensure you can log into Braintrust using the account associated with the API key.
- Generate a new API key if needed.
MCP connection errors
MCP connection errors
- The plugin connects to
$BRAINTRUST_API_URL/mcp, defaulting tohttps://api.braintrust.dev/mcp. If your organization is on the EU data plane, setBRAINTRUST_API_URLtohttps://api-eu.braintrust.dev. - Corporate networks may need to allowlist the configured Braintrust API host:
api.braintrust.devfor the US data plane orapi-eu.braintrust.devfor the EU data plane. Allowlist*.braintrust.devif your network also filters browser sign-in or app links.
Next steps
- Learn the CLI: See the full
bt tracereference, including session imports and per-run tracing. - Run evaluations: Check out the evaluation guide to learn evaluation patterns.
- Explore MCP tools: See the MCP documentation for all available commands.
- Browse the source: The coding-agent plugins repository contains the plugin source code.