ctxlens: Open-Source CLI Tool That Measures Codebase Token Usage Across AI Models
A developer built ctxlens, a command-line utility that analyzes how many tokens a codebase consumes relative to the context limits of 23 AI models across 7 providers. The tool, inspired by the Unix 'du' disk-usage command, ranks files and directories by token count, helping developers identify which files consume the most context budget. Additional features include a diff command to estimate token savings from stripping comments, a CI flag for automated budget gating, and a watch mode for real-time monitoring. The creator developed it in early 2025 while working with local Ollama models and Codex, where hitting context limits was a frequent problem. Though the author notes reduced personal use since frontier models now offer larger context windows, the tool remains potentially useful for developers running local LLMs with limited context capacity.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in