A command-line tool to generate a single Markdown file that concatenates the structure and content of a specified directory. Useful for providing context to Large Language Models (LLMs) or creating simple project documentation.
- Recursively scans a directory.
- Outputs a tree-like structure of the directory (using relative paths).
- Includes the content of text files, formatted with line numbers.
- Automatically detects and skips likely binary files.
- Allows ignoring specific directories, files, and extensions via command-line options.
- Provides sensible default ignores for common development artifacts (e.g.,
.git,node_modules,.pyc). - Output can be directed to stdout (default), a file (
-o), or the system clipboard (-c). - Uses
typerfor a user-friendly command-line interface.
-
Install Dependencies:
uv sync
-
Make Executable (Optional):
chmod +x repo_to_md.py
-
Run: (Examples assume it's executable, otherwise use
python repo_to_md.py ...)- Basic Usage (Output to stdout, current directory):
or
./repo_to_md.py .uvx repo_to_md.py . - Specify Directory:
or
./repo_to_md.py /path/to/your/project
uvx repo_to_md.py /path/to/your/project
- Output to File:
or
./repo_to_md.py . --output project_docs.md # or short form: ./repo_to_md.py . -o project_docs.md
uvx repo_to_md.py . -o project_docs.md - Output to Clipboard:
or
./repo_to_md.py . --clipboard # or short form: ./repo_to_md.py . -c
uvx repo_to_md.py . -c - Ignore Specific Directories: (Uses default ignores + adds
logsandtemp)or./repo_to_md.py . --ignore-dir logs --ignore-dir tempuvx repo_to_md.py . --ignore-dir logs --ignore-dir temp - Ignore Specific Files: (Uses default ignores + adds
.envandconfig.json)or./repo_to_md.py . --ignore-file .env --ignore-file config.jsonuvx repo_to_md.py . --ignore-file .env --ignore-file config.json - Ignore Specific Extensions: (Uses default ignores + adds
.logand.tmp)or./repo_to_md.py . --ignore-ext log --ignore-ext .tmp # Handles leading dot or not
uvx repo_to_md.py . --ignore-ext log --ignore-ext .tmp # Handles leading dot or not
- Combining Ignores:
or
./repo_to_md.py . -o out.md --ignore-dir build --ignore-file secrets.txt --ignore-ext bakuvx repo_to_md.py . -o out.md --ignore-dir build --ignore-file secrets.txt --ignore-ext bak - Get Help:
or
./repo_to_md.py --help
uvx repo_to_md.py --help
- Basic Usage (Output to stdout, current directory):
Contributions are welcome! Please see the CONTRIBUTING.md file for guidelines.