You've got 200k tokens. So why do you keep running out of room halfway through your API call?
Most developers treat context like a gas tank—fill it up and hope you don't run empty. That's the wrong mental model. Context is inventory. You need to manage it.
Here's what actually works.
The Real Problem
You throw your whole codebase at Claude. You paste the 500-line file. You include the error trace, the full conversation history, and the docs. Then you're surprised when the model says "sorry, I'm out of space."
But it's not about space—it's about signal-to-noise.
A 200k token context window looks huge until you realize:
- Your entire Ruby on Rails app is 50k tokens
- Your conversation history is another 30k
- The relevant 2k-line file is buried in the middle
- The model spends half its attention on stuff that doesn't matter
You're not running out of context. You're drowning in it.
The Three-Tier Strategy
Start with this:
Tier 1: The Essentials (10-20% of context)
- Only the active files you're modifying right now
- The specific error or issue
- One or two related tests
Tier 2: Reference (20-30% of context)
- Related functions/methods (search for imports, dependencies)
- Type definitions if you're in TypeScript
- API specs if you're integrating something
- Key configuration
Tier 3: Archive (optional, 30-50%)
- Full codebase when you actually need it (rare)
- Long conversation history if the context matters (don't save for pride)
- Documentation or standards your team follows
Rule: Start at Tier 1. Only move up if the model says "I need X to help."
Practical Tools
Option 1: Cursor-style context picker
If you're using Cursor or Claude in your IDE, use the @-symbol to tag only what matters. Don't include your entire project—select the 3-4 files you're actually working on.
Option 2: Context manifesto (my preference)
Create a .context file in your repo:
# CONTEXT.md
## This PR is about
[1-2 sentences]
## Files that matter
- src/auth/login.ts — where the bug is
- src/types/user.ts — User type definition
- tests/auth.test.ts — relevant test
## Recent context
[Last 3-5 messages from your conversation, not the whole history]
## To understand this, you need to know
- We use bcrypt for password hashing
- Sessions are JWT-based
- Tests run in Jest with supertest
Then just paste the context file + your active files.
When to Break the Rules
Full context is worth it when:
- You're doing a major refactor (need the whole picture)
- The bug is weird and context-dependent (search errors across files)
- You're building something new and need all the constraints
Full context is a waste when:
- You're debugging one function
- You're writing docs
- You're fixing a typo or renaming something
- You already know the structure and just need help with logic
Real Example
I was debugging a React state issue. Bad approach:
Here's my entire src folder (42 files, 40k tokens):
[entire src dump]
Why is my form state not updating?
Good approach:
Component: UserForm.tsx (handles user profile updates)
Issue: Form fields don't update when user data loads
Relevant code:
- useEffect hook (lines 15-23) that should trigger
- setState call (line 42)
- Form input onChange (line 55)
Current behavior: Form shows stale data
Expected: Form updates within 500ms of data load
Here's the component:
[just the component, 120 lines]
What am I missing?
The model found the issue in 10 seconds: missing dependency in the useEffect array. With the full folder dump, it would've taken longer and used 10x more tokens.
The Token Budget Mindset
Think like you're on a 100MB bandwidth limit (even if you're not).
- Every token costs money (API calls) or time (local models)
- Every extra token makes the model slower
- Every distraction makes the model dumber
Treat context like you treat production deploys. Be intentional. Be minimal. Be clear about what matters.
Your Move
Next time you hit a "context limit exceeded" or "I need more space" error, don't just upgrade to a bigger model. Actually look at what you're sending.
Can you remove:
- The entire conversation history? (keep just the last 3-5 exchanges)
- The unrelated files? (use imports/references instead)
- The boilerplate? (docs and comments aren't tokens)
Usually you'll cut it by 50% and the model will actually perform better.
Want to level up your AI workflow? I send weekly tips on building with LLMs—real patterns, no hype. Join the LearnAI Weekly newsletter—it's where developers share what actually works.
Top comments (0)