Optimize Claude Code context window usage. Identify what to keep in context vs fetch on-demand. Use when context is bloated, responses are slow, hitting token limits, or want to slim down context.
Optimizes context window usage for efficient Claude Code sessions.
| Priority | Keep in Context | Fetch on Demand | | ------------- | ----------------------- | ---------------------- | | Always | CLAUDE.md (~500 tokens) | Full file contents | | Task-specific | Current file | Related files | | Reference | Function signatures | Implementation details |
| File | What to Know | Size |
| ------------------------ | -------------------------- | ----------- |
| CLAUDE.md | Commands, rules, structure | ~500 tokens |
| Active file being edited | Full content | Varies |
| Task | Files to Fetch |
| -------- | ---------------------------------------- |
| API work | apps/web/app/api/_lib/, specific route |
| Database | packages/db/src/schema.ts |
| Auth | packages/auth/src/index.ts |
| Tests | Specific test file only |
| Mobile | Specific screen/component |
What's the user working on?
For the current task, what's truly needed?
## Essential for This Task
1. {file1} - {why needed}
2. {file2} - {why needed}
## Can Fetch If Needed
- {file3} - Only if {condition}
- {file4} - Only if {condition}
## Skip
- {file5} - Already known / not relevant
Generate a minimal file list:
## Context Shortlist
### Must Have (read fully)
- `{path}` - Active editing
### Reference Only (read signatures)
- `{path}` - Import types
- `{path}` - Check pattern
### Fetch If Blocked
- `{path}` - Implementation details
## Recommendations
### To Reduce Context Now
1. {action} - saves ~{tokens}
2. {action} - saves ~{tokens}
### For Future Sessions
- Start with: "I'm working on {task}. Files: {shortlist}"
- Use subagents for exploration
- Split large tasks into focused sessions
"Read the entire codebase"
"Show me all the packages"
"Give me everything about auth"
"I'm editing apps/web/app/api/users/route.ts"
"Show me the getCurrentUser function signature"
"What tables are in the schema?"
| Item | ~Tokens | | ----------------------- | --------- | | Average TypeScript file | 500-1500 | | Large component | 1000-2000 | | Schema file | 800-1200 | | Full CLAUDE.md | 500 | | Test file | 400-800 |
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer