files-to-prompt
$ files-to-prompt 社区开源 低风险由 Simon Willison 开发的 files-to-prompt(simonw/files-to-prompt)是一款专注的 Unix CLI,可将指定文件、目录或来自标准输入的文件路径列表整合为干净的提示词文本。原生支持 -e 扩展名过滤、--ignore 排除、-c(--cxml)Claude XML 标签、-m Markdown 代码块及自动遵循 .gitignore。
brew install files-to-prompt files-to-prompt 在 Unix 管道中可与 fd、rg --files 和 ttok 无缝配合,精准组装无冗余的提示词上下文。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
纯粹的 Unix 管道设计:默认输出至 stdout,支持 -c/--cxml、-m/--markdown、-e 过滤、--ignore 及 stdin 路径列表。
- Supports
--cxml,--markdown,-e,--ignore, and stdin path lists
默认纯只读输出到 stdout(仅传 -o 时才写文件),且自动尊重 .gitignore 忽略规则。
- Read-only stdout default; automatic
.gitignoreexclusion
跨平台支持 Homebrew、PyPI(pip)与 uvx。
- Published on Homebrew and PyPI (
simonw/files-to-prompt)
职责单一锐利,极易与 rg、find、ttok 串联使用。
- Composable file-to-XML/Markdown prompt assembler
由 Simon Willison(simonw/files-to-prompt)以 Apache-2.0 协议维护。
- Active
simonw/files-to-promptrepository
仓库 README 与 --help 对所有参数及 stdin 用法说明清晰。
- Official README at github.com/simonw/files-to-prompt
安全边界、鉴权与放权指南
无需凭证;纯本地文件系统到标准输出的 Unix 过滤器。
基于 Apache-2.0 协议 100% 免费开源。
# files-to-prompt Agent Rules - Always scope inputs with `-e <ext>`, `--ignore <glob>`, or piped `rg --files` paths. - Use `-c` (`--cxml`) or `-m` (`--markdown`) for clear file boundary delimiters. - Pipe into `ttok` when checking token budget before passing output to an LLM.
Agent 高频安全命令配方
只读查询(安全推荐)
files-to-prompt src/ -e ts -e tsx --cxml
遵循 .gitignore 并为 .ts/.tsx 文件生成 <documents><document> XML 块。
rg --files 筛选输出 Markdown 块 rg --files -g '*.py' | files-to-prompt -m --ignore '*test*'
从标准输入接收文件路径列表,将非测试 Python 文件格式化为 Markdown。
受控写入与预演
files-to-prompt src/ -e md -m -o docs-context.md
通过 -o 直接将格式化结果保存至 docs-context.md。
核心优势
- +
--cxml(-c)直接生成结构清晰的<document>XML 分隔标签。 - + 支持从 stdin 接收文件清单(
rg --files | files-to-prompt)及-0空字符分隔。 - + 开箱即用遵循
.gitignore,并提供细粒度-e与--ignore过滤。
注意事项与踩坑点
- ! 自身不统计 Token 数——需串联
ttok进行上下文预算控制。