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. 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.