Collect all your code into a single XML file — perfect for AI assistants, code review, and documentation.
A powerful TUI (Terminal User Interface) utility that scans your project and aggregates all code files into one structured XML document with token counting, smart filtering, and built-in ignore presets.
- 🖥️ Interactive TUI — Navigate directories with keyboard, preview selections
- 🔢 Token Counting — GPT tokenizer integration for accurate token counts
- 🎯 12+ Ignore Presets — Node.js, Python, Rust, Go, Java, and more
- ⚡ CI/CD Friendly — Run without TUI in automated pipelines
- 📋 Clipboard Integration — Output path automatically copied
- 🔧 Custom Rules — Add your own ignore patterns for directories, files, or extensions
# Install globally
npm install -g @lemantorus/code-collector
# Or use with npx (no installation required)
npx @lemantorus/code-collector --path ~/my-project# Interactive mode (default)
code-collector
# Specify a directory
code-collector --path ~/projects/my-app
# CI mode (no TUI)
code-collector --no-tui
# Custom output file
code-collector --output my-code.xml| Option | Alias | Description | Default |
|---|---|---|---|
--path | -p | Starting directory | Current directory |
--output | -o | Output filename | all_code.txt |
--no-tui | Run without TUI (CI mode) | false | |
--open | Open output file after collection | false | |
--help | -h | Show help | |
--version | -v | Show version |
| Key | Action |
|---|---|
↑ / ↓ | Navigate directories |
Enter | Enter directory |
Backspace / Esc | Go to parent directory |
R | Run collection |
I | Open ignore settings |
P | Quick presets menu |
/ | Search directories |
Q | Quit |
| Key | Action |
|---|---|
↑ / ↓ | Navigate presets |
Enter | Toggle preset on/off |
E | Edit preset rules |
A | Add custom rule |
S | Save and go back |
/ | Search presets |
Esc | Cancel |
| Key | Action |
|---|---|
D | Show Directories |
F | Show Files |
E | Show Extensions |
↑ / ↓ | Navigate rules |
A | Add new rule |
X | Delete selected rule |
S | Save changes |
Esc | Cancel |
| Preset | Ignores |
|---|---|
| Node.js | node_modules/, dist/, build/ |
| Python | venv/, .venv/, __pycache__/, *.pyc |
| Rust | target/, Cargo.lock |
| Go | vendor/ |
| Java/Kotlin | .gradle/, *.class |
| Databases | *.db, *.sqlite, *.sqlite3 |
| Build Artifacts | dist/, build/, out/, target/ |
| VCS | .git/, .svn/, .hg/ |
| Secrets | .env, *.pem, *.key, credentials.* |
| Media | *.png, *.jpg, *.gif, *.zip, *.mp4 |
| IDE | .idea/, .vscode/, *.iml |
| JavaScript | *.min.js, *.min.css |
The output is a structured XML file:
<?xml version="1.0" encoding="UTF-8"?>
<codebaseproject="/path/to/project"generated="2025-01-15T12:00:00Z">
<meta>
<totalFiles>42</totalFiles>
<totalTokens>15234</totalTokens>
<totalSize>125000</totalSize>
</meta>
<filepath="src/index.ts"lang="typescript"tokens="150">
<content><![CDATA[// Your code hereexport function hello() { return "Hello, World!";}]]></content>
</file>
<filepath="src/utils.ts"lang="typescript"tokens="85">
<content><![CDATA[// Utility functionsexport const formatDate = (d: Date) => d.toISOString();]]></content>
</file>
</codebase>In the TUI:
- Press
Ito open Ignore Settings - Press
Ato add a custom rule - Choose type:
[D]irectory,[F]ile, or[E]xtension - Enter the pattern (supports glob patterns)
Examples:
- Directory:
my-build-folder - File:
*.generated.ts - Extension:
.min.js
Collect your entire codebase into a single file to provide context to ChatGPT, Claude, or other AI tools:
code-collector --no-tui --output context.txtGenerate a comprehensive view of all changes:
code-collector --path ./my-featureCreate code snapshots for tutorials or documentation.
Run in automated pipelines:
- name: Collect coderun: npx @lemantorus/code-collector --no-tui --output artifacts/codebase.xml# Clone the repository
git clone https://github.com/lemantorus/code-collector.git
cd code-collector
# Install dependencies
npm install
# Build
npm run build
# Run locally
npm run dev
# Type check
npx tsc --noEmitContributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Ink - React for interactive CLI apps
- GPT Tokenizer - Accurate GPT token counting
- Commander.js - CLI framework
Made with ❤️ by lemantorus