Prerequisites
Before setting up tracing, ensure you have:- Claude Code CLI installed.
- A LangSmith API key.
- Node.js installed.
Getting started
From within Claude Code, run: The marketplace update on its own only refreshes the catalog clone. Your install stays pinned to the version directory it was installed from, so the hooks keep running the old bundle until
claude plugin update moves it. To skip both steps next time, run /plugin, open Marketplaces → langsmith-claude-code-plugins and choose Enable auto-update: third-party marketplaces have it off by default, and enabling it updates the marketplace and its installed plugins together. If you are migrating from the previously recommended version of tracing Claude Code with manually created stop hooks, refer to Migrating from the manual stop hook.
Setting environment variables
Option 1: Project-level configuration (recommended) The plugin requires the following environment variables:TRACE_TO_LANGSMITH: "true": Enables tracing for this project. Remove or set tofalseto disable tracing.CC_LANGSMITH_API_KEY: Your LangSmith API key.CC_LANGSMITH_PROJECT: The LangSmith project name to which your traces will send.- (optional)
CC_LANGSMITH_METADATA: JSON object of custom metadata to attach to all runs (e.g., PR URL, author). - (optional)
CC_LANGSMITH_DEBUG: "true": Enables detailed debug logging. Remove or set tofalseto disable debug logging.
.claude/settings.local.json in your project directory and populate it as follows:
Alternatively, to enable tracing to LangSmith for all Claude Code sessions, you can add the previous JSON to your global Claude Code settings.json file.
~/.zshrc, ~/.bashrc, or ~/.bash_profile):
Verify setup
Traces will appear complete in your LangSmith project after Claude Code responds. If you interrupt a run while it is in progress, the plugin will only flush that run when you send the next message or end the session. In LangSmith, you’ll find:- Each message to Claude Code appears as a trace.
- All turns from the same Claude Code session are grouped using a shared
thread_id, which you can view in the Threads tab of a project.
Custom metadata
Set theCC_LANGSMITH_METADATA environment variable to a JSON object to attach custom metadata to all traced runs. This is useful for tagging traces with contextual information such as PR URLs, authors, or environment names.
- Settings file (recommended)
- Shell environment variable
Mute a thread
Muting suppresses a thread’s input and output content in traces without disabling tracing. Muting is off by default unless you set a default. With tracing enabled, run these plugin commands inside Claude Code. Neither command takes arguments:/langsmith-tracing:mute: Omit this thread’s input and output content from later traces./langsmith-tracing:unmute: Restore full tracing for later turns in this thread.
Set a default mute configuration
To start threads in metadata-only mode without running a command in each one, setCC_LANGSMITH_DEFAULT_MUTED to "true":
- Settings file (recommended)
- Shell environment variable
"false" to return to the unmuted default. The comparison is case-insensitive, and any other value mutes, including an empty string.
The plugin also reads a defaultMuted boolean from its own configuration files, in this order: .claude/langsmith.json and langsmith-plugins.json in the project directory, then ~/.claude/langsmith.json and ~/.langsmith-plugins.json. The environment variable takes precedence over all four.
Thread preferences are sticky. The plugin saves each explicit mute or unmute to a privacy file, ~/.claude/state/langsmith_state.privacy.json by default, and a saved thread preference wins over the configured default in both directions. Deleting the privacy file removes every thread override and returns each thread to the configured default.
Secret redaction
The plugin redacts detected secrets from run inputs, outputs, errors, and metadata before uploading them to LangSmith. Redaction is on by default. Redaction runs on your machine before upload, so unredacted content never reaches LangSmith. Replica destinations receive the same redacted payload. Detection covers provider API key prefixes, JSON Web Tokens, and PEM private key blocks. It also covers contextual shapes such asAPI_KEY=<value>, an Authorization header, and a password embedded in a URL. Each match is replaced with [SECRET_DETECTED]. For the rule list, see Redact secrets from traces.
Redaction matches known credential shapes, so treat it as a safety net rather than a guarantee. A credential in an unrecognized format still reaches LangSmith, and attachments, run names, and tags do not pass through the anonymizer. A redacted trace also still holds the prompts, file contents, and tool results it was built from, so restrict who can read the tracing project.
Redaction targets credential values, not identity. The anthropic_user_id and local_username metadata that the plugin attaches is unaffected. To omit content and attribution instead of scrubbing credentials out of it, mute the thread.
Turn redaction off
SetCC_LANGSMITH_REDACT to false, 0, no, or off. The comparison is case-insensitive, and any other value leaves redaction on.
Redact additional patterns
SetCC_LANGSMITH_REDACT_EXTRA to a JSON array of { "pattern": ..., "replace": ... } rules. Each pattern is a regular expression string, applied globally and case-sensitively. replace is optional and falls back to [redacted].
redact and redact_extra_rules keys:
.claude/langsmith.json can set redact to false, review that file before enabling tracing in a repository you do not control.
Usage with GitHub Actions
You can use this plugin withanthropics/claude-code-action to trace Claude Code runs in CI. Add the following to your workflow:
LANGSMITH_API_KEY and ANTHROPIC_API_KEY as repository secrets.
This lets you correlate traces back to specific PRs, commits, and authors in LangSmith.
Nesting traces under an existing run
You can also set an environment variable namedCC_LANGSMITH_PARENT_DOTTED_ORDER to nest all Claude Code traces as children of an existing LangSmith run. This is useful when Claude Code is invoked programmatically as part of a larger traced workflow.
Python
Trace to multiple destinations (replicas)
You can trace to multiple LangSmith projects or workspaces simultaneously using theCC_LANGSMITH_RUNS_ENDPOINTS environment variable. Set CC_LANGSMITH_RUNS_ENDPOINTS to a JSON array of replica configurations. This overrides other client settings.
Tracing to multiple replicas is useful for:
- Sending traces to both a production and staging project.
- Tracing to multiple workspaces with different API keys.
- Adding extra metadata to specific replica destinations.
There are two ways to set the
CC_LANGSMITH_RUNS_ENDPOINTS environment variable:
- Settings file (recommended)
- Shell environment variable
In your local
.claude/settings.local.json or global ~/.claude/settings.json:Troubleshooting
No traces appearing in LangSmith
-
Check the hook is running:
You should see log entries after each Claude response.
-
Verify environment variables:
- Check that
TRACE_TO_LANGSMITH="true"in your project’s.claude/settings.local.json. - Verify your Personal Access Token (PAT) is correct (starts with
lsv2_pt_). - Ensure the project name exists in LangSmith.
- Check that
-
Enable debug mode to see detailed API activity:
Then check logs for API calls and HTTP status codes.
Subagent runs do not appear after user interruption
Subagents are only traced upon completion. This means if you interrupt a conversation turn in the middle of a subagent run, the subagent’s child runs will not be traced.Managing log file size
The hook logs all activity to~/.claude/state/hook.log. With debug mode enabled, this file can grow large:
Migrating from the manual stop hook
If you were using the previous version of tracing Claude Code with LangSmith, you will need to remove~/.claude/hooks/stop_hook.sh and remove the reference to the hook from any previous settings.local.json or settings.json files you added it to previously, then follow the plugin installation instructions.
Source code
The plugin is open-source under the MIT license and is available in this GitHub repo.Connect these docs to your agent of choice via MCP for real-time answers.

