At a glance
WHAT IT’S REALLY ABOUT
Optimize Claude Code memory using compaction, clearing, tools, subagents
- Claude’s context window is finite and fills up with prompts, file reads, tool calls, and tool results, so active optimization is necessary.
- Automatic or manual compaction (/compact) summarizes prior work and removes unnecessary tool outputs to free space, but it may lose some detail.
- Use /clear to fully reset when switching to a new feature to avoid bias from prior work, and use /context to inspect what’s consuming memory.
- Persist cross-session knowledge in claude.md so Claude doesn’t need to rediscover project facts repeatedly.
- Reduce avoidable context usage by being explicit in prompts, disabling unrelated MCP servers, using skills for lighter tool loading, and delegating research-like tasks to subagents with separate context.
IDEAS WORTH REMEMBERING
5 ideasTreat context like scarce RAM: every interaction consumes it.
Prompts, file reads, tool calls, and their results all add to the context window, so long sessions can hit limits unless you manage what’s retained.
Use /compact when you must continue a feature but are running out of context.
Compaction summarizes what matters and drops low-value tool outputs, freeing space while preserving a workable memory of the current effort.
Use /clear when starting a new feature to prevent carryover bias.
Clearing removes prior conversation state entirely, which helps ensure the next feature’s approach isn’t influenced by outdated assumptions or irrelevant history.
Check /context to identify the biggest context “spenders.”
The context view provides size, category breakdowns, and a visual overview so you can target what to trim or avoid generating further.
Put durable, reusable facts in claude.md instead of re-teaching them every session.
Storing stable project knowledge (conventions, architecture notes, key commands) reduces repeated exploration and keeps future sessions efficient.
WORDS WORTH SAVING
5 quotesContext is Claude's working memory. Every file it reads, every command it runs, every message you send, it all takes up space in the context window.
— Unknown
And since there's only a finite amount you can put in the context window, it becomes extremely important to optimize this as much as possible.
— Unknown
Compaction will summarize important details and remove the unnecessary tool call results and free up a lot of space in your context window.
— Unknown
You don't want the previous conversation to present bias in anything new that you want to create.
— Unknown
The irony behind writing a smaller prompt is that i- in the long run, it will take up more context.
— Unknown
High quality AI-generated summary created from speaker-labeled transcript.
