Flatten Repository

A VS Code extension that helps you flatten your codebase into a single file for easy sharing and analysis with LLMs (Large Language Models).
Features
Installation
- Open VS Code
- Go to the Extensions view (Ctrl+Shift+X)
- Search for "Flatten Repository"
- Click Install
Usage
- Open your project in VS Code
- Press
Ctrl+Shift+P to open the command palette
- Type "Flatten Repository" and select one of the commands:
- "Flatten Project to TXT": Creates a flattened version of your codebase
- "Create/Edit .flatten_ignore File": Configure what files to include/exclude
Configuration
.flatten_ignore File
The .flatten_ignore file supports three types of patterns:
# Global ignore patterns (always ignored)
global:
node_modules/**
dist/**
build/**
vendor/**
/generated/** # Root level generated files
**/generated/** # Any generated files
# Whitelist patterns (always included)
whitelist:
src/**/*.java
src/**/*.ts
*.md
*.json
# Blacklist patterns (additional ignores)
blacklist:
*.min.js
*.min.css
*.map
# Settings
settings:
maxTokenLimit: 128000 # ~128K tokens (Claude/GPT-4)
maxTokensPerFile: 25000
useGitIgnore: true
VS Code Settings
flattenRepo.includeExtensions : File extensions to include
flattenRepo.ignoreDirs : Directory names to ignore
flattenRepo.useGitIgnore : Use .gitignore patterns
flattenRepo.maxChunkSize : Maximum characters per chunk
flattenRepo.globalWhitelist : Global include patterns
flattenRepo.globalBlacklist : Global exclude patterns
Token Limits
The extension supports various LLM token limits:
- Claude 3 Opus: ~200K tokens (800K chars)
- Claude 3 Sonnet: ~128K tokens (512K chars) [DEFAULT]
- GPT-4 Turbo: ~128K tokens (512K chars)
- Claude 2: ~100K tokens (400K chars)
- GPT-4: ~32K tokens (128K chars)
- GPT-3.5 Turbo: ~16K tokens (64K chars)
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
License
MIT License - see LICENSE for details
Support
Version History
1.0.3
- Added support for
/generated directory ignore patterns
- Improved whitelist pattern handling
- Updated default ignore patterns
- Enhanced LLM token limit documentation
See CHANGELOG.md for full version history.
| |