- Trace Claude Code sessions to record session, turn, model call, tool, and subagent spans in Braintrust.
- Connect to Braintrust MCP to work with Braintrust projects, experiments, logs, and other data from Claude Code.
Trace Claude Code sessions
Thetrace-claude-code plugin passes your interactions with Claude Code to bt, which in turn uses a background process to build and deliver the trace to Braintrust.
Claude Code continues to communicate directly with its model provider, and tracing failures do not stop your Claude Code session.
Set up tracing
trace-claude-code is already installed, follow Update the tracing plugin.Install Claude Code
Install and authenticate bt
bt CLI quickstart to install bt, authenticate, and set your active context.Enable tracing
- Adds or refreshes the Braintrust plugin marketplace.
- Installs (or updates) and enables
trace-claude-code. - Writes a Claude-specific tracing config file, normally
~/.claude/braintrust.json, which records whether tracing is enabled and which project receives traces.
bt trace enable.Restart Claude Code
Log a test trace
What Braintrust traces
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 in trace_claude_code_version.
Common workflows
Use different tracing settings for one session
Use different tracing settings for one session
bt trace run to trace a single Claude Code invocation without changing the saved tracing configuration.This workflow launches Claude Code from the terminal.To change the saved destination, profile, or organization, rerun bt trace enable claude with the corresponding options. Running bt switch does not change the saved tracing configuration.To add root-span metadata, pass --additional-metadata '<JSON>' to bt trace run for one invocation or to bt trace enable for future sessions. Standard session metadata takes precedence when keys conflict.With bt v0.19.3 or later, pass --tag ci --tag release-validation to either command to tag session spans.Trace a saved Claude Code session
Trace a saved Claude Code session
bt trace import to import a past session, even if tracing was not enabled when it ran.You can also attach an imported session to an existing span or experiment.Resume a Claude Code session
Resume a Claude Code session
Stop tracing Claude Code sessions
Stop tracing Claude Code sessions
bt trace disable claude to uninstall the tracing plugin and remove its tracing configuration. Saved bt profiles and credentials are preserved. Restart Claude Code afterward.Update the tracing plugin
To update the plugin, follow these steps:claude plugin list --json shows trace-claude-code earlier than v2.0.1, or bt --version shows a version earlier than v0.19.0, follow Migrate from an older plugin version.Update bt
bt to the latest version and complete the applicable migrations.Update the tracing plugin
bt trace update updates the installed plugin without changing your saved tracing configuration.Restart and verify Claude Code
Migrate from an older plugin version
To migrate to the latest version of thetrace-claude-code plugin, follow these steps:
Inspect your Claude plugins
trace-claude-code@braintrust-claude-plugin:version before updating. If your tracing configuration file exists, also record its profile, organization, project, and any custom tracing settings you want to preserve.Install or update bt
bt is installed:- If the command succeeds, migrate to the latest version (unless you’ve already done so).
- Otherwise, install
bt, authenticate, and set organization and project context.
Complete version-specific migration steps
trace-claude-code version, beginning with the oldest. If no sections apply, continue to the next step.trace-claude-code v2.0.1
trace-claude-code v2.0.1
bt trace enable claude.If you don’t know which Braintrust project has been receiving your traces, find the value of the BRAINTRUST_CC_PROJECT variable.To find it, look in the env object in ~/.claude/settings.json or the project’s .claude/settings.local.json, and in your shell configuration. If it is not set, the earlier plugin used the claude-code project.Apply your tracing settings
--profile <profile> and --org <organization> if needed to preserve your tracing account and organization. Otherwise, the command uses your active bt context, not your saved tracing settings.To preserve metadata from an older plugin’s configuration or BRAINTRUST_ADDITIONAL_METADATA, pass it explicitly with --additional-metadata '<JSON>'. Normal-session hooks do not read metadata from this environment variable.The command updates your tracing file, normally ~/.claude/braintrust.json. Check the following settings in that file:- Existing
route.additional_metadatais preserved unless you pass--additional-metadata. - Existing
route.tagsis preserved unless you pass--tagor setBRAINTRUST_TAGS. route.flush_moderesets tofire_and_forget. Restore its previous value if you customized it.- Restore any other custom tracing settings you recorded before updating.
Restart and verify Claude Code
Remove obsolete environment settings
Environment settings used before trace-claude-code v2.0.1
Environment settings used before trace-claude-code v2.0.1
- The
envobject in~/.claude/settings.json - The
envobject in your project’s.claude/settings.local.json - Your shell configuration
bt commands, MCP connections, or integrations still need:TRACE_TO_BRAINTRUSTBRAINTRUST_CC_PROJECTBRAINTRUST_API_KEYBRAINTRUST_API_URLandBRAINTRUST_APP_URLBRAINTRUST_ORG_NAMECC_PARENT_SPAN_ID,CC_ROOT_SPAN_ID, andCC_EXPERIMENT_IDBRAINTRUST_CC_DEBUG,BRAINTRUST_ENVIRONMENT_TYPE, andBRAINTRUST_ENVIRONMENT_NAME
Troubleshooting tracing
First, runbt trace doctor claude. Then, review the following:
The tracing plugin is missing or disabled
The tracing plugin is missing or disabled
claude plugin list and confirm that trace-claude-code@braintrust-claude-plugin is installed and enabled. If it is missing or broken, run:Traces do not appear after setup
Traces do not appear after setup
bt trace doctor claude and confirm that tracing is enabled and routed to the intended project.If authentication succeeds but traces do not appear, confirm that your account has permission to write logs to the selected project.For authentication, tracing destination, or endpoint problems, see bt trace troubleshooting and the CLI migration troubleshooting guide.Tracing failures do not interrupt the Claude Code session.Claude Code uses an unexpected configuration directory
Claude Code uses an unexpected configuration directory
CLAUDE_CONFIG_DIR is set in the environment that launches Claude Code. When it’s set, bt trace enable claude and the tracing integration use $CLAUDE_CONFIG_DIR/braintrust.json instead of ~/.claude/braintrust.json.An explicit BT_DAEMON_CONFIG override changes the tracing file path. If you use it, supply the same path when enabling tracing and launching Claude Code.Traces use unexpected settings
Traces use unexpected settings
bt trace run take precedence over the saved tracing configuration. For normal sessions, the integration does not use TRACE_TO_BRAINTRUST, BRAINTRUST_CC_PROJECT, or BRAINTRUST_ADDITIONAL_METADATA from the agent’s environment to override the saved tracing settings.For environment variables accepted by the bt commands themselves, see bt trace.bt reports obsolete tracing environment settings
bt reports obsolete tracing environment settings
bt trace enable claude warns when Claude settings contain environment variables used by an earlier tracing plugin.Connect to Braintrust MCP
The Braintrust MCP server lets Claude Code query and update Braintrust data. MCP is configured independently from the tracing plugin.Set up the MCP server
Install Claude Code
Add the Braintrust MCP server
Remove the retired Braintrust MCP plugin (if installed)
Remove the retired Braintrust MCP plugin (if installed)
braintrust plugin. However, the plugin has been retired in favor of Claude Code’s native MCP configuration. If you installed the plugin, remove it before configuring the direct connection below.Check whether the plugin is still installed:braintrust@braintrust-claude-plugin appears in the list, use its scope value to remove it:trace-claude-code tracing plugin.- Current project
- All projects
~/.claude.json under the current project’s path.Authenticate
bt login, which authenticates the CLI and tracing integration.Verify the connection
- CLI: Start Claude Code and run
/mcpto confirm that the Braintrust server is connected. - Code tab: Start a local session. For local scope, open the project where you ran
claude mcp add. For user scope, open any project.
Use MCP tools
Once connected, Claude Code can query logs, compare experiments, work with datasets, and use other Braintrust tools. For example:- “Show me my recent Braintrust experiments.”
- “Query the last 10 logged requests with errors.”
- “Compare accuracy scores between my two latest experiments.”
Troubleshooting MCP
Braintrust MCP tools do not appear
Braintrust MCP tools do not appear
/mcp and confirm that the Braintrust remote server is registered and connected. Restart Claude Code after adding or changing the server.For a local-scope server in the Code tab, confirm that the local session opened the same project where you ran claude mcp add.MCP authentication or connection fails
MCP authentication or connection fails
/mcp to retry authentication. For authentication methods, regional and self-hosted endpoints, and network requirements, see the Braintrust MCP guide.Next steps
- Learn the CLI: See the full
bt tracereference. - Run evaluations: Follow the evaluation guide.
- Explore MCP tools: See the Braintrust MCP tool reference.
- Browse the source: View the coding-agent plugins repository.