Command reference Β· Codex CLI
codex exec
Runs Codex non-interactively, e.g. for scripts or CI.
codex exec (short form: e) runs a task non-interactively without opening the TUI. You can also pass '-' as the prompt to read input from stdin. With --json, events are output as JSONL; with -o/--output-last-message, only the last message is saved; and with --output-schema, an output schema is enforced.
π¬ AS A SHORT VIDEO
Runs Codex non-interactively, e.g. for scripts or CI.
π THE SAME TASK (βSTART HEADLESS/NON-INTERACTIVEβ) ON OTHER PLATFORMS
- Antigravity CLI: agy -p / --print
β WHEN TO USE IT?
Integrate Codex into a script or pipeline
codex exec "summarize the changes from the last commits" --json
Pipe input from another source via stdin
cat task.txt | codex exec -
β WHEN NOT TO?
You want to steer interactively, e.g. answer follow-up questions live
codex exec runs through without interactive follow-up questions.
Better: Start the normal TUI with codex (without exec)
SOURCES
- Codex CLI docs: Non-interactive Mode β learn.chatgpt.com