{"name":"files-to-prompt: Concatenate Files into a Single Prompt for LLMs","description":"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","url":"https://osrepos.com/repo/simonw-files-to-prompt","source":"osrepos.com","sourceDescription":"This repository profile is provided by osrepos.com, an open source repository discovery platform.","repositoryProfile":"https://osrepos.com/repo/simonw-files-to-prompt","generatedFor":"open source discovery and AI-assisted research","markdown":"https://osrepos.com/repo/simonw-files-to-prompt.md","json":"https://osrepos.com/repo/simonw-files-to-prompt.json","topics":["Python","CLI","LLM","Prompt Engineering","AI Tools","Developer Tools","File Utility"],"keywords":["Python","CLI","LLM","Prompt Engineering","AI Tools","Developer Tools","File Utility"],"stars":null,"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.","content":"## Introduction\n\n`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.\n\n## Installation\n\nInstalling `files-to-prompt` is straightforward using `pip`:\n\nbash\npip install files-to-prompt\n\n\n## Examples\n\nHere are some common ways to use `files-to-prompt`:\n\n**Basic Usage:** Concatenate all files in a directory.\n\nbash\nfiles-to-prompt path/to/directory\n\n\n**Filter by Extension:** Include only files with specific extensions.\n\nbash\nfiles-to-prompt path/to/directory -e py -e js\n\n\n**Output as Claude XML:** Format the output specifically for Anthropic's Claude LLMs, optimizing for its context window.\n\nbash\nfiles-to-prompt path/to/directory --cxml\n\n\n**Output as Markdown:** Generate output with fenced code blocks, useful for pasting into Markdown documents.\n\nbash\nfiles-to-prompt path/to/directory --markdown\n\n\n**Include Line Numbers:** Add line numbers to each file's content in the output.\n\nbash\nfiles-to-prompt path/to/directory -n\n\n\n**Ignore Files:** Exclude files matching a specific pattern.\n\nbash\nfiles-to-prompt path/to/directory --ignore \"*.log\"\n\n\n**Read from Stdin:** Pipe file paths from another command, such as `find`.\n\nbash\nfind . -name \"*.py\" -print0 | files-to-prompt --null\n\n\n## Why Use files-to-prompt?\n\nIn 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:\n\n*   **Streamlining Context Preparation:** Automatically gathers and formats content from multiple files, saving manual effort.\n*   **Optimizing for LLMs:** Offers specific output formats like Claude XML and Markdown, which can improve how LLMs process and understand the provided context.\n*   **Flexibility and Control:** Provides extensive options for filtering, ignoring, and customizing the output, allowing users to precisely control what content is included.\n*   **Developer-Friendly:** Integrates seamlessly into existing workflows, especially for projects involving codebases or extensive documentation.\n\n## Links\n\n*   **GitHub Repository:** [https://github.com/simonw/files-to-prompt](https://github.com/simonw/files-to-prompt){:target=\"_blank\"}\n*   **PyPI:** [https://pypi.org/project/files-to-prompt/](https://pypi.org/project/files-to-prompt/){:target=\"_blank\"}\n*   **Background Article:** [Building files-to-prompt entirely using Claude 3 Opus](https://simonwillison.net/2024/Apr/8/files-to-prompt/){:target=\"_blank\"}","metrics":{"detailViews":20,"githubClicks":13},"dates":{"published":null,"modified":"2026-02-07T20:01:10.000Z"}}