files-to-prompt 0.6.0

Concatenates a directory full of files into a single prompt for use with LLMs
files-to-prompt-0.6.0 is not a library.

files-to-prompt

CI Dependabot Crates.io Version

files-to-prompt is a command-line tool that recursively reads all files in a specified directory (respecting .gitignore) and concatenates their contents into a structured format, making it easy to use as a prompt for Large Language Models (LLMs).

Features

  • Recursively scans directories and reads all files
  • Outputs file paths along with their contents
  • Respects .gitignore
  • Ignores hidden files be default
  • Sorts files by path for consistency

Installation

To use files-to-prompt, first ensure you have Rust installed. Then, build the project:

cargo build --release

Or install it directly using:

cargo install --path .

Usage

Run the tool by providing one or more directory paths:

files-to-prompt <path1> [path2] ...

Example

files-to-prompt ./my_project

This will output:

./my_project/file1.txt
----
<contents of file1.txt>
----

./my_project/file2.rs
----
<contents of file2.rs>
----

Error Handling

  • If a file cannot be read, an error message is printed.
  • If no path is provided, the program exits with an error message.

Use Case

This tool is particularly useful when preparing large codebases or documentation as a prompt for an LLM, allowing users to efficiently gather and format multiple files into a structured input.

Credit

This project is a Rust port of the original files-to-prompt written in Python by Simon Willison.

License

MIT License