Skip to content

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

pip install anosys-claude-code
anosys-claude-code install
npx -y anosys-sdk-claude-code install

The installer asks for:

  1. API key for logs: the key from step 1.
  2. API key for OTEL (optional): a key from an OpenTelemetry / AI Agents endpoint, to also turn on Claude Code's built-in OTEL export.
  3. Content redaction: when on, prompts, responses and thinking are replaced with REDACTED before 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

anosys-claude-code status        # or: npx -y anosys-sdk-claude-code status

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:

1
2
3
4
5
anosys-claude-code install \
  --api-key "YOUR_LOGS_KEY" \
  --otel-key "YOUR_OTEL_KEY" \
  --redaction \
  --auto-update
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:

{
  "env": {
    "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
    "OTEL_SERVICE_NAME": "claude-code",
    "OTEL_TRACES_EXPORTER": "otlp",
    "OTEL_METRICS_EXPORTER": "otlp",
    "OTEL_LOGS_EXPORTER": "otlp",
    "OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf",
    "OTEL_EXPORTER_OTLP_ENDPOINT": "YOUR_ANOSYS_OTEL_URL"
  }
}

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.ai on your network.
  • Check that ~/.claude/settings.json is 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