cd /news/developer-tools/i-built-a-tool-that-cuts-claude-chat… · home topics developer-tools article
[ARTICLE · art-45671] src=dev.to ↗ pub= topic=developer-tools verified=true sentiment=↑ positive

I built a tool that cuts Claude/ChatGPT token usage by 97% — here's how it works

A developer built ContextOS, a tool that reduces token usage in AI coding assistants like Claude and ChatGPT by up to 97% by scanning repositories and exporting only relevant files. The tool ranks files based on task relevance, import graph centrality, AST symbols, and git churn, then packs them into a context-limited bundle with automatic secret redaction. Tested on the FastAPI repository (2,811 files), ContextOS cut tokens from ~284,000 to ~7,998.

read1 min views1 publishedJun 30, 2026

The Problem

You're debugging a bug. You open Claude. You paste 10 files. You hit the context limit.

Or worse — you paste the wrong files and Claude gives you a useless answer.

This happens because most repos have hundreds of files but you only need 10-15 for any given task.

What I Built

ContextOS — it scans your entire repo, ranks files by relevance to your current task, and exports a perfectly-sized context pack. Secrets are automatically redacted. No cloud. No accounts.

Real Numbers

Tested on FastAPI (2,811 files):

bash
git clone https://github.com/tiangolo/fastapi
cd fastapi
pip install rm-contextos
contextos scan
contextos pack --task "add rate limiting to auth endpoint"

Output:
Without ContextOS : ~284,000 tokens  (2,811 files)
With ContextOS    : ~7,998 tokens    (15 files)
Saved             : ~276,002 tokens  (97% reduction)

How It Works

1. contextos scan — indexes every file: imports, exports, symbols, purpose
2. contextos pack --task "your task" — ranks files using:
  - Keyword matching against your task description
  - Import graph centrality (files imported by many others rank higher)
  - AST symbol extraction (matches function/class names)
  - Git churn scoring (recently modified files rank higher)
3. Fills the token budget greedily, redacts 14 secret patterns, exports

MCP Server

It also runs as an MCP server so Claude Desktop/Code can call it directly:

pip install "rm-contextos[mcp]"
contextos serve --stdio /path/to/project

Claude then has tools: pack_context, list_files, get_file, churn_report.

Install

pip install rm-contextos        # base
pip install "rm-contextos[all]" # + MCP + AST + headroom compression

GitHub: https://github.com/Rohithmatham12/ContextOS
Docs: https://Rohithmatham12.github.io/ContextOS/

Apache-2.0. Fully local. PRs welcome.
── more in #developer-tools 4 stories · sorted by recency
── more on @contextos 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/i-built-a-tool-that-…] indexed:0 read:1min 2026-06-30 ·