CLI 目录 横向对比 FCRS-1.0 标准 /llms.txt
← 返回 CLI 目录

files-to-prompt

$ files-to-prompt 社区开源 低风险
Simon Willison · Agent 桥接与元工具 · Apache-2.0 · macos / linux / windows

由 Simon Willison 开发的 files-to-prompt(simonw/files-to-prompt)是一款专注的 Unix CLI,可将指定文件、目录或来自标准输入的文件路径列表整合为干净的提示词文本。原生支持 -e 扩展名过滤、--ignore 排除、-c(--cxml)Claude XML 标签、-m Markdown 代码块及自动遵循 .gitignore。

FCRS-1.0 综合评分
90 /100
极佳 (Excellent)
中置信度 (源码/文档)
零摩擦安装命令
brew install files-to-prompt
CLI vs MCP 选型建议 仅 CLI 可用

files-to-prompt 在 Unix 管道中可与 fd、rg --files 和 ttok 无缝配合,精准组装无冗余的提示词上下文。

Agent 友好度体检单

— 原生 JSON 输出
✓ 字段裁剪
✓ 无头非交互
— 支持 Dry-Run
— 只读模式开关
✓ 支持 NO_COLOR
✓ 自省/Schema 发现
— 官方 SKILL.md

当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。

FCRS-1.0 六维评分拆解

Agent 友好度 23 / 25

纯粹的 Unix 管道设计:默认输出至 stdout,支持 -c/--cxml、-m/--markdown、-e 过滤、--ignore 及 stdin 路径列表。

  • Supports --cxml, --markdown, -e, --ignore, and stdin path lists
安全与权限边界 24 / 25

默认纯只读输出到 stdout(仅传 -o 时才写文件),且自动尊重 .gitignore 忽略规则。

  • Read-only stdout default; automatic .gitignore exclusion
安装与运行摩擦 14 / 15

跨平台支持 Homebrew、PyPI(pip)与 uvx。

  • Published on Homebrew and PyPI (simonw/files-to-prompt)
能力覆盖与边际价值 14 / 15

职责单一锐利,极易与 rg、find、ttok 串联使用。

  • Composable file-to-XML/Markdown prompt assembler
维护与来源背书 8 / 10

由 Simon Willison(simonw/files-to-prompt)以 Apache-2.0 协议维护。

  • Active simonw/files-to-prompt repository
文档与可验证性 7 / 10

仓库 README 与 --help 对所有参数及 stdin 用法说明清晰。

  • Official README at github.com/simonw/files-to-prompt

安全边界、鉴权与放权指南

鉴权方式
无需鉴权
凭证存储位置

无需凭证;纯本地文件系统到标准输出的 Unix 过滤器。

潜在副作用
只读查询 本地写入
费用与配额提示

基于 Apache-2.0 协议 100% 免费开源。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# 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 高频安全命令配方

只读查询(安全推荐)

以 Claude XML 格式打包 TypeScript 文件
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 进行上下文预算控制。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI

Follow 家族生态联动