Codepack is a CLI tool that extracts folder structure and file contents into a single text file, optimized for AI processing (ChatGPT, Claude, etc.).
- Directory tree generation: Visual representation of project structure
- File content extraction: Concatenates all relevant files into one output
- Smart exclusions: Auto-excludes
.git,node_modules,venv,__pycache__, etc. - Minification: Ultra-aggressive content compression for token optimization
- Binary detection: Skips binary files automatically
- Clipboard support: Copy output directly to clipboard
- Gzip compression: Optional output compression
codepack/
├── codepack.sh # Main script (Bash)
├── CLAUDE.md # This file
├── CHANGELOG.md # Version history
├── README.md # User documentation
├── LICENSE # MIT License
├── package.json # npm package config
├── logo.png # Project logo
├── test/ # Test scripts
│ ├── test_basic.sh # Basic functionality tests
│ └── test_features.sh # Feature tests
└── .github/
└── workflows/
└── publish.yml # GitHub Packages workflow
- Bash 4.0+ (uses arrays, associative arrays)
- NOT compatible with POSIX
sh(BusyBox ash, dash, etc.)
terser/esbuild- JavaScriptpyminify- Pythoncsso/cleancss- CSShtml-minifier-terser- HTMLjq- JSON
- Maintain Bash compatibility (arrays,
[[ ]],declare -A) - Keep the guard at the top that checks for
$BASH_VERSION - Test with both
bash codepack.shand./codepack.sh - Update version number in header AND in
main()function
cd test/
bash test_basic.sh
bash test_features.shThe generated file includes:
- Directory tree structure
- File contents with separators
- Exclusion notes
- Minification notes (if enabled)
- Add detection in
get_file_type()function - Create
minify_<type>()function - Add case in
minify_content()switch
Add to DEFAULT_EXCLUDE_DIRS array at line 19
Add to DEFAULT_EXCLUDE_FILES array at line 20