back to index

flatten-repo VSC Extension

A VS Code extension that flattens a repo into a single .txt file for pasting into an LLM context window.

repo: https://github.com/EricSpencer00/flatten-repo


Built to solve a real annoyance: burning through monthly Copilot credits and needing to drop a whole project into a free Gemini or Claude session without copy-pasting twenty files one by one.

It's a VS Code extension. You point it at your workspace, run Flatten Project to TXT from the command palette, and it dumps the whole codebase into a single .txt file under /flattened/. If the repo is too big for one LLM's context window, it splits into chunks based on a configurable token limit (~4 chars per token, rough but fine). Each chunk starts with a directory tree, then the files in === FILE: path/to/file.ext === blocks. It also auto-adds /flattened to your .gitignore so you don't accidentally commit the dumps.

The actually-useful part is the filtering. You don't want nodemodules in there. You probably don't want test files or .env either. Everything gets configured through a single .flattenignore at the project root, which the extension generates for you on first run. Glob-based, with three sections — global for things you always want out, whitelist for narrowing down to specific paths, and blacklist for specific exceptions. There's also a settings: section for per-project token caps.

A sample .flatten_ignore looks like this:


# Ignore rules
global:
node_modules
.git
dist

# Whitelist (optional)
whitelist:
src/**/*.js

# Blacklist (optional)
blacklist:
**/*.test.js
.env

# Settings (optional)
settings:
maxTokenLimit: 50000
maxTokensPerFile: 25000

You can also stick the same kind of config in .vscode/settings.json if you'd rather keep it with the rest of your VS Code stuff:


"flattenRepo.includeExtensions": [".ts", ".tsx", ".js", ".jsx", ".py", ".html", ".css"],
"flattenRepo.ignoreDirs": ["node_modules", ".git", "dist"],
"flattenRepo.maxChunkSize": 200000

Command-only — no UI for picking files interactively — and it doesn't flatten binaries or images. Most useful for dropping a flattened repo into a free model when paid credits run out.

GitHub Repo — feel free to open issues or send a PR if you want to take a swing at the file-picker UI.


No time to write a full breakdown for everything — this description was written by an LLM.