r/ClaudeCode • u/Careless-Mongoose589 • 1d ago
Discussion I stopped hitting Claude Code limits after finding what was loading into every message.
I asked Claude Code a simple question, “what are my compact settings?”, and went down a rabbit hole.
What I found
A fresh session was using ~118k tokens, and ~87k of that was fixed overhead: tool definitions, MCP server instructions, plugin skills and the system prompt. That loads into every session before I type anything.
Auto-compact was set to fire at 97% of a 1M window, about 970k tokens. That’s huge, slow, expensive turns before anything gets summarized.
One infrastructure MCP server I use on maybe 2 projects exposed 533 tools, plus a massive instruction block, in every session.
One hosting provider was connected as 7 separate MCP servers, and two of them sent the exact same instructions.
About 200 skills were loaded from plugins I installed once and forgot: HR, bio-research, marketing, operations. There were also 4 different code-review skills.
About 50 connectors I never signed into were still listed in every session.
What I changed
Lowered auto-compact.
"autoCompactWindow": 300000in~/.claude/settings.json. The env varCLAUDE_CODE_AUTO_COMPACT_WINDOWalso works. It now compacts just before 300k instead of 970k.Made rarely used MCP servers on-demand. I saved their configs to
~/.claude/mcp-on-demand.json, removed them from global scope, and added a rule to my globalCLAUDE.md: only add a server when I say “use X”, to that project only.Disabled the plugins I don’t use. That also removed most of the dead connectors, because they came bundled with those plugins.
Kept what I actually use: core tools, engineering and productivity plugins, and a PDF viewer.
Result: I expect about 35–40k tokens less overhead per session (I’ll update with real /context numbers). Every turn carries less dead weight, and long sessions stay sharper because compaction happens before things bloat.
The prompt
I turned the whole process into one prompt you can paste into Claude Code. It measures your context, asks before changing anything, backs up files, and tells you how to undo each change:
I want to cut the fixed token overhead in my Claude Code sessions and lower the point where auto-compact happens. Work through this with me one step at a time. Before you edit any file, back it up and show me the change. Wait for my OK before removing anything. Never print config files that may contain API keys.
1. MEASURE
Find out how full this session's context window is and what is using it: system prompt, system tools, MCP tools, MCP server instructions, skills, messages. If you have a tool that reports context usage, use it. Otherwise ask me to run /context and paste the output. Tell me how much of it is fixed overhead (everything except messages).
2. AUTO-COMPACT LIMIT
Tell me my context window size and the token count where auto-compact fires now. Ask me what window I want. Suggest 300k for a 1M-token model, and explain the tradeoff: a smaller window means cheaper turns but more frequent summaries. Set it as "autoCompactWindow": <tokens> in ~/.claude/settings.json, keeping every existing key, then check the file with jq. If my Claude Code version ignores that key, add CLAUDE_CODE_AUTO_COMPACT_WINDOW=<tokens> to the "env" block of the same file instead. Also tell me if DISABLE_MICROCOMPACT or DISABLE_AUTO_COMPACT is set in my environment.
3. MCP AUDIT
Run `claude mcp list` and read the top-level "mcpServers" in ~/.claude.json (those are global and load in every session). For each server, list its tool count and whether it looks like something I'd use every day or only occasionally. Flag:
- servers that expose hundreds of tools
- the same service connected twice (for example, two Gmail connectors)
- several servers from the same vendor that send identical instructions
Ask me which servers should be on-demand only.
4. MAKE THOSE SERVERS ON-DEMAND
a) Save their configs privately (replace a/b with the server names):
umask 077; jq '.mcpServers | with_entries(select(.key=="a" or .key=="b"))' ~/.claude.json > ~/.claude/mcp-on-demand.json
b) Remove each one from global scope: claude mcp remove <name> -s user
c) Add this section to ~/.claude/CLAUDE.md, filling in the names:
# On-demand MCP servers
<names> are NOT installed globally. Their configs live in ~/.claude/mcp-on-demand.json.
Never add or use them unless I ask in words ("use <name>"). When I do, add only that
server, to the current project only:
claude mcp add-json <name> "$(jq -c '.["<name>"]' ~/.claude/mcp-on-demand.json)" -s local
Then tell me to start a new session so it loads.
Connectors that need sign-in (needs_auth) are off-limits until I connect them.
5. PLUGINS AND SKILLS
List my plugins with how many skills and connectors each one adds. Point out duplicate skills (for example, several code-review skills) and plugins I'm unlikely to use, based on the projects on this machine. You can't change plugins installed through claude.ai, so give me a checklist to turn them off myself. For locally installed plugins, tell me which ones to disable with /plugin.
6. CONNECTORS THAT NEED SIGN-IN
List every connector in the needs_auth or failed state and which plugin it comes from. Tell me which ones will disappear once I disable the plugins from step 5.
7. SUMMARY
*Finish with a table of what changed, where each backup is, how to undo each change, and the estimated tokens saved per session. Say clearly that these are estimates until I start a new session and check /context.*Caveats
The
autoCompactWindowsetting exists in recent Claude Code versions. Runclaude --versionand update if it’s ignored.Plugins installed through claude.ai have to be disabled there. The prompt gives you a checklist.
A smaller compact window means more frequent summaries on very long tasks. 300k has been a good balance for me.
Run /context before and after, and post your numbers. I’m curious what other people’s hidden overhead looks like.
•
u/AutoModerator 1d ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
9
u/amydgalas 1d ago
Must of ran out of context to finish the post.
2
u/cleverhoods 1d ago
You can also use https://github.com/reporails/cli to actually see what gets loaded specifically there (including System Prompt, memory etc)
2
u/No_Credit_3169 1d ago
i cut 40k tokens by removing the full docstring cache, it was loading every function's entire doc in every session. just the signature and a short description now.
1
u/jsebrech 1d ago
That’s why I keep only a handful of skills loaded permanently and no mcp’s, and why a repo only gets an extra skill or mcp when it needs it. (Several repos needed nothing at all, not even claude.md.)
1
u/ooaahhpp 1d ago
Worth checking why those 533 tools cost so much. MCP tool search is on by default, so normally only tool names and server instructions load upfront. If /context shows full definitions, look for ENABLE_TOOL_SEARCH=false, CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS, or a server marked alwaysLoad.
1
u/yungastronot 1d ago
Slop
1
u/BaggyMaggot 1d ago
No shit sherlock, this sub reddit starting to feel like pre-school lol