A simple CLI tool to dump a project's structure and file contents into a single Markdown file. Ideal for providing context to LLMs, creating project snapshots, or generating documentation.
- Project Tree Generation: Creates a visual tree of your project's directory structure.
- File Content Embedding: Includes the full content of specified file types.
- Advanced Exclusions: Exclude files and directories using
.gitignorerules and custom glob patterns viapathspec. - Rich Terminal Preview: Uses
richto show a colorful preview of the files that will be included in the dump. - Clipboard Integration: Copies the entire dump to the clipboard instead of writing to a file.
- Highly Customizable: A wide range of CLI options to tailor the output to your needs.
- Built with Typer: Modern and easy-to-use CLI interface.
This tool is built and managed with uv, the fast Python package installer and resolver
from Astral.
-
Install
uv: If you don't haveuvinstalled, follow the official installation guide:curl -LsSf https://astral.sh/uv/install.sh | sh -
Install
codebase-dump: To make thecodebase-dumpcommand available globally, navigate to the root of this project and run:uv tool install .If
uvwarns that the tools directory is not in yourPATH, follow the instructions it provides to update your shell configuration. -
Update the tool: To update the tool after making changes to the source code, run:
uv tool install . --force
To ensure code quality and consistency, this project uses pre-commit hooks for
linting, formatting, type checking, and pytest for testing.
-
Sync Dependencies: Install all required dependencies for development:
uv sync
-
Install
pre-commitHooks: Set up the git hooks for automated checks on commit and push:pre-commit install pre-commit install --hook-type pre-push
Now,
ruffandtywill run automatically on every commit, andpytestwill run on every push. -
Run Tests: To run the tests manually:
uv run pytest
-
Check Test Coverage: To run tests and check the test coverage:
uv run pytest --cov=codebase_dump
You can view a detailed HTML report by opening
htmlcov/index.html.
Here are some common usage examples.
This will scan the current directory for .py files and create a codebase.md file.
codebase-dumpShow a tree of the files that will be included in the output without writing the file.
codebase-dump --previewInclude .toml and .md files in addition to the default .py.
codebase-dump --ext .py --ext .toml --ext .mdSave the dump to a different file.
codebase-dump -o project_snapshot.mdCopy the entire dump to your clipboard.
codebase-dump --to-clipboard
# or
codebase-dump -cExclude specific directories or files using glob patterns.
# Exclude the tests directory
codebase-dump -x "tests/*"
# Exclude all migration files
codebase-dump -x "*/migrations/*"To ignore the rules from your .gitignore file:
codebase-dump --no-gitignoreFor a full list of commands and options, run:
codebase-dump --help