Support STDIN as PROMPT for large input
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
cat PROMPT.md | codex -
Specify a file
codex --file PROMPT.md
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 exec subcommand hence codex used to freeze. But now this workes for me:
➜ git diff --cached | codex exec "Write a commit message for these staged changes"
I wasn't using the
execsubcommand hence codex used to freeze. But now this workes for me:➜ git diff --cached | codex exec "Write a commit message for these staged changes"
@surajssd I tested. The codex will not read STDIN from the git diff --cached command output when there is a PROMPT in the argument.
@easong-openai I wish codex can 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 --staged again. I had a wrong assumption that it was reading STDIN.
cd `mktemp -d`
git init
echo "foo" | tee README.md
git status
git add .
git diff --cached
Finally when running the command:
➜ git diff --cached | codex exec "Write a commit message for these staged changes"
[2025-09-04T16:20:04] OpenAI Codex v0.29.0 (research preview)
--------
workdir: /private/var/folders/ls/csbb474j2r9__hhcvmxq0rfh0000gn/T/tmp.g9rYxumPfE
model: grok-3
sandbox: read-only
--------
[2025-09-04T16:20:04] User instructions:
Write a commit message for these staged changes
[2025-09-04T16:20:07] exec git diff --staged in /private/var/folders/ls/csbb474j2r9__hhcvmxq0rfh0000gn/T/tmp.g9rYxumPfE
[2025-09-04T16:20:07] git diff --staged succeeded in 30ms:
diff --git README.md README.md
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ README.md
@@ -0,0 +1 @@
+foo
[2025-09-04T16:20:07] codex
I'll help you write a commit message for the staged changes. Let me check what's been modified.
[2025-09-04T16:20:09] codex
Based on the diff, I see you've added a README.md file with the content "foo". Here's a commit message for these changes:
**Commit Message**
- **README**: Add initial project documentation file
If you'd like me to adjust the tone or content of this message, just let me know!
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:
> codex "$(Get-Content C:\dev\Misc\BuildOutput.txt)"
Program 'node.exe' failed to run: The filename or extension is too longAt C:\Program
Files\nodejs\codex.ps1:16 char:5
+ & "$basedir/node$exe" "$basedir/node_modules/@openai/codex/bin/c ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
At C:\Program Files\nodejs\codex.ps1:16 char:5
+ & "$basedir/node$exe" "$basedir/node_modules/@openai/codex/bin/c ...
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.