Keep Your Context Window Clean
Claude Code has a large context window, but it's not infinite. A few habits will keep it working efficiently.
Instead of reading 20 files yourself, let a subagent do the research in a separate context:
"Search the codebase for how authentication is implemented"
Claude will spawn an Explore agent that reads files in its own context, then returns a summary — keeping your main window clean.
Be specific about what you need. Instead of "Look at the User model", try:
"What validation rules does the User model use for email?"
Use /clear or start a new session when switching to unrelated work. A conversation about database migrations doesn't need the context from your CSS refactor.
You can also create a .claudeignore file to exclude directories Claude doesn't need to read:
node_modules/
vendor/
storage/
.git/
public/build/
The key principle: a focused context gives better answers than a cluttered one.
Log in to leave a comment.
When Claude starts referencing files you've since deleted, remembering old code you've already changed, or getting confused by contradictory instructions from a long session — type /clear to wipe the slate clean. Unlike /compact which preserves context, /clear gives you a true fresh start without restarting the CLI.
Not every task needs deep reasoning. Type /fast to switch Claude Code into fast mode — same model, faster output — for quick edits, simple questions, and routine changes. Toggle it off when you need Claude to think harder on complex problems.
Long sessions eat through your context window as conversation history piles up. Type /compact to summarize the conversation so far and reclaim space — keeping Claude's understanding of what you're working on while freeing up room for more work.