cost-xray — CLI for Claude Code and Codex

Shows what Claude Code and Codex actually send to the API: it captures local traffic and splits tokens and cost by source

Install in Claude Code and Codex

Manual install

curl -fsSL https://raw.githubusercontent.com/tigerless-labs/cost-xray/master/install.sh | bash

A script from the internet: read it before running. Then open a new terminal and run claude or codex as usual.

Access and checks

How we review

Broad access. The tool can change data, run commands or handle secrets.

  • Intercepts all of the agent's API traffic, including prompts and file contents
  • Runs as a background service with autostart
  • Installing by an internet script runs someone else's code

This is third-party code. Review the repository files before installing.

What it does

cost-xray captures the agent's local API traffic through mitmproxy and splits tokens and cost by source inside a request: system prompts, tool schemas, MCP blocks and tool results. You view the result in the `cx` panel. No API keys or account are needed, and the agent's settings do not change: capture runs as a transparent local proxy. It runs as a background service with autostart on macOS and Linux. Only new sessions are captured: already running ones are not visible.

Who it is for. For people who pay for Claude Code or Codex and want to understand where tokens go: into extra tool schemas, long system prompts or command results.

Good fit when

  • The agent bill grew and you need to find which part of a request costs the most
  • You need to check how many tokens the connected MCP servers eat
  • You need to compare the cost of different sessions by source

Not a fit when

  • You cannot route the agent's traffic through a local proxy: the utility sees the whole request
  • You work on Windows: the README names macOS and Linux

Example request

Show which part of the latest Claude Code request went to MCP server schemas and calculate what that costs per day

Limitations

The utility intercepts all of the agent's API traffic, including prompts and file contents that go into requests. Per the README the data is stored locally, but check this yourself. Installing with `curl ... | bash` runs a script from the internet: read it before running. The script asks which agents to capture, and you can answer in advance with the `COST_XRAY_AGENTS` variable (claude, codex or all). After installation open a new terminal and run the agent as usual. Claude Code or Codex and macOS or Linux are required.

How to disable. Stop the cost-xray background service, remove autostart and the utility files per the README instructions, then open a new terminal.

FAQ

What does cost-xray do?

It captures the local API traffic of Claude Code and Codex and splits tokens and cost by source inside a request.

Are keys or an account needed?

No, API keys and an account are not needed and the agent's settings do not change.

Does the utility see my prompts?

Yes, it intercepts all of the agent's traffic. Per the README the data is stored locally, but check this yourself.

Are already running sessions captured?

No, only new ones: open a new terminal after installation.

How do I install cost-xray?

Run curl -fsSL https://raw.githubusercontent.com/tigerless-labs/cost-xray/master/install.sh | bash in a terminal.

Which agents does cost-xray work with?

cost-xray works in Claude Code and Codex.

Discussion

No questions or reviews yet.

Comparison with similar tools

Cards that share the main search query, and how they differ.

ToolOfficialRepository starsMain difference
cost-xray (this card)no5,375
Token Optimizerno3,179a plugin that trims wasted tokens and keeps work across sessions
Token Monitorno3,939a desktop widget tracking tokens, cost and limits for many tools
Claude Usageno2,331a local dashboard over Claude Code logs: tokens, models, sessions and projects

README in short

The README describes a utility that captures the local API traffic of Claude Code and Codex through mitmproxy and shows a token and cost breakdown in the cx panel. Installation by script, run as a service, macOS and Linux only. MIT license.

README badge

Report a problem