# files-to-prompt: Concatenate Files into a Single Prompt for LLMs

This repository profile is provided by osrepos.com, an open source repository discovery platform.

Source: osrepos.com
Repository profile: https://osrepos.com/repo/simonw-files-to-prompt
Generated for open source discovery and AI-assisted research.

files-to-prompt is a command-line tool designed to concatenate the contents of multiple files from a directory into a single, structured prompt suitable for Large Language Models (LLMs). It offers flexible options for filtering files by extension, ignoring patterns, and supports various output formats including standard text, Claude XML, and Markdown. This utility streamlines the process of preparing complex codebases or documentation for AI analysis.

GitHub: https://github.com/simonw/files-to-prompt
OSRepos URL: https://osrepos.com/repo/simonw-files-to-prompt

## Summary

files-to-prompt is a command-line tool designed to concatenate the contents of multiple files from a directory into a single, structured prompt suitable for Large Language Models (LLMs). It offers flexible options for filtering files by extension, ignoring patterns, and supports various output formats including standard text, Claude XML, and Markdown. This utility streamlines the process of preparing complex codebases or documentation for AI analysis.

## Topics

- Python
- CLI
- LLM
- Prompt Engineering
- AI Tools
- Developer Tools
- File Utility

## Repository Information

Last analyzed by OSRepos: Sat Feb 07 2026 20:01:10 GMT+0000 (Western European Standard Time)
Detail views: 20
GitHub clicks: 13

## Safety Notice

OSRepos shares public repositories for knowledge and discovery only. Review source code, dependencies, licenses, and security implications before running or installing anything.

## Content

## Introduction

`files-to-prompt` is a powerful command-line utility created by Simon Willison that simplifies the process of preparing textual data for Large Language Models (LLMs). It efficiently concatenates the contents of multiple files, or even entire directories, into a single, cohesive output. This tool is particularly useful for developers and researchers who need to feed large amounts of code, documentation, or other text files into LLMs for tasks like code analysis, summarization, or question-answering, ensuring the LLM receives a well-structured context.

## Installation

Installing `files-to-prompt` is straightforward using `pip`:

bash
pip install files-to-prompt


## Examples

Here are some common ways to use `files-to-prompt`:

**Basic Usage:** Concatenate all files in a directory.

bash
files-to-prompt path/to/directory


**Filter by Extension:** Include only files with specific extensions.

bash
files-to-prompt path/to/directory -e py -e js


**Output as Claude XML:** Format the output specifically for Anthropic's Claude LLMs, optimizing for its context window.

bash
files-to-prompt path/to/directory --cxml


**Output as Markdown:** Generate output with fenced code blocks, useful for pasting into Markdown documents.

bash
files-to-prompt path/to/directory --markdown


**Include Line Numbers:** Add line numbers to each file's content in the output.

bash
files-to-prompt path/to/directory -n


**Ignore Files:** Exclude files matching a specific pattern.

bash
files-to-prompt path/to/directory --ignore "*.log"


**Read from Stdin:** Pipe file paths from another command, such as `find`.

bash
find . -name "*.py" -print0 | files-to-prompt --null


## Why Use files-to-prompt?

In the era of powerful LLMs, providing well-structured and relevant context is crucial for obtaining accurate and useful responses. `files-to-prompt` addresses this need by:

*   **Streamlining Context Preparation:** Automatically gathers and formats content from multiple files, saving manual effort.
*   **Optimizing for LLMs:** Offers specific output formats like Claude XML and Markdown, which can improve how LLMs process and understand the provided context.
*   **Flexibility and Control:** Provides extensive options for filtering, ignoring, and customizing the output, allowing users to precisely control what content is included.
*   **Developer-Friendly:** Integrates seamlessly into existing workflows, especially for projects involving codebases or extensive documentation.

## Links

*   **GitHub Repository:** [https://github.com/simonw/files-to-prompt](https://github.com/simonw/files-to-prompt){:target="_blank"}
*   **PyPI:** [https://pypi.org/project/files-to-prompt/](https://pypi.org/project/files-to-prompt/){:target="_blank"}
*   **Background Article:** [Building files-to-prompt entirely using Claude 3 Opus](https://simonwillison.net/2024/Apr/8/files-to-prompt/){:target="_blank"}