files-to-prompt
$ files-to-prompt Community Low RiskCreated by Simon Willison (simonw/files-to-prompt), this focused Unix CLI turns one or more files, directories, or stdin file lists into clean prompt text. Supports -e extension filters, --ignore globs, -c (--cxml) Claude XML tags, -m Markdown fences, and .gitignore respect.
brew install files-to-prompt files-to-prompt pairs cleanly with fd, rg --files, and ttok in Unix pipelines to assemble exact prompt context without bloat.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Pure Unix-pipe ergonomics: stdout default, -c/--cxml, -m/--markdown, -e extension filter, --ignore, and stdin file lists.
- Supports
--cxml,--markdown,-e,--ignore, and stdin path lists
Read-only stdout stream by default (only writes if -o is explicitly passed) and honors .gitignore automatically.
- Read-only stdout default; automatic
.gitignoreexclusion
Available via Homebrew, PyPI (pip), and uvx across macOS, Linux, and Windows.
- Published on Homebrew and PyPI (
simonw/files-to-prompt)
Sharp single-purpose Unix tool that composes effortlessly with rg, find, and ttok.
- Composable file-to-XML/Markdown prompt assembler
Maintained by Simon Willison (simonw/files-to-prompt) under Apache-2.0.
- Active
simonw/files-to-promptrepository
Clear README and --help documenting all flags and stdin formats.
- Official README at github.com/simonw/files-to-prompt
Security, Auth & Guardrails
None; pure local filesystem-to-stdout Unix filter.
100% free and Apache-2.0 open-source.
# 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-Ready Command Recipes
Safe Read-Only Queries
files-to-prompt src/ -e ts -e tsx --cxml
Emits <documents><document> XML blocks for .ts/.tsx files while respecting .gitignore.
rg --files selection with Markdown output rg --files -g '*.py' | files-to-prompt -m --ignore '*test*'
Accepts file paths from stdin and formats non-test Python files as Markdown.
Controlled Writes & Previews
files-to-prompt src/ -e md -m -o docs-context.md
Writes the formatted prompt bundle directly to docs-context.md via -o.
Strengths for Agents
- +
--cxml(-c) outputs clean Claude-optimized<document>XML tags. - + Accepts file lists via stdin (
rg --files | files-to-prompt) and null-delimited-0input. - + Respects
.gitignoreout of the box with granular-eand--ignorefilters.
Caveats & Pitfalls
- ! Does not count tokens itself—pair with
ttokfor token budgeting.