| Crates.io | git2prompt |
| lib.rs | git2prompt |
| version | 0.4.3 |
| created_at | 2025-08-27 15:05:47.963841+00 |
| updated_at | 2026-01-15 14:06:56.260006+00 |
| description | git2prompt is a command-line tool that takes a GitHub repository URL, downloads its contents, and generates a single text file optimized for use as input to AI tools. |
| homepage | |
| repository | https://github.com/fabiomolinar/git2prompt |
| max_upload_size | |
| id | 1812813 |
| size | 127,681 |
git2prompt is a command-line utility written in Rust that streamlines the process of preparing GitHub repository content for large language models (LLMs). It clones repositories, filters out unnecessary files, and concatenates the source code into a single, clean markdown file, ready to be used as context for AI tools.
.gitignore syntax (glob patterns, negations, directory-specific rules) via the ignore crate.src, docs) into separate output files for better context management..git2promptconfig file (TOML) to save your preferences for ignore patterns, split folders, and more.##) to preserve the structural integrity of the final output. It also injects a warning note to inform the AI of these changes.To get started, clone the repository and build the project with Cargo.
cargo build --release
After building, you can use the compiled binary directly.
The output files are stored within an output folder which is created where the binary is ran from.
To process a single repository and output a single file:
git2prompt <owner/repo>
For example:
git2prompt rust-lang/rust-by-example
Or in case you have the repository on your local machine, then just run it with the --local flag. For example:
git2prompt --local .
Process multiple repositories and merge their contents into a single file:
git2prompt --merge-files rust-lang/rust rust-lang/book
Splitting Content by Folder:
If you want to separate documentation or specific modules into their own files, use the --split-folder flag:
git2prompt rust-lang/rust --split-folder src --split-folder docs
This will generate files like rust_processed.md (default content), rust_src_processed.md, and rust_docs_processed.md.
Custom Configuration:
You can persist your preferences in a .git2promptconfig file (see below) or specify a custom config path:
git2prompt --config my-config.toml rust-lang/rust
Use the --no-headers flag to remove the file path headers above each code block:
git2prompt --no-headers rust-lang/rust-by-example
Sometimes you only need a single folder from a repository (instead of downloading the entire repo and ignoring most files). Use the --folder flag to restrict processing to a single directory:
git2prompt rust-lang/rust-by-example -f src
You can also restrict processing to only the files impacted by a GitHub pull request.
git2prompt --pr 123 rust-lang/rust-by-example
git2prompt automatically ignores certain common file types and directories to keep the output clean.
These are automatically ignored:
To ignore additional files or directories, create a file named .git2promptignore in the same directory as the binary. The format supports standard .gitignore syntax (glob patterns, wildcards, negations).
For example:
assets/
docs/*.pdf
!docs/important.txt
target/
Alternatively, you can specify a custom ignore file using the --ignore-file flag:
git2prompt --ignore-file my-custom-ignore.txt <owner/repo>
You can create a .git2promptconfig file in your working directory to save your preferences. This file uses TOML format.
Example .git2promptconfig:
# Default ignore patterns (supplementary to .git2promptignore)
ignore_patterns = ["tests/", "*.log"]
# Folders to always split into separate output files
split_folders = ["docs", "examples"]
# Default settings
no_headers = false
ignore_file = ".git2promptignore"
As I am starting my journey with Rust, here it goes a few reminders so I don't have to Google them all the time:
cargo new <project-name>.cargo build.cargo run.cargo run --release.cargo check.cargo test.cargo clippy (run with --fix to automatically fix the issues).cargo test <test-file>.cargo test <test-function>.cargo install --path . from the root of the crate.Before pushing to crates.io, run the following:
cargo clippy --fixcargo fmtcargo testcargo build --releaseIf all good:
Cargo.toml.cargo package and then cargo publish.To update the CLI program binary from source, run cargo install --path ..