5 Context Window Tricks That Cut My Token Usage in Half
I was burning through tokens like they were free. Then I started measuring. My average coding session used ~80K tokens, and most of it was wasted context the model didn't need. After a month of exp...

Source: DEV Community
I was burning through tokens like they were free. Then I started measuring. My average coding session used ~80K tokens, and most of it was wasted context the model didn't need. After a month of experimenting, I cut that to ~35K tokens per session with zero loss in output quality. Here are the five tricks that made the difference. 1. The File Summary Header Instead of pasting an entire file into context, I prepend a 3-line summary: // FILE: src/auth/middleware.ts (147 lines) // PURPOSE: Express middleware for JWT validation + role-based access // EXPORTS: authMiddleware, requireRole, extractUser Then I only include the specific function I need help with. The model gets enough context to understand the architecture without reading 147 lines of boilerplate. Token savings: ~60% per file reference. 2. The Dependency Stub When the model needs to understand how a function interacts with other modules, don't paste the full dependency — paste a stub: // STUB: database.ts interface DB { query<