A Python script inspired by repo2file to generate an LLM prompt text file from your code, here's what it does:
- Recursively dump a directory tree.
- Collect and embed file contents into a single text file.
- Automatically skip
.git/
,.vscode/
, and common media/document formats. - Honor your
.gitignore
rules. - Offer a single
--exclude
flag for any extra patterns. - Optionally customize the output directory.
python codepromptor.py <root> [options]
- (required): Path to the directory you want to scan.
Flag | Alias | Description |
---|---|---|
-e , --exclude |
— | Comma‑separated glob patterns to exclude (e.g. readme.md,.gitignore,.css ). |
-o , --output-dir |
— | Directory where the resulting text file will be saved. Defaults to a prompts/ folder next to script. |
-
Always skips the following:
.git/
directory.vscode/
directory- File types:
png
,jpg
,jpeg
,gif
,bmp
,svg
,mp4
,mp3
,wav
,avi
,mov
,mkv
,webp
,pdf
,ppt
,pptx
,doc
,docx
,xls
,xlsx
,csv
-
Honors all patterns in
.gitignore
(if present). -
Prints each file as it’s added:
-
Basic scan (uses defaults, output to
prompts/<folder>.txt
):python codepromptor.py /path/to/my-project
-
Exclude specific files (
README.md
,.gitignore
,package-lock.json
):python codepromptor.py ./my-app \ -e readme.md,.gitignore,package-lock.json
-
Custom output directory:
python codepromptor.py ./my-app \ -o /tmp/dumps
-
Combine exclude + custom output:
python codepromptor.py ../repo \ -e '*.test.js',node_modules/ \ -o /var/log/dir-dumps
The script generates a single .txt
file named after the scanned folder (e.g. my-app.txt), containing:
-
Directory Structure
/ ├── src/ │ ├── index.js │ └── lib/ └── README.md
-
File Contents
File: src/index.js -------------------------------------------------- // (file contents...) File: docs/overview.md -------------------------------------------------- # Overview ...