2 stable releases
Uses new Rust 2024
| 1.0.1 | Sep 20, 2025 |
|---|---|
| 1.0.0 | Aug 24, 2025 |
#1224 in Text processing
78 downloads per month
22KB
292 lines
Codebase to Prompt
codebase-to-prompt is a Rust-based CLI tool designed to bundle files from a directory into a single output file. It supports filtering files by extensions, respecting .gitignore rules, and formatting the output in Markdown, plain text, or console-friendly formats.
Features
- File Filtering: Include or exclude files based on their extensions.
- Output Formats: Supports Markdown, plain text, and console-friendly formats.
- Git Integration: Optionally append the current Git hash to the output file name.
- Date Integration: Optionally append the current date to the output file name.
- Line Numbers: Include line numbers in the output.
- Hidden Files: Optionally ignore hidden files.
.gitignoreRespect: Optionally respect.gitignorerules.
Installation
There are multiple ways to install codebase-to-prompt.
Option 1: Using cargo install (Recommended for Rust developers)
If you have the Rust toolchain installed, you can easily install the latest version from crates.io:
cargo install codebase-to-prompt
Option 2: Using the Install Script (for Linux & macOS)
You can download and run the installation script, which will install the latest release binary for your system:
curl -fsSL https://raw.githubusercontent.com/GKaszewski/codebase-to-prompt/master/install.sh | sh
Option 3: From GitHub Releases
You can download the pre-compiled binary for your operating system directly from the Releases page.
Option 4: Building from Source
- Ensure you have Rust installed.
- Clone this repository:
git clone https://github.com/GKaszewski/codebase-to-prompt cd codebase-to-prompt - Build the project:
cargo build --release - The binary will be available at
target/release/codebase-to-prompt.
Usage
Run the tool with the following options:
codebase-to-prompt [OPTIONS] [DIRECTORY]
Options
-o, --output <FILE>: Specify the output file. Defaults to stdout if not provided.-i, --include <EXTENSIONS>: Comma-separated list of file extensions to include.-e, --exclude <EXTENSIONS>: Comma-separated list of file extensions to exclude.--format <FORMAT>: Output format (console,markdown,text). Defaults toconsole.-d, --append-date: Append the current date to the output file name.-g, --append-git-hash: Append the current Git hash to the output file name.-l, --line-numbers: Include line numbers in the output.-H, --ignore-hidden: Ignore hidden files.-R, --respect-gitignore: Respect.gitignorerules. Enabled by default.
Examples
-
Bundle all
.rsfiles in the current directory intooutput.mdin Markdown format:codebase-to-prompt -o output.md -i rs -
Bundle all files except
.logfiles, appending the current date and Git hash to the output file name:codebase-to-prompt -o output.txt -e log -d -g -
Output all files to the console, including line numbers:
codebase-to-prompt -l
Development
Prerequisites
- Rust (latest stable version recommended)
Building
To build the project:
cargo build --release
Running Tests
To run tests:
cargo test
Linting and Formatting
To lint the code:
cargo clippy
To format the code:
cargo fmt
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
Contributions are welcome! Feel free to open issues or submit pull requests.
Dependencies
~21–32MB
~571K SLoC