Skip to content

Context windows and repository size: how much code can an AI read at once?

Tokens, characters and lines of code: how big a repository fits in a model's context window, what gets filtered out, and what to do when a repository is too large.

October 13, 2026 · 2 min read · RepoGrasp team

A model's context window is the amount of text it can consider at once, measured in tokens. Current models offer windows from a couple of hundred thousand tokens to a million. How much code is that, and why do tools still set limits below the maximum?

Tokens, characters and lines

A token is a chunk of text: a word, part of a word or a piece of punctuation. For code, a rough rule is about 4 characters per token, though it varies with the language, naming style and the model's tokenizer.

TokensCharacters (approx.)Lines of code (approx., 40 chars/line)
50,000200,0005,000
200,000800,00020,000
1,000,0004,000,000100,000

Many real applications and libraries have under 20,000 lines of hand-written source once you remove dependencies, generated files and build output.

What should be filtered out

A raw repository is much bigger than its source code. Good tools remove:

  • Dependencies (node_modules, vendor)
  • Build output (dist, build, .next)
  • Lockfiles, which can be enormous and say nothing about behaviour
  • Minified files and source maps
  • Generated type declarations
  • Binary files, images and fonts
  • Secrets and credentials, which should never be sent anywhere

After filtering, a repository that's 500 MB on disk can be a few hundred thousand tokens of source.

Why not always use the maximum?

  • Cost. Input tokens are billed per request. A million-token prompt costs far more than a 200,000-token one. Prompt caching cuts the cost of follow-up questions on the same context substantially, but the first question pays full price.
  • Speed. Longer prompts take longer to process before the answer starts.
  • Attention. Models handle long contexts well but not perfectly. Details in the middle of a huge context are more likely to be overlooked, which line numbers and explicit citation instructions help counter.

What RepoGrasp does

RepoGrasp's preview keeps source files (TypeScript, JavaScript, Vue, Svelte, Astro), Prisma and GraphQL schemas, JSON and README files, skips the noise listed above, and caps the total at roughly 200,000 tokens (about 800,000 characters). Individual files over 100 KB are skipped. If a repository is bigger, RepoGrasp says so rather than silently cutting files, and suggests linking a subfolder such as github.com/owner/repo/tree/main/packages/core.

When a repository is too big

  • Scope to a package or folder. Most questions are about one part of a codebase.
  • Ask about one feature at a time and point the tool at that feature's folder.
  • Use retrieval or agent-based tools for questions that truly span a huge codebase. See RAG vs long context.

The bottom line

A surprising amount of real software fits in a modern context window once you filter it properly. For what doesn't, narrow the scope rather than hoping the model sees everything.