How do I run external commands on files before packing with repomix?
I want repomix to transform files before packing them, for example converting JSON files to TOON format to reduce tokens for LLMs. The GitHub issue proposed a
fileProcessorsconfig that runs an external command on matched files. Is this feature available, and what is the working configuration as of repomix v1.17.0?Originally asked on GitHub: https://github.com/yamadashy/repomix/issues/933
3 answers
Fixed in repomix v1.17.0, shipped as
input.processors(the issue's proposedfileProcessorsname was not used).Working configuration from the maintainer's release note:
json{ "input": { "processors": [ { "pattern": "**/*.json", "command": "npx @toon-format/cli {file}" } ] } }The mechanism described in the issue: files matching the glob are written to a temp file,
{file}in the command is replaced with that path, the command runs, and its stdout replaces the file content in the packed result. The maintainer also confirmed the PDF-to-markdown preprocessing use case works with this design.Security model from the maintainer's notes: command execution is off by default everywhere (library
pack()/collectFiles(), MCP, hosted website) and auto-enabled only for an explicit local CLI run. Remote repository configs require--remote-trust-config; MCPpack_remote_repositoryand repomix.com never load such configs. Active processors are logged at startup. Local CLI use has the same trust boundary as npm scripts or Makefiles. In the design checklist before shipping, the maintainer plannedchild_process.execFile/spawnwith an argv array rather thanexecto avoid shell injection from file paths.Did this work for you?What @yamadashy tried on GitHub (Worked)
The maintainer shipped the feature in repomix v1.17.0 under
input.processorswith the exact config shape shown in the release note and docs.Source: https://github.com/yamadashy/repomix/issues/933#issuecomment-5077396541 (opens external site)
Did this work for you?What @Benexl tried on GitHub (Worked)
A commenter suggested the external-command mechanism could also preprocess PDFs to markdown before packing; the maintainer later confirmed this use case works with the shipped design.
Source: https://github.com/yamadashy/repomix/issues/933#issuecomment-3508123905 (opens external site)
Did this work for you?
Related questions
- How to pack a remote repository from a specific branch or commit in repomix?
- How to pack only currently open files in VSCode with Repomix?
- Repomix: how to split packed output into multiple files for large codebases?
- Can I use multiple named configs in repomix.config.json for subdirectories?
- How to set per-file inclusion levels (full, compressed, directory-only) in repomix?