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


flatten-repo exists to get a whole project into a free Gemini or Claude session once the month's Copilot credits are gone, without pasting twenty files one at a time.

It is a VS Code extension. Pointed at a workspace, the Flatten Project to TXT command from the command palette dumps the codebase into a single .txt file under /flattened/. If the repo is too big for one model's context window, it splits into chunks based on a configurable token limit, estimated at roughly 4 characters per token. Each chunk starts with a directory tree, followed by the files in === FILE: path/to/file.ext === blocks. /flattened is added to .gitignore automatically so the dumps are not committed by accident.

The useful part is the filtering. node_modules does not belong in the dump, and neither do test files or .env in most cases. All of it is configured through a single .flatten_ignore at the project root, which the extension generates on first run. The rules are glob-based, in three sections: global for permanent exclusions, whitelist for narrowing to specific paths, and blacklist for specific exceptions. A settings: section holds per-project token caps.

A sample .flatten_ignore:


# 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

The same kind of config can live in .vscode/settings.json instead:


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

It is command-only, with no UI for picking files interactively, and it does not flatten binaries or images.

GitHub Repo