{"slug": "i-built-a-tool-that-cuts-claude-chatgpt-token-usage-by-97-here-s-how-it-works", "title": "I built a tool that cuts Claude/ChatGPT token usage by 97% — here's how it works", "summary": "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.", "body_md": "**The Problem**\n\nYou're debugging a bug. You open Claude. You paste 10 files. You hit the context limit.\n\nOr worse — you paste the wrong files and Claude gives you a useless answer.\n\nThis happens because most repos have hundreds of files but you only need 10-15 for any given task.\n\n**What I Built**\n\n**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.\n\n**Real Numbers**\n\nTested on FastAPI (2,811 files):\n\n```\nbash\ngit clone https://github.com/tiangolo/fastapi\ncd fastapi\npip install rm-contextos\ncontextos scan\ncontextos pack --task \"add rate limiting to auth endpoint\"\n\nOutput:\nWithout ContextOS : ~284,000 tokens  (2,811 files)\nWith ContextOS    : ~7,998 tokens    (15 files)\nSaved             : ~276,002 tokens  (97% reduction)\n\nHow It Works\n\n1. contextos scan — indexes every file: imports, exports, symbols, purpose\n2. contextos pack --task \"your task\" — ranks files using:\n  - Keyword matching against your task description\n  - Import graph centrality (files imported by many others rank higher)\n  - AST symbol extraction (matches function/class names)\n  - Git churn scoring (recently modified files rank higher)\n3. Fills the token budget greedily, redacts 14 secret patterns, exports\n\nMCP Server\n\nIt also runs as an MCP server so Claude Desktop/Code can call it directly:\n\npip install \"rm-contextos[mcp]\"\ncontextos serve --stdio /path/to/project\n\nClaude then has tools: pack_context, list_files, get_file, churn_report.\n\nInstall\n\npip install rm-contextos        # base\npip install \"rm-contextos[all]\" # + MCP + AST + headroom compression\n\nGitHub: https://github.com/Rohithmatham12/ContextOS\nDocs: https://Rohithmatham12.github.io/ContextOS/\n\nApache-2.0. Fully local. PRs welcome.\n```\n\n", "url": "https://wpnews.pro/news/i-built-a-tool-that-cuts-claude-chatgpt-token-usage-by-97-here-s-how-it-works", "canonical_source": "https://dev.to/rohith_matam_be6aea5caf13/i-built-a-tool-that-cuts-claudechatgpt-token-usage-by-97-heres-how-it-works-4070", "published_at": "2026-06-30 22:40:10+00:00", "updated_at": "2026-06-30 22:48:35.767723+00:00", "lang": "en", "topics": ["developer-tools", "large-language-models", "artificial-intelligence"], "entities": ["ContextOS", "Claude", "ChatGPT", "FastAPI", "MCP", "Rohithmatham12", "GitHub"], "alternates": {"html": "https://wpnews.pro/news/i-built-a-tool-that-cuts-claude-chatgpt-token-usage-by-97-here-s-how-it-works", "markdown": "https://wpnews.pro/news/i-built-a-tool-that-cuts-claude-chatgpt-token-usage-by-97-here-s-how-it-works.md", "text": "https://wpnews.pro/news/i-built-a-tool-that-cuts-claude-chatgpt-token-usage-by-97-here-s-how-it-works.txt", "jsonld": "https://wpnews.pro/news/i-built-a-tool-that-cuts-claude-chatgpt-token-usage-by-97-here-s-how-it-works.jsonld"}}