| Crates.io | files-to-prompt |
| lib.rs | files-to-prompt |
| version | 1.0.2 |
| created_at | 2025-02-20 22:31:13.234042+00 |
| updated_at | 2025-03-01 17:56:16.76172+00 |
| description | Concatenates a directory full of files into a single prompt for use with LLMs |
| homepage | |
| repository | https://github.com/anishkny/files-to-prompt-rust |
| max_upload_size | |
| id | 1563273 |
| size | 46,597 |
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).
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.
cargo install files-to-prompt
Pre-compiled binaries for direct download... coming soon!
files-to-prompt [OPTIONS] [PATHS]...
[PATHS]... Directories or files to process. Defaults to the current directory (.)--include-hidden Include hidden files in the output--ignore <IGNORE_PATTERNS> Glob patterns of files or directories to ignore--ignore-gitignore Ignore .gitignore files when scanning directories-n, --line-numbers Include line numbers in the output-c, --cxml Output in an XML-like format suitable for Claude's long context window-m, --markdown Output Markdown fenced code blocks-o, --output <OUTPUT> Output file (default: stdout) or location (for -r, default: current directory)-j, --json Output JSON compatible with CodeSandbox API/CLI-r, --reverse Reverse operation. Reads files from stdin and writes to disk. Requires -c/--cxml.-e, --extension <EXTENSIONS> Only include files with the given extension(s)-h, --help Print help information-V, --version Print version informationfiles-to-prompt --markdown
./sample.cpp
```cpp
#include <iostream>
int main() {
std::cout << "Hello, C++!" << std::endl;
return 0;
}
```
./sample.java
```java
public class Sample {
public static void main(String[] args) {
System.out.println("Hello, Java!");
}
}
```
...
files-to-prompt --cxml --output output.xml
cat output.xml
<documents>
<document path="./file1.txt">
Contents of file1.txt
</document>
<document path="./file2.txt">
Contents of file2.txt
</document>
<document path="./folder/file3.txt">
Contents of file3.txt
</document>
</documents>
echo '<documents><document path="file1.txt">Contents of file1.txt</document><document path="file2.txt">Contents of file2.txt</document><document path="folder/file3.txt">Contents of file3.txt</document></documents>' \
| files-to-prompt --reverse --cxml
files-to-prompt --include-hidden --ignore "\*.log"
files-to-prompt -e c -e cpp -e h
For more examples, see tests/cli-tests.rs.
This project is a Rust port of the original files-to-prompt written in Python by Simon Willison.
MIT License