promptgarten ๐ŸŒฑ
๐ŸŒ ES

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.

โœ… 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