"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.






