Dev.to
7/3/2026

Will your codebase fit in the context window? How to measure it (and trim to fit)
Short summary
Determine whether your codebase fits an LLM's context window using two quick offline formulas—chars ÷ 3.6 plus word runs × 1.15—then express the result as a percentage of your model's budget (Claude 200K, GPT-5 400K, Gemini 2.5 Pro 1M). When trimming is needed, omit the largest file bodies first but keep the full file listing so the model sees the complete project map. Use ctxpack to automate this with one command.
- •Estimate token count offline using chars ÷ 3.6 and word runs × 1.15 formulas
- •Budget against specific model windows and report as a percentage of available context
- •Trim by file size with ctxpack while keeping the project file map intact
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



