{"slug": "how-i-stopped-hitting-claude-code-usage-limits", "title": "How I Stopped Hitting Claude Code Usage Limits", "summary": "A developer audited Claude Code's local session logs and found their median session peaked at 252,696 tokens, with 160 of 230 sessions in one week exceeding 150k tokens and the largest reaching 967k. The analysis attributes limit exhaustion to Claude Code re-sending the full conversation on every turn, so cost scales with context size times turn count, and the developer published nine fixes including a status-line gauge script, aggressive /clear use, permission deny rules for lockfiles and node_modules, and trimming CLAUDE.md and MCP tool definitions.", "body_md": "\"You've hit your usage limit.\" I saw that message three times in one week, every time in the middle of a task, with half-written code open in front of me.\n\nSo I stopped guessing and measured. I wrote a small script that reads Claude Code's own session logs on my Mac. The result was embarrassing: **my median session peaked at 252,696 tokens.** 160 of my 230 sessions that week went past 150k. My largest hit 967k.\n\n*Note: I used Claude Code to help build the audit script and draft this post. The numbers and screenshots are from my own machine.*\n\nHere is what was actually eating my limit, and the nine fixes that work. Most of them are free and take five minutes.\n\nClaude Code re-sends the whole conversation to the model on every turn.\n\nYour CLAUDE.md, every MCP tool definition, every file it opened, every test log it printed, every message you sent. Turn 80 pays for turns 1 to 79 again.\n\nSo your limit isn't eaten by your questions. It's eaten by **context size times number of turns**. A session sitting at 200k tokens carries ten times more per turn than one at 20k.\n\nEvery fix below shrinks one of those two numbers.\n\nYou can't manage what you only see when it's too late. Claude Code's status line receives your context percentage and, on Pro and Max, your 5-hour and weekly limit usage. Most people never turn it on.\n\nSave this as `~/.claude/gauge.py`:\n\n``` python\nimport json, sys\nd = json.load(sys.stdin)\nctx = (d.get(\"context_window\") or {}).get(\"used_percentage\") or 0\nrl = d.get(\"rate_limits\") or {}\nfive = (rl.get(\"five_hour\") or {}).get(\"used_percentage\")\nweek = (rl.get(\"seven_day\") or {}).get(\"used_percentage\")\nprint(f\"ctx {ctx:.0f}% | 5h {five or 0:.0f}% | week {week or 0:.0f}%\")\n```\n\nThen add this to `~/.claude/settings.json` and restart:\n\n```\n\"statusLine\": {\"type\": \"command\", \"command\": \"python3 ~/.claude/gauge.py\"}\n```\n\nNow you see the problem building instead of meeting it at 100%.\n\nThis was my biggest leak. 137 of my sessions ran 80+ model turns, because I kept working in the same window all afternoon.\n\nFinished a feature? Run `/clear` before the next one. Mid-task and context is above 60%? Ask Claude to write a short handoff note to a file (goal, what's done, next steps, key files), then `/clear` and point the new session at that note.\n\n**/compact vs /clear:** compacting keeps a summary in the same session. It's fine once. Do it four times and you're dragging a blurry, still-heavy history around. A 40-line handoff plus a clear is cheaper, and you decide what survives.\n\nOne accidental read of a lockfile or a minified bundle can add tens of thousands of tokens that ride along for the rest of the session.\n\nAdd deny rules to your project's `.claude/settings.json`:\n\n```\n{\n  \"permissions\": {\n    \"deny\": [\n      \"Read(./node_modules/**)\", \"Read(./dist/**)\", \"Read(./build/**)\",\n      \"Read(./package-lock.json)\", \"Read(./pnpm-lock.yaml)\", \"Read(./**/*.min.js)\"\n    ]\n  }\n}\n```\n\nAnd name exact places in your prompts. \"Fix the null check in src/lib/auth.ts around getUser\" costs a fraction of \"fix the login bug\".\n\nCLAUDE.md is loaded on every single turn. So is every CLAUDE.md in parent folders, which surprised me: mine was quietly pulling in a 1,800-token file from my home folder.\n\nKeep it to the stack, the commands, where things live, and the few gotchas that bit you before. Move long docs into a docs/ folder and reference them by path. Claude opens them only when it needs them.\n\nEvery MCP server injects its full tool list into context, on every turn. Run `/mcp` and disable what this project doesn't need. Three focused servers beat twelve \"just in case\" ones. The same goes for plugins you installed once and forgot.\n\nPress Shift+Tab for plan mode on anything non-trivial. Fixing a wrong approach after 40k tokens of code costs far more than reading a 2k-token plan and saying \"no, do it this way\".\n\nBatch your asks, too. One message with three clear changes beats three back-and-forth turns that each re-send everything.\n\nUse your heaviest model for design and hard bugs, and switch with `/model` for renames, tests and docs.\n\nSubagents can run on a lighter model too. Add `model: haiku` to an agent's frontmatter in `~/.claude/agents/` and send it the searching and boilerplate. The noise stays out of your main context.\n\nPonytail is a free, MIT-licensed skill that pushes Claude to reuse what exists and skip speculative abstractions, without dropping validation or security. Its published benchmark on real Claude Code tasks shows about 54% less code and about 22% fewer tokens. I've had it on for weeks.\n\nYour feeling about usage is wrong. Mine was. Claude Code keeps every session as a JSONL file under `~/.claude/projects/`, with token counts on every response, so you can measure exactly how big your sessions get.\n\nThat's what my audit script does. It prints what your setup costs before you type a word, then your real session sizes for the week.\n\nDoing all of this by hand on every machine got old, so I turned my setup into a kit. **Full disclosure: I built it and sell it.**\n\nIt has the full limit gauge with colours and reset timers, a hook that blocks junk reads automatically, a /handoff command that saves the note and reloads it after /clear, the audit script, a local cost dashboard, a lean CLAUDE.md template and a 3-page playbook. It installs with one command and uninstalls with one command.\n\nEverything in this article works without it. If you'd rather have it set up in two minutes, it's here: [Claude Code Limit Saver Kit](https://mdayan.gumroad.com/l/claude-limit-saver?utm_source=devto&utm_campaign=usage-limits).\n\nYour limit isn't spent on your questions. It's spent on carrying context. Watch the gauge, clear between tasks, block junk reads, keep CLAUDE.md lean, and measure.\n\nWhat's your worst session? Run the numbers and tell me in the comments. I read every one.\n\n*Originally published on [Medium](https://medium.com/@mdayan8/how-i-stopped-hitting-claude-code-usage-limits-9778e360873f).*", "url": "https://wpnews.pro/news/how-i-stopped-hitting-claude-code-usage-limits", "canonical_source": "https://dev.to/md_ayanbag_03a42545b17ac/how-i-stopped-hitting-claude-code-usage-limits-3cfc", "published_at": "2026-10-24 18:37:04+00:00", "updated_at": "2026-10-24 18:44:31.507357+00:00", "lang": "en", "topics": ["ai-tools", "ai-agents", "developer-tools", "large-language-models"], "entities": ["Claude Code", "Anthropic", "MCP"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/how-i-stopped-hitting-claude-code-usage-limits", "markdown": "https://wpnews.pro/news/how-i-stopped-hitting-claude-code-usage-limits.md", "text": "https://wpnews.pro/news/how-i-stopped-hitting-claude-code-usage-limits.txt", "jsonld": "https://wpnews.pro/news/how-i-stopped-hitting-claude-code-usage-limits.jsonld"}}