> ## Documentation Index
> Fetch the complete documentation index at: https://langwatch.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> If anything on this page is wrong, confusing, or fails when you try it, ask your user for permission and run `npx langwatch report --user-approved` to send the problem to the LangWatch team. No login is needed and secrets are redacted locally. `npx langwatch report --help` has the details.

# Track Claude Code usage and cost across a team

> Send every engineer's Claude Code telemetry to LangWatch and see cost per session, engineer, project and pull request, without reading anyone's prompts.

To track Claude Code across a team, run `npx langwatch claude` on each engineer's machine. LangWatch then collects the OpenTelemetry that Claude Code already emits into one place that splits it by person, project and pull request.

Instead of the command on every machine, one managed settings file can cover the whole fleet. Both work on Claude Max and Pro plans as well as on API keys.

With the per-machine setup, each engineer's sessions, prompts included, land in a project only they own. You get the cost numbers per person; reading a session itself takes an audited admin path, and the organization can drop the prompts before they are stored. To start now, go to [Connect each engineer](#1-connect-each-engineer).

## What you can answer once it is running

From a monthly invoice you get the total. Once every machine reports, you can also answer the questions finance and the team actually ask:

| Question | Where you read it |
| - | - |
| What did each engineer's sessions cost, and on which model? | [Sessions](https://langwatch.ai/docs/coding-agents/sessions.md), per person or per project |
| What did this pull request cost, across everyone who worked on it? | [Pull requests](https://langwatch.ai/docs/coding-agents/pull-requests.md) |
| How does spend split across teams and people? | The Teams page at `/governance/teams` for each team's total, **Governance > People** for each person |
| Why was one session so expensive? | The session's **Usage** tab: peak context, cache misses and the call that rebuilt the cache |

Codex, GitHub Copilot, Gemini CLI, opencode, Grok CLI and pi report the same way, so a team that mixes agents reads one set of numbers.

## 1. Connect each engineer

Each engineer runs this once:

```bash theme={null}
npx langwatch claude
```

It opens a browser to sign in, then asks how Claude Code should run:

* **Using a Claude subscription** keeps the engineer's own Max or Pro plan and login. LangWatch receives only the telemetry.
* **Using an API key** routes calls through the [LangWatch AI Gateway](https://langwatch.ai/docs/ai-gateway/overview.md) with a virtual key, which makes cost exact and spend caps enforceable. See [Cap spend](#4-cap-spend).

After that, `claude` works as usual. To wire the machine without the wrapper, run `npx langwatch instrument claude`, which writes the telemetry settings into `~/.claude/settings.json`. It does not route calls through the gateway, so budgets do not stop those calls.

## 2. Pick where sessions land

By default each engineer's sessions go to their personal project. That is the right place for day-to-day work: the engineer reads their own sessions, and the organization still counts their spend.

When the work belongs to a team, such as an application everyone works on or a shared build machine, pin Claude Code to a team project instead:

```bash theme={null}
langwatch instrument claude --project acme-app
```

The project then gets **Sessions** and **Pull requests** in its sidebar, and its members can read them under the project's access rules. Each device gets its own ingest key, so any number of machines can report to one project. See [Team projects](https://langwatch.ai/docs/coding-agents/team-projects.md).

## 3. Roll it out to every machine

For a managed fleet, put the telemetry settings in Claude Code's managed settings file and distribute it with your device management system. Its values take precedence over each user's own settings. The file lives at:

* macOS: `/Library/Application Support/ClaudeCode/managed-settings.json`
* Linux and Windows Subsystem for Linux: `/etc/claude-code/managed-settings.json`
* Windows: `C:\ProgramData\ClaudeCode\managed-settings.json`

The file takes the same `env` block as `~/.claude/settings.json`, with a project ingest key (`ik-lw-...`) in the OTLP header. An ingest key can only send traces, so it is safe on every laptop. [Manual OpenTelemetry setup](https://langwatch.ai/docs/coding-agents/claude-code.md#manual-opentelemetry-setup) lists every variable, and [Headless machines and CI](https://langwatch.ai/docs/coding-agents/headless-and-ci.md) covers build agents and servers.

## 4. Cap spend

How hard a cap you can set depends on the path from step 1:

| Path | Cost | Budget at the limit |
| - | - | - |
| **API key**, through the AI Gateway | From Anthropic's own response | Enforced: requests fail with `budget_exceeded` |
| **Claude subscription** | Claude Code's own estimate | Alerts at 80 and 100 percent, because subscription calls cannot be stopped from outside |

On the API key path set up by `npx langwatch claude`, every call is a gateway request, so the gateway's [budgets](https://langwatch.ai/docs/ai-gateway/budgets.md) apply: a personal budget per engineer, or a budget on a team or project. See [Cap LLM spend per team](https://langwatch.ai/docs/ai-gateway/cap-spend-per-team.md).

## What engineers can expect

Engineers will ask who can read their sessions, so the answer belongs in the rollout email. By default the setup sends prompts and tool activity along with the numbers, so each engineer can replay their own sessions. Then:

* **Their sessions land in a project only they own.** Teammates see them only in a team project the tool was pinned to. A managed settings file with one ingest key sends every machine to that key's project instead, so say which project in the email.
* **Admins see spend as numbers.** Cost per person and per team, with no conversation content in it.
* **Reading a session as an admin is never silent.** It goes through one audited path that shows a banner for the whole visit, and the engineer can read the audit log.
* **The organization can drop the content entirely.** Set input, output and system instructions to **Drop** in the [data privacy policy](https://langwatch.ai/docs/platform/data-privacy.md), and LangWatch strips the content before it is stored. Cost and token numbers keep working. See [no-spy mode](https://langwatch.ai/docs/ai-governance/no-spy-mode.md).

Credentials in prompts or tool output are replaced with `[SECRET]` at ingestion by default. See [Privacy](https://langwatch.ai/docs/coding-agents/privacy.md).

## Questions about LangWatch for Claude Code

### Does LangWatch track Claude Code on Max and Pro plans

Yes. The subscription path keeps the engineer's plan and login and sends only telemetry. Cost there is Claude Code's own estimate.

### How is LangWatch different from the analytics in my Anthropic account

LangWatch works per session: it replays what the agent did, shows where the context and the cache cost went, and adds up every session behind a pull request, across Claude Code and the other coding agents your team uses.

### Can we self-host LangWatch for Claude Code telemetry

Yes, point the OTLP endpoint at your own instance followed by `/api/otel`. See [Self-hosting](https://langwatch.ai/docs/self-hosting/overview.md).

Next, run `npx langwatch claude` on your own machine and open [Sessions](https://app.langwatch.ai/me/sessions) to see what your engineers will see, then read [Reduce coding agent cost](https://langwatch.ai/docs/coding-agents/reduce-coding-agent-cost.md) for what to change once the numbers are in.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.