{"slug": "making-a-bloated-claude-code-fast-again-auditing-context-injection-down-from-to", "title": "Making a Bloated Claude Code Fast Again: Auditing Context Injection Down From 228KB to 48KB", "summary": "A developer audited Claude Code's context injection, finding that bloated rules directories caused session slowdowns and dropped instructions. By removing unused language rules, they reduced injection size from 228KB to 48KB, a 79% improvement.", "body_md": "Last time, I wrote about [teaching Claude Code to write and grow its own skills](https://zenn.dev/bokuwalily/articles/self-growing-skills). Once you start piling on skills and plugins, there's one wall you're guaranteed to hit eventually: **sessions get heavy and instructions start slipping through the cracks**. This is the record of an audit where I measured the cause and **trimmed context injection from 228KB down to 48KB**.\n\nAt some point, Claude Code started behaving like this:\n\nAt first I assumed it was \"the model having an off day.\" It wasn't. The real cause was that **the context injected at SessionStart had ballooned so much that the user's most recent instructions were getting buried**. The bigger the injection, the more the relative presence of the latest part of the conversation gets diluted.\n\nThe important distinction the audit revealed was this.\n\n| Symptom | The real culprit | Fix |\n|---|---|---|\nSession is just heavy\n|\nNumber of enabled plugins |\n`disable` unused plugins |\nDrops recent instructions / conversation cross-wires |\nTotal injection volume |\nMeasure injection sources and prune them |\n\nIf you lump \"heavy\" and \"foggy\" together, you'll keep cutting plugins with nothing to show for it. The real driver of the \"foggy\" problem lives somewhere else.\n\nThere are multiple injection sources: plugin metadata, `rules/`\n\n, the Obsidian context, auto-memory, and the remember history. I **measure each source empirically**. You can roughly estimate tokens as \"byte count ÷ 4 ≒ English tokens.\"\n\n```\n# Everything under rules/ is auto-loaded in full as \"global instructions\" (no cap)\nfind ~/.claude/rules/ecc -name '*.md' -exec cat {} + | wc -c\n\n# auto-memory (MEMORY.md is injected in full)\nwc -c ~/.claude/projects/*/memory/MEMORY.md\n\n# remember history (now/recent/archive are injection targets)\nwc -c ~/.remember/now.md ~/.remember/recent.md ~/.remember/archive.md\n```\n\nOnce I measured, the culprit was obvious. ** rules/ecc alone accounted for about 57K tokens (≒228KB)** — by far the single largest block of the entire injection.\n\n`rules/`\n\nso heavy?\nThis was the biggest trap. Everything under `~/.claude/rules/`\n\nis **not** read on demand via `@import`\n\n— **Claude Code loads the entire directory in full, every time, as global instructions**.\n\nMy `rules/ecc`\n\n, inherited from a general-purpose rule pack, contained rules for **10 languages** wholesale (angular / golang / swift / php / ruby / arkts / java / kotlin …). **The only languages I actually write are Python / TypeScript / Web — three** — yet coding conventions for languages I never touch, like Swift and Ruby, were being injected in full every single session.\n\nBecause `rules/`\n\nis a directory load rather than `@import`\n\n, **you don't need to touch any import lines. Just mv the files outside the tree and the injection stops**. And when you want them back, you just\n\n`mv`\n\nthem back — \n\n```\n# Keep only the languages I use (common/python/typescript/web); move the rest out of the tree\nA=\"$HOME/.claude/.rules-archive/ecc\"; mkdir -p \"$A\"\ncd ~/.claude/rules/ecc\nfor d in angular arkts cpp csharp dart fsharp golang java kotlin perl php ruby rust swift zh; do\n  [ -d \"$d\" ] && mv \"$d\" \"$A/\"\ndone\n# To restore, bring them back one at a time: mv \"$A/rust\" ~/.claude/rules/ecc/\n```\n\nNote\n\nEven a hidden directory (`.rules-archive`\n\n) risks being loaded by mistake if you put itinsidethe`rules/`\n\ntree. The archive destination must always beoutsidethe tree.\n\nAfter trimming, I re-measured the current `rules/ecc`\n\nand got this:\n\n``` bash\n$ find ~/.claude/rules/ecc -name '*.md' -exec cat {} + | wc -c\n48092\n$ ls -d ~/.claude/rules/ecc/*/ | xargs -n1 basename\ncommon\npython\ntypescript\nweb\n```\n\n**228KB (≒57K tokens) → 48KB (≒12K tokens). About a 79% reduction.** The directory count dropped from 10 languages to 4. When I open a new session, startup is lighter, and dropped recent instructions have clearly decreased.\n\nAt first, Obsidian's `hot.md`\n\nhad grown to 32KB, so I thought \"deleting this will make things lighter.\" **I was wrong.** The Obsidian context is already capped on the injection-script side at `hot.md=9000 chars / index=2500 chars`\n\n, so no matter how many KB the file balloons to, **the injected volume stays constant at about 7K tokens**.\n\nLikewise, remember's `today-*.done.md`\n\nisn't an injection target either. Deleting those is **disk tidying — it doesn't shave off a single bit of tokens**. \"Big file = heavy injection\" simply doesn't hold, so always measure the injection sources empirically.\n\nYou might think, \"On the MAX plan, $/token is a flat rate, so who cares?\" On the cost side, that's true. But the real benefit of the reduction is elsewhere.\n\nIf you're cutting plugins, `enabled: true→false`\n\nin `settings.json`\n\ncan be rolled back instantly. `claude plugin uninstall`\n\nreclaims it from disk, so it's irreversible. **You should start with disable and see how it goes.** That said, disabling a plugin makes its slash commands error out, so keep the rarely-used-but-important commands around.\n\n`~/.claude/rules/`\n\nis `@import`\n\n`mv`\n\n-ing files outside the tree. Rollback is `mv`\n\ntooNext time, I'll write about [the launchd setup I built to run all of this automation around the clock](https://zenn.dev/bokuwalily/articles/launchd-traps) — and the macOS-specific traps I hit along the way.\n\n*Written by **Lily** — I ship iOS apps and automate my content stack with Claude Code.\n\nFollow along: [Portfolio](https://bokuwalily.com) · [X](https://x.com/bokuwalily) · [GitHub](https://github.com/bokuwalily)*", "url": "https://wpnews.pro/news/making-a-bloated-claude-code-fast-again-auditing-context-injection-down-from-to", "canonical_source": "https://dev.to/bokuwalily/making-a-bloated-claude-code-fast-again-auditing-context-injection-down-from-228kb-to-48kb-1644", "published_at": "2026-07-11 05:00:03+00:00", "updated_at": "2026-07-11 05:11:04.174360+00:00", "lang": "en", "topics": ["developer-tools", "large-language-models", "ai-tools"], "entities": ["Claude Code", "Anthropic"], "alternates": {"html": "https://wpnews.pro/news/making-a-bloated-claude-code-fast-again-auditing-context-injection-down-from-to", "markdown": "https://wpnews.pro/news/making-a-bloated-claude-code-fast-again-auditing-context-injection-down-from-to.md", "text": "https://wpnews.pro/news/making-a-bloated-claude-code-fast-again-auditing-context-injection-down-from-to.txt", "jsonld": "https://wpnews.pro/news/making-a-bloated-claude-code-fast-again-auditing-context-injection-down-from-to.jsonld"}}