"Just paste the repo into the model" runs into a hard wall: the context window. Paste too much and you get a truncation error, or β worse β the model silently drops the earliest files and answers from a partial picture. The fix is to treat "will it fit?" as a number you compute before you paste.
Step 1: estimate tokens without calling an API
You don't need a network round-trip to get a usable estimate. For source code, a blend of two signals is within ~5β10% of real BPE tokenizers:
- Characters Γ· ~3.6 β code tokenizes denser than prose (more punctuation and identifiers).
- Count of word/symbol runs Γ ~1.15 β a second signal that corrects the char estimate on symbol-heavy files.
Average the two and you have a fast, offline token estimate. Good enough to answer "does it fit?"
Step 2: check it against the model you're targeting
Context windows vary a lot, so budget against the specific model:
| Model | Context |
|---|---|
| Claude (Fable 5 / Opus / Sonnet) | 200K |
| GPT-5 | 400K |
| GPT-4.1 | 1M |
| Gemini 2.5 Pro | 1M |
Report the bundle as a percentage of the target window β "48K tokens = 24% of 200K" tells you at a glance whether you have room left for the actual conversation.
Step 3: if it's over budget, trim by importance β not at random
When a repo is too big, the naive move (truncate the end) throws away whoever files happen to be last. Better: omit the largest file bodies first, but keep every file listed. The model still sees the full project map (so it knows payments/refund.ts exists) even if that file's body didn't make the cut.
With ctxpack this is one flag:
npx github:trongtruong110-ux/ctxpack . --fit 60000 -o context.md
ctxpack: 220 files packed
tokens: ~59,400
trimmed: 34 file(s) omitted to fit 60,000 tokens
Every file is still named in the index; only the biggest bodies are dropped to hit the budget.
The habit
- Estimate before you paste β "does it fit?" is answerable up front.
- Budget per model β a bundle that fits Gemini may blow Claude's window.
- Trim by size, keep the map β a partial bundle that still lists every file beats a truncated one that hides what's missing.
ctxpack is MIT-licensed and free: https://github.com/trongtruong110-ux/ctxpack. How do you currently decide what to include when a repo is too big for one prompt?
United States
NORTH AMERICA
Related News

Mattress Firm Coupons: Save up to $600
4h ago
π I Built a Dropshipping Automation Pipeline β Here's What I Learned (and What I'd Do Differently)
11h ago
How I Cut My LLM API Bill by 40x: A Freelancer's Migration Story
11h ago
Cursor AI Review 2026: The AI-Native Code Editor
8h ago

Another Model Rewrote My Memories. Here's How I Caught It.
8h ago