← Back to Leaderboard
Ctigerless-labs

tigerless-labs/cost-xray

Local proxy for tracing coding-agent context, cache usage, and API cost

View on GitHub ↗
Engineering Health (Methodology)
B+ · 73/100
Maintenance Activity
● Updated 22d ago
Latest Release
Rolling commits (main)
Commercial License Check
MIT · Commercial Friendly

Automated SPDX check for reference only — not legal advice. Disclaimer

Maintenance31/35
Fork Adoption16/25
Release Cadence6/20
License Clarity20/20
Self-HostedCLI
Total Stars
★ 5,441
24h Growth
+0
7d Growth
+209
Forks
353

GitHub Star History

Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.

tigerless-labs/cost-xray Star History (2026-06-09 - 2026-12-04) ALL-TIME STAR HISTORY (2026-06 – 2026-12) +5.4k in 178d · avg +31/day 5.7k 2.9k 0 2026-06-09: ★ 12026-06-20: ★ 382026-07-04: ★ 1612026-07-18: ★ 2412026-08-01: ★ 3392026-08-15: ★ 4612026-08-29: ★ 6092026-09-12: ★ 1,3662026-09-26: ★ 2,3722026-10-10: ★ 4,0242026-10-24: ★ 5,2212026-11-04: ★ 5,2272026-11-15: ★ 5,2312026-11-26: ★ 5,2322026-12-04: ★ 5,441 ★ 5.4k 06-09 09-06 12-04

Evidence-Backed Technical Brief

AI Deep Review

Architecture & Core Mechanics

cost-xray sits between a coding agent and its model API. Claude Code uses a reverse proxy via a base-URL override and needs no local CA. Codex uses a forward proxy with a local CA scoped to the wrapped command rather than installed in the system trust store. Thin per-agent adapters handle the Anthropic and OpenAI Responses wire formats; capture and analysis share the rest of the pipeline.

The Python stack uses mitmproxy (>=10) for capture, tiktoken (>=0.7) for token estimation, and Rich (>=13) for terminal rendering. The proxy binds to 127.0.0.1, redacts traffic before writing to ~/.cost-xray/sessions/, and leaves tokenization and pricing to a separate materializer. Captured records are the source for rebuilding views: repeated blocks are stored once and per-turn deltas reconstruct the redacted exchanges.

Key Capabilities & Differentiators

The terminal UI drills from agent, project, and session into source category, MCP server, tool, individual invocation, and captured result. It separates fresh input, cache reads, cache writes, and output costs while also showing context occupancy. That distinction matters: a cached schema can be cheap to read yet still consume a large share of the window. The tool flags schemas injected into the prefix whose tools were never called in the observed session.

For Claude, tiktoken provides initial sizes, with targeted corrections for thinking blocks and tool schemas. Those corrections use count_tokens when authenticated and fixed ratios otherwise; the estimates are reconciled to provider-reported usage. Pricing uses LiteLLM data. Provider counts anchor the request total, but the allocation among sources remains approximate. Full count_tokens differencing is planned, not a current feature.

Trade-offs & Limitations

Compared with ccusage or codeburn, cost-xray trades transcript-only setup and historical coverage for visibility into fields assembled at request time. It can expose system prompts, injected schemas, and cache behavior that transcripts miss, but it cannot backfill uncaptured sessions. The wrapper attempts to recover a failed proxy and falls back to a direct connection when it cannot: the agent keeps working, but the capture can have gaps.

Loopback binding, pre-write redaction, and no telemetry reduce exposure without making captured content harmless. Prompts and tool results can still contain source code or sensitive text, and cx uninstall retains the archive. For team use, define access and retention for local captures. Keeping analysis off the relay path also does not eliminate the proxy hop or capture writes, and calibrated Claude source splits are diagnostic estimates rather than invoice line items.

Hardware & Deployment Guide

Run it self-hosted on macOS or Linux with Python 3.10+ and an existing Claude Code or Codex installation. A checkout includes install.sh; the installer can select either agent or both, with COST_XRAY_AGENTS=claude|codex|all for unattended selection. Open a new terminal after setup, launch the agent normally, then use cx for the live TUI. The observer needs no separate account or API key; the agent still uses its normal upstream credentials and connection.

