ctxray · a free CLI that counts your repo's AI tokens and cuts the cost
Your repo bills you every time an agent reads it.
ctxray counts your codebase in tokens, prices it on every model, shows which files cost money without teaching the agent anything, and writes the ignore file that removes them.
No install, no config, no dependencies, no network calls. Node 18+. MIT.
ctxray · ~/code/api 1,204 files · 8.2 MB · scanned in 210ms CONTEXT WEIGHT 627k tokens if an agent ingested this whole repo █ 275k signal (44%) █ 352k waste (56%) GRADE F Severe. The agent is mostly reading noise. COST OF ONE FULL-CONTEXT PASS (prices checked 2026-11-11) Claude Opus 5.5 $2.51 $1.41 of it wasted Claude Sonnet 5.5 $1.25 $0.704 of it wasted GPT-5 class $3.14 $1.76 of it wasted ⚠ exceeds context window WORST OFFENDERS 181k tok package-lock.json Dependency lockfile. The manifest says the same thing 41k tok test/fixtures/dump.json Bulk data. Send a schema and 3 sample rows instead 22k tok dist/vendor.min.js Minified bundle. Maximum tokens, minimum meaning
Find it free. Keep it fixed with Pro.
Everything that finds waste is free and open source, and stays that way. Pro is the part you share with a team and wire into CI, so a cleanup does not drift back within a quarter.
npx github:geraltbhai/ctxrayMeasure
Tokens per file, cost per model, a grade, and 14 categories of content an agent cannot use.
ctxray initFix
Writes .agentignore and a starter AGENTS.md from the repo's real shape.
ctxray diffHold the line · Pro
A pull-request comment showing what each change did to the context budget.
ctxray budget 100kPack · Pro
Given a window size, picks the highest-value files that fit, ranked by value per token.
Free vs Pro
| Feature | Free | Pro |
|---|---|---|
| Full scan, token counts, cost on every model | yes | yes |
| Waste and duplicate detection | yes | yes |
init, audit, badges, JSON, programmatic API | yes | yes |
--html shareable report (see one) | — | yes |
diff PR comments and baselines | — | yes |
budget context packer | — | yes |
--ci thresholds, annotations, exit codes | — | yes |
| Commercial use in CI | — | yes |
Pricing
A subscription, because the part that goes stale is the price table. Between August and November 2026, Anthropic alone replaced three models with new ones at new prices. The subscription pays for prices, tokenizer calibration and waste rules being rechecked every month.
Free
- The whole scanner
- Ignore file and AGENTS.md generator
- Badges and JSON output
- MIT licence
Pro
- HTML report, diff, budget, CI mode
- Monthly price and rule updates
- One developer
- Cancel any time
Team
- Everything in Pro
- Whole organisation, CI included
- One key for every repo
- Cancel any time
Questions
What happens when I cancel?
Your key works until the end of the period you paid for, plus five days. After that the Pro commands stop and the free scanner keeps working exactly as before. Nothing is deleted and nothing phones home.
Does it send my code anywhere?
No. ctxray makes no network calls, free or Pro. The licence check is an offline signature check on your machine.
How accurate is the token count?
It uses a built-in estimator fitted against a real tokenizer, with about 6% median error. That is enough to rank files and price a repo; the README shows the calibration method.
Can the licence check be bypassed?
Yes, trivially, and the source says so. It exists to make paying the obvious path for people who find the tool useful, not to fight anyone.