#recursion #prompt #llm #file #concatenation #file-path

app files-to-prompt

Concatenates a directory full of files into a single prompt for use with LLMs

3 releases (breaking)

new 0.3.0 Feb 22, 2025
0.2.0 Feb 21, 2025
0.1.0 Feb 20, 2025

#313 in Filesystem

Download history

71 downloads per month

MIT license

8KB

files-to-prompt

CI Dependabot

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

Credit

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

Features

  • Recursively scans directories and reads all files
  • Sorts files by path for consistency
  • Outputs file paths along with their contents
  • Handles errors gracefully if files cannot be read

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.

License

MIT License

Dependencies

~4–11MB
~122K SLoC