Support STDIN as PROMPT for large input
Open 💬 7 comments Opened May 26, 2025 by doggy8088
This is a feature suggestion.
When I need to input a lot of prompt content, I hope to have the following methods to replace directly passing in the last argument:
- STDIN
``sh``
cat PROMPT.md | codex
- Specify a file
``sh``
codex --file PROMPT.md
7 Comments
For me codex freezes when I pass in the stdin.
You can use
``
codex "$(cat <prompt-file>)"``but having it use stdio would open up some pretty powerful tool chaining. Should probably run in headless mode for this.
I wasn't using the
execsubcommand hence codex used to freeze. But now this workes for me:@surajssd I tested. The
codexwill not read STDIN from thegit diff --cachedcommand output when there is a PROMPT in the argument.@easong-openai I wish
codexcan read both STDIN and the PROMPT.@doggy8088 you are right, I tried to recreate the same issue and I can now see that codex is running
git diff --stagedagain. I had a wrong assumption that it was readingSTDIN.Finally when running the command:
To address why running
codex "$(cat <prompt-file>)"is not a valid solution, if you run it on large prompt files, you get this error:Note: This is on windows, so I'm using Get-Content instead of cat, but I see a similar error on linux and macOS when using cat.
The title of this issue even says "for large input". One of the main reasons I use STDIN for claude and copilot CLI is to automate passing large prompts with a lot of context, or even just pass the output of a long log file. Not accepting STDIN is a serious limitation with codex.
I implemented stdin/file prompt input support in my fork, xCodex (xcodex). If you need this today, you can try it as a workaround (it’s still WIP and may have bugs): https://github.com/Eriz1818/xCodex.
If maintainers are interested in bringing this upstream, I’m happy to open a proposal/PR and adapt it to match Codex’s contribution guidelines and desired behaviour (I understand new feature PRs may not be accepted right now). I’ve tested with PROMPT.md files up to ~1MB. Both xcodex exec (non-interactive) and xcodex (interactive) can be used.
1) Prompt as a file (large prompts)
xcodex exec --file PROMPT.md
2) Prompt via stdin (pipe)
cat PROMPT.md | xcodex exec -
3) Prompt via stdin (heredoc)
xcodex exec - <<'EOF'
Write a one-paragraph summary of this repository.
EOF