Use cx status to check service state, ports, and session counts; cx stop pauses capture, and cx start resumes it. Edit ~/.cost-xray/env and run cx restart to change port or upstream settings. Linux setup covers systemd and a manual path. No GPU is needed; size CPU and disk for tokenization and retained captures. Package metadata lists version 0.1.0 as beta, with no tagged release listed.

Capture: Claude Code uses a base-URL override; Codex uses a forward proxy with command-scoped CA trust.
Processing: mitmproxy records redacted traffic; a separate materializer tokenizes and prices it.
Attribution: The TUI breaks out fresh input, cache reads, cache writes, and output down to individual tool calls.
Context occupancy: Identify MCP schemas injected on every turn even when their tools are never called.
Calibration: Claude source estimates are reconciled to provider usage; matching the total does not make the split exact.
Storage: Repeated messages, schemas, and tool results are stored once and reconstructed with per-turn deltas.
Best For

Claude Code or Codex users tuning MCP configuration, investigating context pressure, or tracing costs to a particular schema or tool result.

Skip If

You only need historical spend rollups, cannot retain request content or use Codex's scoped CA, or require exact per-source Claude billing.

Reviewed on 2026-12-04 · Grounded in GitHub README, root file tree & releasesMethodology

Quick Start & Installation

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

Comparison vs. Top Coding, Skills & MCP Alternatives

Full comparison →
RepositoryStars7d TrendStackLicenseCore Positioning
cost-xray ★5.4k+209PythonMITLocal proxy for tracing coding-agent context, cache usage, and API cost
cc-switch159.1k+1.7kRustMITTauri desktop manager for AI coding providers, local routing, and MCP config
herdr54.1k+871RustApache-2.0Rust terminal multiplexer for persistent, multi-machine coding-agent workspaces
claude-code-router38.5k+101TypeScriptMITLocal model gateway for routing coding agents across providers

AI Context Briefing (for Claude / Cursor / Windsurf)

Standardized architecture summary & quickstart commands ready to paste into coding agents.

Raw .md ↗
curl -sL https://repoforai.com/repo/tigerless-labs/cost-xray.md

Embed Star History Chart & Badges in README.md

Full-history Star History SVGs and velocity cards on GitHub Camo: drop-in replacement for OSSInsight and Star History widgets.

tigerless-labs/cost-xray Star History on RepoForAI

Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).

Frequently Asked Questions about cost-xray

How does cost-xray integrate with Claude Code and Codex?

Claude Code is routed through a local reverse proxy using a base-URL override; it needs no local CA. Codex uses a forward proxy and a local CA scoped to the Codex command, not the system trust store. Capture starts with new wrapped runs and does not backfill old sessions. If the proxy cannot be restored, the agent runs directly and that traffic is not recorded.

Does it need a GPU, and what drives local resource usage?

No GPU or VRAM is required for the observer: the model still runs behind the upstream API. Budget CPU for local tokenization and rebuilding views, and disk for retained redacted captures. Deduplication reduces repeated blocks, but long sessions with large, unique tool outputs still grow the archive; size it using representative sessions.

Can a company self-host it, and what data controls are still needed?

The MIT license allows commercial and self-hosted use subject to its notice requirements. That permission does not override provider terms or internal data-handling rules. The proxy binds to loopback and redacts credentials before writing, but captures can still contain proprietary code and sensitive tool outputs. Set access and retention rules for ~/.cost-xray/; uninstalling does not delete it.

When is cost-xray a better fit than ccusage or codeburn?

Keep ccusage or codeburn if you mainly need historical spend by session, model, or day without changing the request path. Use cost-xray when you need to diagnose request-time overhead, such as an unused MCP schema consuming context on every turn or one tool call returning a large result. Treat Claude's source-level allocations as estimates, not separate billing line items.

Upstream README & Documentation

This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.

Maintaining tigerless-labs/cost-xray? Pin to Homepage + competitor /alternatives pages with a custom Cloud/Demo CTA.Feature tigerless-labs/cost-xray on Homepage & Alternatives ($19)
WEEKLY BREAKOUT DIGEST

Top 10 Breakout Open-Source AI Repos, Every Thursday

Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.

Zero spam · 1-click unsubscribe · Privacy Policy

Saved in your browser · Export Markdown RFC tables or jump into /vs compare