The Quick Answer
Clear context between tasks with /clear
. Monitor the context meter and /compact
at 70% capacity. Use CLAUDE.md files for persistent memory instead of repeating instructions. Write design docs and task lists to markdown files that Claude can reference. Start new conversations for unrelated work. Natural language beats complex commands: "fix the type errors" instead of listing each file.
Essential Commands
/clear
- Reset context when switching tasks
$> /clear$Context cleared. Starting fresh.
[Screenshot: Claude Code showing context meter before and after /clear]
/compact
- Compress conversation history
$> /compact$Compacting conversation history...$Context reduced from 120k to 30k tokens.
/usage
- Check token usage and costs
$> /usage$Session: 45,231 tokens (~$0.68)$Daily: 892,450 tokens (~$13.39)
Natural language for context awareness
$> # Remember: our API uses snake_case not camelCase$I'll keep that in mind. Should I save this to CLAUDE.md?
Power User Tips
1. Strategic Context Management
Think of Claude's context like a fast intern's working memory. Too much clutter slows them down.
Monitor actively: Watch the context meter (bottom right). At 70%, it's time to act:
$> Just finished the auth feature. Time to /compact before starting payments
Clear at natural breakpoints:
- After completing a feature
- Before starting unrelated work
- After making a commit
- When switching between frontend/backend
2. CLAUDE.md as Persistent Memory
Project memory (./CLAUDE.md):
# Project Context
## Code Style
- Use snake_case for API endpoints
- 2-space indentation for TypeScript
- Prefer composition over inheritance
## Build Commands
- Development: `pnpm dev`
- Type check: `pnpm typecheck`
- Tests: `pnpm test`
User memory (~/.claude/CLAUDE.md):
# Personal Preferences
- Use UK spelling in all documentation
- Prefer functional components in React
- Always add JSDoc comments for public APIs
3. Scratchpad Pattern
Offload context to markdown files:
$> Create a file called 'refactor-plan.md' to track our database migration$I'll create a refactor plan document to track our progress.$> Update refactor-plan.md with what we just completed
[Screenshot: Claude Code editing a markdown scratchpad file]
4. Thinking Budget Control
Use specific phrases to control Claude's computation time:
- "think" - Standard analysis
- "think hard" - Deeper evaluation
- "think harder" - Complex problem solving
- "ultrathink" - Maximum computation
$> think hard about the performance implications of this approach
Workflow Examples
Large Refactoring Project
$> /clear$> Create a file 'lint-fixes.md' with all ESLint errors as a checklist$I'll analyze the codebase and create a comprehensive checklist.$> Work through lint-fixes.md systematically, updating it as you go$[Claude processes each item, marking completed in the file]
Bug Investigation with Limited Context
$> The app crashes on user logout. Here's the error log$I'll investigate this logout crash. Let me start by examining the relevant files.$> @auth/logout.ts @hooks/useAuth.ts # Add specific files
Context-Efficient PR Review
$> cat pr-diff.txt | claude# or$> Review changes in PR #234 focusing on security implications
Troubleshooting
Context Limit Warnings
Symptom: "Context window 90% full" warning
Quick fix:
$> /compact# If still too full:$> Save current state to 'session-notes.md' then /clear
Performance Degradation
Symptom: Claude responds slowly, misses obvious patterns
Solution:
$> /clear$> @important-context.md # Re-add only essential context$> Continue with the database optimization
Lost Context After Compaction
Symptom: Claude forgets previous corrections or decisions
Prevention:
$> Update CLAUDE.md: never use .forEach() for async operations$I've updated CLAUDE.md with this coding standard.
Session State Management
Save session state:
$> Write a summary of our progress to 'session-2025-01-17.md'
Resume efficiently:
$> /clear$> @session-2025-01-17.md$> Let's continue where we left off
Common Mistakes to Avoid
❌ Wrong: Letting context fill up naturally ✅ Right: Proactively manage at 70% capacity
❌ Wrong: "Fix the error in the auth component" ✅ Right: "Fix the TypeScript error in LoginForm.tsx where user might be undefined"
❌ Wrong: Repeating the same instructions every session ✅ Right: Add persistent rules to CLAUDE.md
❌ Wrong: One long session for multiple features ✅ Right: Clear between features or use separate sessions
Pro Tips
Batch related work: Group similar tasks to minimize context switches.
Use subagents for research: Let Claude spawn agents for investigation while preserving main context.
Version control safety: Always commit before major context operations:
$> Create a commit before we /clear
Context-aware prompting:
$> Given our snake_case API convention, refactor these endpoints# Claude already knows the convention from CLAUDE.md
When to Start Fresh
Start a new conversation when:
- Switching between completely different projects
- After multiple compactions (performance degrades)
- Beginning a new day of work
- Context becomes corrupted or confused
Remember: Claude Code's context is a resource. Use it wisely, clear it regularly, and leverage persistent memory for anything you'll need again.
Related Guides
Which plan to choose: Pro, Max 5x, Max 20x
Compare Claude Code subscription plans to find the perfect fit for your development needs and usage patterns.
Quickstart with Claude Code
Get started with Claude Code in minutes. Learn essential commands and features to boost your development workflow.
Best MCP servers for Claude Code
Discover the most powerful MCP servers to enhance your Claude Code development workflow with specialized tools and integrations.