-
braintrust: Brings context (docs, logs, experiments) from Braintrust into your programming environment. For example, query logs, access Braintrust docs, or fetch experiment results when writing evaluations. -
trace-claude-code: Traces Claude Code’s operations to show LLM calls, tool usage, and timing data. This can be useful for personal exploration or to monitor your team’s activity.
Prerequisites
Install Claude Code
If you haven’t already, install Claude Code.
Add the Braintrust plugin marketplace
A plugin marketplace is a catalog of plugins that you can browse and install into Claude Code.
Set your API key
Both plugins authenticate using
BRAINTRUST_API_KEY. You only need to set it in one location. Global settings are recommended if you use Braintrust across multiple projects.If the key is set in multiple locations, Claude Code applies this precedence order (highest to lowest):CLI flag (--settings)
CLI flag (--settings)
Overrides settings files for a single session. See the CLI reference for details.
Local project settings (.claude/settings.local.json)
Local project settings (.claude/settings.local.json)
This file applies only to the current project. Don’t commit it to version control.
Global settings (~/.claude/settings.json)
Global settings (~/.claude/settings.json)
Applies to all projects on your machine:
Shell profile (~/.zshrc or ~/.bashrc)
Shell profile (~/.zshrc or ~/.bashrc)
Lowest precedence. Overridden by any settings file:
Plugin: braintrust
The braintrust plugin brings Braintrust data and context directly into Claude Code by connecting to Braintrust’s MCP server.
Setup
Set your API key
Set
BRAINTRUST_API_KEY as described in the Prerequisites.Usage
Once installed, you can ask Claude Code to work with your Braintrust data directly:- “Compare my experiment against the baseline”
- “Show me the last 10 logged requests with errors”
- “What fields are available in my experiment data?”
- “How do I create a custom scorer?”
Troubleshooting
Needs authentication
Needs authentication
Verify that If it’s empty, make sure the key is set in
BRAINTRUST_API_KEY is set in your Claude Code session:~/.claude/settings.json (global), .claude/settings.local.json (project), or your shell profile, then restart Claude Code.Plugin: trace-claude-code
The trace-claude-code plugin automatically traces Claude Code sessions to Braintrust, helping you:
- Debug issues by seeing exactly what tools Claude ran
- Monitor team usage and patterns
- Understand LLM call costs and performance
Setup
Install jq
The tracing hooks use
jq to parse Claude Code’s output:Configure tracing
Make sure Alternatively, run the setup script to configure a project directory interactively:
BRAINTRUST_API_KEY is set as described in Prerequisites, then add the following tracing settings to ~/.claude/settings.json (global), .claude/settings.local.json (project), or your shell profile:The plugin directory path may vary depending on your Claude Code configuration. If the path above doesn’t exist, see plugin caching and file resolution for details on where Claude Code stores installed plugins.
Configuration
Required settings:| Setting | Description | Default |
|---|---|---|
TRACE_TO_BRAINTRUST | Must be set to true to enable tracing | — |
BRAINTRUST_API_KEY | Your Braintrust API key | — |
| Setting | Description | Default |
|---|---|---|
BRAINTRUST_CC_PROJECT | Braintrust project to send traces to | claude-code |
BRAINTRUST_CC_DEBUG | Write verbose logs to ~/.claude/state/braintrust_hook.log | false |
Configuration changes take effect the next time you start a Claude Code session. Exit any running sessions and start a new one to apply your changes.
Usage
Start a Claude Code session:- Session root: The overall Claude Code session from start to finish
- Turns: Individual conversation exchanges (your input → Claude’s response)
- Tool calls: Operations like file reads, edits, terminal commands, and searches
- Session ID and workspace location
- Turn numbers and conversation content
- Tool names with inputs and outputs
- Span attributes indicating type (“task”, “llm”, “tool”)
Embed traces in parent traces
You can embed Claude Code traces inside a parent trace when using Claude Code as part of a larger workflow. This enables better observability by showing Claude Code’s execution context within your broader application traces. To attach a Claude Code session to an existing Braintrust trace, pass theCC_PARENT_SPAN_ID environment variable:
CC_ROOT_SPAN_ID to maintain proper trace relationships:
Troubleshooting
No traces appearing
No traces appearing
Check the hook logs for errors:Verify your environment variables are set correctly and that
TRACE_TO_BRAINTRUST is true. Enable debug mode by setting BRAINTRUST_CC_DEBUG=true.State issues
State issues
If traces seem corrupted or incomplete, try resetting the state file:Then start a new Claude Code session.
Next steps
- Query your data: Use the
braintrustplugin to explore experiments, logs, and datasets from Claude Code. - Explore your traces: View Claude Code session traces in the Braintrust UI.
- Run evaluations: Check out the evaluation guide to learn evaluation patterns.
- Browse examples: The braintrust-claude-plugin repository includes evaluation suites that demonstrate the plugin’s capabilities.