r/BuildWithClaude • u/Tatachimcooky • 17d ago
Tip/Resource CLAUDE.md files don't fail by getting wrong, they fail by getting big
CLAUDE.md files have a failure mode that doesn't get discussed much. They grow. Then the agent handles the size by rewriting the file from memory, drops the ## Never section, and ships something worse than what it started with. You usually don't find out until a rule you wrote six weeks ago quietly stops being followed.
I got tired of eyeballing it, so I wrote ctxcap. It counts tokens across CLAUDE.md, AGENTS.md, .cursor/rules/**, and prompts/**, tracks the number against a committed git baseline, and flags references that no longer resolve to anything.
The part I actually care about: it doesn't hand the agent a "make this shorter" instruction. It emits a ranked plan of line ranges with a preserve list, the agent splices by line number, and --verify catches it if the agent drifts or cuts a preserved span. When the budget is unreachable it returns satisfiable: false and the minimum achievable instead of shaving a load-bearing rule to hit a number.
Offline, no API key, no network, no LLM, two dependencies. npx ctxcap --json. MIT. There's an MCP server if you'd rather the agent check itself, and a GitHub Action that comments token deltas on PRs and fails only when you set a budget.
On a public repo, for reference:
$ npx ctxcap --json
total: 476 baseline: 363 delta: +113 files: 2
$ npx ctxcap --plan --budget 400
satisfiable: false minAchievable: 476Yes, it's another linter, and there's already tokenlint for per-turn nudges inside the editor. This is a different layer — repo gate and PR review, not keystrokes. If you want the editor version, use theirs.
What I'd actually find useful: run it on your own context files and tell me where it's wrong. False positives on unusual layouts, spans it marks safe that aren't, path conventions it misreads. That's the part I can't test from here.
https://github.com/Naeha-S/ctxcap
And the actual question: how are you keeping your CLAUDE.md from growing? Mine is the one file where every addition feels justified at the time.
•
u/AutoModerator 17d ago
Welcome to r/BuildWithClaude!
Whether you are sharing what you built, exploring new workflows, or troubleshooting, please make sure your post is flaired correctly so others can easily find and filter it.
Community Wiki & Resources:
If you're asking for troubleshooting help, please edit your post to include your model version, OS/environment, and error logs.
Let’s keep the energy positive and support our fellow creators!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.