[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-72406":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":24,"hasPages":22,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":26,"readmeContent":27,"aiSummary":28,"trendingCount":16,"starSnapshotCount":16,"syncStatus":29,"lastSyncTime":30,"discoverSource":31},72406,"files-to-prompt","simonw\u002Ffiles-to-prompt","simonw","Concatenate a directory full of files into a single prompt for use with LLMs","",null,"Python",2744,176,26,13,0,1,10,3,28.74,"Apache License 2.0",false,"main",true,[],"2026-06-12 02:03:02","# files-to-prompt\n\n[![PyPI](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fv\u002Ffiles-to-prompt.svg)](https:\u002F\u002Fpypi.org\u002Fproject\u002Ffiles-to-prompt\u002F)\n[![Changelog](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fv\u002Frelease\u002Fsimonw\u002Ffiles-to-prompt?include_prereleases&label=changelog)](https:\u002F\u002Fgithub.com\u002Fsimonw\u002Ffiles-to-prompt\u002Freleases)\n[![Tests](https:\u002F\u002Fgithub.com\u002Fsimonw\u002Ffiles-to-prompt\u002Factions\u002Fworkflows\u002Ftest.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fsimonw\u002Ffiles-to-prompt\u002Factions\u002Fworkflows\u002Ftest.yml)\n[![License](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-Apache%202.0-blue.svg)](https:\u002F\u002Fgithub.com\u002Fsimonw\u002Ffiles-to-prompt\u002Fblob\u002Fmaster\u002FLICENSE)\n\nConcatenate a directory full of files into a single prompt for use with LLMs\n\nFor background on this project see [Building files-to-prompt entirely using Claude 3 Opus](https:\u002F\u002Fsimonwillison.net\u002F2024\u002FApr\u002F8\u002Ffiles-to-prompt\u002F).\n\n## Installation\n\nInstall this tool using `pip`:\n\n```bash\npip install files-to-prompt\n```\n\n## Usage\n\nTo use `files-to-prompt`, provide the path to one or more files or directories you want to process:\n\n```bash\nfiles-to-prompt path\u002Fto\u002Ffile_or_directory [path\u002Fto\u002Fanother\u002Ffile_or_directory ...]\n```\n\nThis will output the contents of every file, with each file preceded by its relative path and separated by `---`.\n\n### Options\n\n- `-e\u002F--extension \u003Cextension>`: Only include files with the specified extension. Can be used multiple times.\n\n  ```bash\n  files-to-prompt path\u002Fto\u002Fdirectory -e txt -e md\n  ```\n\n- `--include-hidden`: Include files and folders starting with `.` (hidden files and directories).\n\n  ```bash\n  files-to-prompt path\u002Fto\u002Fdirectory --include-hidden\n  ```\n\n- `--ignore \u003Cpattern>`: Specify one or more patterns to ignore. Can be used multiple times. Patterns may match file names and directory names, unless you also specify `--ignore-files-only`. Pattern syntax uses [fnmatch](https:\u002F\u002Fdocs.python.org\u002F3\u002Flibrary\u002Ffnmatch.html), which supports `*`, `?`, `[anychar]`, `[!notchars]` and `[?]` for special character literals.\n  ```bash\n  files-to-prompt path\u002Fto\u002Fdirectory --ignore \"*.log\" --ignore \"temp*\"\n  ```\n\n- `--ignore-files-only`: Include directory paths which would otherwise be ignored by an `--ignore` pattern.\n\n  ```bash\n  files-to-prompt path\u002Fto\u002Fdirectory --ignore-files-only --ignore \"*dir*\"\n  ```\n\n- `--ignore-gitignore`: Ignore `.gitignore` files and include all files.\n\n  ```bash\n  files-to-prompt path\u002Fto\u002Fdirectory --ignore-gitignore\n  ```\n\n- `-c\u002F--cxml`: Output in Claude XML format.\n\n  ```bash\n  files-to-prompt path\u002Fto\u002Fdirectory --cxml\n  ```\n\n- `-m\u002F--markdown`: Output as Markdown with fenced code blocks.\n\n  ```bash\n  files-to-prompt path\u002Fto\u002Fdirectory --markdown\n  ```\n\n- `-o\u002F--output \u003Cfile>`: Write the output to a file instead of printing it to the console.\n\n  ```bash\n  files-to-prompt path\u002Fto\u002Fdirectory -o output.txt\n  ```\n\n- `-n\u002F--line-numbers`: Include line numbers in the output.\n\n  ```bash\n  files-to-prompt path\u002Fto\u002Fdirectory -n\n  ```\n  Example output:\n  ```\n  files_to_prompt\u002Fcli.py\n  ---\n    1  import os\n    2  from fnmatch import fnmatch\n    3\n    4  import click\n    ...\n  ```\n\n- `-0\u002F--null`: Use NUL character as separator when reading paths from stdin. Useful when filenames may contain spaces.\n\n  ```bash\n  find . -name \"*.py\" -print0 | files-to-prompt --null\n  ```\n\n### Example\n\nSuppose you have a directory structure like this:\n\n```\nmy_directory\u002F\n├── file1.txt\n├── file2.txt\n├── .hidden_file.txt\n├── temp.log\n└── subdirectory\u002F\n    └── file3.txt\n```\n\nRunning `files-to-prompt my_directory` will output:\n\n```\nmy_directory\u002Ffile1.txt\n---\nContents of file1.txt\n---\nmy_directory\u002Ffile2.txt\n---\nContents of file2.txt\n---\nmy_directory\u002Fsubdirectory\u002Ffile3.txt\n---\nContents of file3.txt\n---\n```\n\nIf you run `files-to-prompt my_directory --include-hidden`, the output will also include `.hidden_file.txt`:\n\n```\nmy_directory\u002F.hidden_file.txt\n---\nContents of .hidden_file.txt\n---\n...\n```\n\nIf you run `files-to-prompt my_directory --ignore \"*.log\"`, the output will exclude `temp.log`:\n\n```\nmy_directory\u002Ffile1.txt\n---\nContents of file1.txt\n---\nmy_directory\u002Ffile2.txt\n---\nContents of file2.txt\n---\nmy_directory\u002Fsubdirectory\u002Ffile3.txt\n---\nContents of file3.txt\n---\n```\n\nIf you run `files-to-prompt my_directory --ignore \"sub*\"`, the output will exclude all files in `subdirectory\u002F` (unless you also specify `--ignore-files-only`):\n\n```\nmy_directory\u002Ffile1.txt\n---\nContents of file1.txt\n---\nmy_directory\u002Ffile2.txt\n---\nContents of file2.txt\n---\n```\n\n### Reading from stdin\n\nThe tool can also read paths from standard input. This can be used to pipe in the output of another command:\n\n```bash\n# Find files modified in the last day\nfind . -mtime -1 | files-to-prompt\n```\n\nWhen using the `--null` (or `-0`) option, paths are expected to be NUL-separated (useful when dealing with filenames containing spaces):\n\n```bash\nfind . -name \"*.txt\" -print0 | files-to-prompt --null\n```\n\nYou can mix and match paths from command line arguments and stdin:\n\n```bash\n# Include files modified in the last day, and also include README.md\nfind . -mtime -1 | files-to-prompt README.md\n```\n\n### Claude XML Output\n\nAnthropic has provided [specific guidelines](https:\u002F\u002Fdocs.anthropic.com\u002Fclaude\u002Fdocs\u002Flong-context-window-tips) for optimally structuring prompts to take advantage of Claude's extended context window.\n\nTo structure the output in this way, use the optional `--cxml` flag, which will produce output like this:\n\n```xml\n\u003Cdocuments>\n\u003Cdocument index=\"1\">\n\u003Csource>my_directory\u002Ffile1.txt\u003C\u002Fsource>\n\u003Cdocument_content>\nContents of file1.txt\n\u003C\u002Fdocument_content>\n\u003C\u002Fdocument>\n\u003Cdocument index=\"2\">\n\u003Csource>my_directory\u002Ffile2.txt\u003C\u002Fsource>\n\u003Cdocument_content>\nContents of file2.txt\n\u003C\u002Fdocument_content>\n\u003C\u002Fdocument>\n\u003C\u002Fdocuments>\n```\n\n## --markdown fenced code block output\n\nThe `--markdown` option will output the files as fenced code blocks, which can be useful for pasting into Markdown documents.\n\n```bash\nfiles-to-prompt path\u002Fto\u002Fdirectory --markdown\n```\nThe language tag will be guessed based on the filename.\n\nIf the code itself contains triple backticks the wrapper around it will use one additional backtick.\n\nExample output:\n`````\nmyfile.py\n```python\ndef my_function():\n    return \"Hello, world!\"\n```\nother.js\n```javascript\nfunction myFunction() {\n    return \"Hello, world!\";\n}\n```\nfile_with_triple_backticks.md\n````markdown\nThis file has its own\n```\nfenced code blocks\n```\nInside it.\n````\n`````\n\n## Development\n\nTo contribute to this tool, first checkout the code. Then create a new virtual environment:\n\n```bash\ncd files-to-prompt\npython -m venv venv\nsource venv\u002Fbin\u002Factivate\n```\n\nNow install the dependencies and test dependencies:\n\n```bash\npip install -e '.[test]'\n```\n\nTo run the tests:\n\n```bash\npytest\n```\n","files-to-prompt 是一个用于将目录中的多个文件合并成单个提示的工具，适用于与大语言模型（LLMs）交互。其核心功能是通过命令行接口读取指定路径下的文件内容，并以统一格式输出，支持多种选项来定制输出结果，如过滤特定扩展名、包含隐藏文件、忽略模式匹配等。此外，它还提供了以Claude XML或Markdown格式输出以及将结果写入文件的功能。此项目适合需要批量处理文本文件并生成结构化输入给AI模型的应用场景，例如代码审查、文档分析等。",2,"2026-06-11 03:41:55","high_star"]