___ _____ ___ _
| _ \___ _ __ __|_ _|__| _ \_ _ ___ _ __ _ __| |_
| / -_) '_ \/ _ \| |/ _ \ _/ '_/ _ \ ' \| '_ \ _|
|_|_\___| .__/\___/|_|\___/_| |_| \___/_|_|_| .__/\__|
|_| |_|
RepoToPrompt is a tool that converts a repository into a single, structured plain-text document. It allows fine-grained filtering of included files and formatting to suit AI prompting, auditing, and archival needs.
Inspired by gpt-repository-loader, and partially restructured to support more flexible extension control, binary skipping, and notebook image filtering, which substantially impact the quality of LLM's answers.
- Filter files by include/exclude extensions
- Ignore files using a
.RepoToPromptignore(similar to.gitignore) - Automatically strip base64 image blobs from Jupyter Notebooks
- Automatically skip binary files and large files
- Configurable output preamble and file format
git clone https://github.com/AxelDlv00/RepoToPrompt.git
cd RepoToPromptRepoToPrompt only requires Python 3.
You can install Python from your system’s package manager or from Python.org directly.
Alternatively, you can use a conda environment, e.g.:
conda create -n repotoprompt python=3.9
conda activate repotopromptYou can run RepoToPrompt.py from anywhere by adding it to your shell's PATH.
Remark:
PATHis an environment variable that tells your terminal where to look for executable programs. When you typepythonorRepoToPrompt, your shell checks the directories listed inPATHin order, looking for an executable with that name.
Choose based on your shell:
Zsh(default on macOS) →~/.zshrcBash(older systems or Linux) →~/.bashrcor~/.bash_profile
chmod +x 'RepoToPrompt.py'
echo 'export PATH="$PATH:'"$(pwd)"'"' >> ~/.zshrc # or ~/.bashrc
echo 'alias RepoToPrompt="RepoToPrompt.py"' >> ~/.zshrc # or ~/.bashrc
source ~/.zshrc # or source ~/.bashrcNow you can call RepoToPrompt from anywhere.
Test it with RepoToPrompt --help.
python RepoToPrompt.py /path/to/repo \
[--preamble preamble.txt] \
[--output output.txt] \
[--include-extensions .py,.ipynb] \
[--exclude-extensions .jpg,.png] \
[--max-file-size 100000] \
[--skip-binary] \
[--strip-notebook-images]Parameters:
repo_path: Path to the repository you want to convert.--preamble: Path to a text file whose content will be prepended to the output.--output: Output file path (default:output.txt).--include-extensions: Comma-separated list of file extensions to include (e.g.,.py,.md).--exclude-extensions: Comma-separated list of file extensions to exclude (e.g.,.jpg,.png).--max-file-size: Skip files larger than this size (in bytes).--skip-binary: Skip files that appear to be binary.--strip-notebook-images: Remove base64 images from Jupyter notebooks.
python RepoToPrompt.py ./my_repo \
--preamble my_preamble.txt \
--output consolidated_repo.txt \
--include-extensions .py,.ipynb \
--exclude-extensions .png,.jpg \
--max-file-size 100000 \
--skip-binary \
--strip-notebook-images----
relative/path/to/file.ext
<file contents>
----
relative/path/to/another_file.ext
<file contents>
--END--
<Instructions or additional text beyond this point>
A simple ignore file that works like .gitignore. Example content:
*.log
__pycache__/
data/
*.png
*.jpg
*.pdf
*.aux
*.bbl
*.fdb_latexmk
*.fls
*.log
*.out
*.synctex.gz
*.toc
*.DS_Store
*.git*
*.txt
Place it in the root of the repo (or next to the script) to filter out files or folders you don’t want included.
MIT License — see LICENSE.
This project reuses logic and structure from gpt-repository-loader.
- Axel Delaval
- Last update : April 2025