codebase-dump.sh is a simple, efficient Bash script designed to create a single-file text representation of your project. It is specifically optimized for providing full-codebase context to Large Language Models (LLMs).
- Smart Filtering: Automatically respects your
.gitignoresettings. - Safety First: Skips binary files and common lock-files (e.g.,
package-lock.json,Cargo.lock,yarn.lock). - Visual Structure: Generates a project tree at the beginning of the dump.
- Flexible Scope: Supports recursive dumps or top-level-only analysis for both the root and any subfolder.
- Named Arguments: Supports short (
-d,-R) and long (--dir,--no-recursive) flags. - Progress Tracking: Displays real-time status with a file counter.
- Error Handling: Exits with a non-zero code and removes the output file if the dump fails or produces an empty result.
Ensure the script is executable:
chmod +x scripts/codebase-dump.shbash scripts/codebase-dump.shOutput: dumps/codebase/codebase-dump.txt
bash scripts/codebase-dump.sh -d src/componentsOutput: dumps/codebase/codebase-dump_src_components.txt
bash scripts/codebase-dump.sh --no-recursiveOutput: dumps/codebase/codebase-dump_root-only.txt
bash scripts/codebase-dump.sh -d src/components --no-recursiveOutput: dumps/codebase/codebase-dump_src_components_top-only.txt
bashgit(the script must be run inside a git repository)perl(used for robust binary file detection)
Add the following to your .gitignore to avoid committing dump files:
# Dumps (e.g. database dumps, codebase dumps, etc.)
dumps/