Claude Code
Track every Claude Code session: tokens, estimated cost, tool calls, subagents, files changed, and which developer, project and branch it was for. Install one hook per machine; nothing changes in how people use Claude Code.
| You get | |
|---|---|
| Spend | Input, output and cache tokens per turn and session, with estimated cost per model |
| Activity | Prompts, tool calls, shell commands, files written, subagents |
| Context | Developer, project, git branch, pull request, Claude Code version |
| Performance | Turn duration, time to first token, tool duration, errors |
Two ways to connect
| Anosys hook (recommended) | Built-in OpenTelemetry | |
|---|---|---|
| Setup | One install command | Edit ~/.claude/settings.json |
| Data | Full session detail, cost estimates, subagents, redaction | Claude Code's standard OTEL metrics, logs and traces |
| Endpoint type | Claude Code & Codex CLI | OpenTelemetry / AI Agents |
You can run both at once: the installer asks for an optional OTEL key and sets up both.
%%{init: {"flowchart": {"curve": "linear"}}}%%
graph LR
A["Claude Code session"] --> B["Turn ends:<br/>Anosys Stop hook runs"]
B --> C["Reads the new part of<br/>the local transcript"]
C --> D["Optional redaction"]
D --> E["Claude Code & Codex CLI<br/>endpoint"]
Install the Anosys hook
Step 1. Get an API key
Create an endpoint of type Claude Code & Codex CLI (or pick the Claude Code goal during onboarding) and copy its API key from Collecting → Integration Options → API.
Step 2. Install
The installer asks for:
- API key for logs: the key from step 1.
- API key for OTEL (optional): a key from an OpenTelemetry / AI Agents endpoint, to also turn on Claude Code's built-in OTEL export.
- Content redaction: when on, prompts, responses and thinking are replaced with
REDACTEDbefore they leave the machine. Tokens, cost and metadata are still sent.
It then adds an Anosys Stop hook to ~/.claude/settings.json, after saving a backup next to it (settings.json.<timestamp>.bak). Your other hooks and settings are kept.
Step 3. Check it works
Then run a short Claude Code session. The endpoint's activity graph in the console shows calls within seconds.
Install without prompts
For dotfiles, dev containers or a fleet rollout:
| Flag | What it does |
|---|---|
--api-key KEY |
API key for logs |
--otel-key KEY |
Optional API key for OTEL export |
--redaction / --no-redaction |
Turn content redaction on or off |
--auto-update |
Write settings.json without asking |
--no-auto-update |
Print the settings to add by hand instead of writing them |
Commands
| Command | What it does |
|---|---|
anosys-claude-code install |
Add or update the hook (safe to run again) |
anosys-claude-code status |
Show whether the hook is installed and the keys work |
anosys-claude-code uninstall |
Remove the Anosys hook and its settings |
anosys-claude-code run |
What Claude Code calls at the end of a turn. You don't run it yourself. |
With Node.js, use npx -y anosys-sdk-claude-code <command>.
Use the built-in OpenTelemetry export only
If you can't install packages, Claude Code can export its own OpenTelemetry data. Create an endpoint of type OpenTelemetry / AI Agents, copy its base URL from Integration Options → OTEL, and add this to ~/.claude/settings.json:
Restart Claude Code. OTEL_SERVICE_NAME can be any label you want to filter by, for example your team name.
Claude Code Desktop over SSH
When the Claude Code desktop app runs the claude CLI on another machine over SSH (including localhost), install the hook on that machine. Every session started from the desktop app is then tracked the same way as a terminal session.
Hook settings
The installer writes these into the env block of ~/.claude/settings.json. You normally don't touch them.
| Variable | What it does |
|---|---|
ANOSYS_HOOK_APIKEY |
API key for logs |
REDACTION |
true to redact conversation content |
ANOSYS_HOOK_DRY_RUN |
true to print what would be sent instead of sending it |
ANOSYS_ENCRYPTION_KEY |
Optional passphrase to encrypt content fields before sending. See Security and data controls. |
Troubleshooting
Nothing shows up in the console
- Run
anosys-claude-code status. - The hook runs when a turn ends. Finish at least one turn after installing.
- Make sure the key belongs to a Claude Code & Codex CLI endpoint. Keys from other endpoint types are rejected.
- Allow outbound HTTPS to
api.anosys.aion your network. - Check that
~/.claude/settings.jsonis valid JSON.
Does the hook slow Claude Code down?
It runs after each turn, reads only the new part of the transcript, and usually finishes in under a second.
How do I turn redaction on later?
Run anosys-claude-code install --redaction --auto-update. The installer updates the existing hook instead of adding a second one.
How do I roll this out to my whole team?
Use one shared endpoint and the headless install command in your dotfiles or dev container setup. Each session records which developer it came from.
Next steps
- Track AI and coding spend: dashboards and cost alerts across tools
- Codex CLI and Antigravity: the same setup for other coding agents