Everyone blames prompts when Claude Code burns through tokens. Usually it's the files.
1. package-lock.json
A typical package-lock.json for a mid-sized project is 50,000 to 200,000 characters. At roughly 4 characters per token, that's 12,500 to 50,000 tokens loaded on every turn.
Claude cannot install packages. It has no use for the lockfile. It's just taking up space.
Same applies to yarn.lock and pnpm-lock.yaml.
package-lock.json
yarn.lock
pnpm-lock.yaml
2. node_modules
If you haven't explicitly excluded node_modules, Claude Code may index it. That's 200MB+ of minified JavaScript, type declarations, and README files that have no value in context.
Some projects have node_modules/.cache with build artifacts inside. These are effectively binary — they burn tokens and return nothing.
node_modules/
3. Build output (.next, dist, build, .turbo)
Compiled output is derived from source. Claude can read source. Loading both doubles token cost with zero benefit.
.next/ is the worst of these — Next.js pre-renders HTML into its cache directory, so you end up with large, structurally noisy files getting loaded on every turn.
.next/
dist/
build/
.turbo/
out/
4. Test snapshots and fixtures
Jest and Vitest snapshot files (__snapshots__/*.snap) hold serialized component output. One snapshot file can be 10,000+ tokens. If you have 20 snapshot files, Claude is reading 200,000 tokens on turns that have nothing to do with tests.
Large JSON fixtures and seed data files have the same problem.
**/__snapshots__/
**/fixtures/
**/*.snap
5. Generated types and schema output
Build-generated type definitions — .d.ts, GraphQL types, Prisma client output — are large and derived from your source. There's no reason to load the output when Claude can read the source.
Auto-generated OpenAPI specs are often thousands of lines. Load the schema, not the generated spec.
**/*.d.ts
src/generated/
prisma/generated/
How to check what's actually eating your tokens
Measure before blocking anything. I built a scanner that shows the top token consumers in your project by file.
Grab it: context-scanner.py
python3 context-scanner.py
I ran it on my project expecting a few large files. Found the whole thing was 83% full before writing a line of actual code — package-lock.json alone was 10k tokens. Once you see the numbers it's hard to unsee.
The full .claudeignore setup
For a complete list with the reasoning behind each entry: what actually goes in .claudeignore.
If you're doing this work seriously, context management is one chapter of a bigger picture. I put everything I've learned about CLAUDE.md patterns, agent workflows, and debugging into one guide.
The Claude Code Playbook — $29, pay once.
Top comments (0)