Skip to content
Checked against codex-cli 0.146.0 · October 9, 2026

How to resume Codex non-interactively

Use codex exec resume with a session ID or --last, send a prompt argument or stdin, and understand how --all and ephemeral execution affect automation.

Short answer

Use codex exec resume <session-id> "prompt" to continue a saved Codex session without the interactive UI. Use --last only when the newest recorded session is the intended one. A prompt of - reads stdin. Add --all when selecting the last session across directories, and --json when a program needs JSONL events.

When to use it

The exec form is designed for scripts and pipelines: it sends one instruction, streams output, and exits. It is distinct from interactive codex resume, which opens the TUI and can show a picker.

Use it safely

1. Prefer an explicit session

Store the session UUID from the workflow that created it and pass that value on the next run. This avoids coupling automation to whichever human or scheduled task happened to run most recently.

codex exec resume <session-id> "Run the focused test and report the remaining failure."

2. Pipe bounded input with a dash

A positional dash tells Codex to read the next instruction from standard input. Review what the producer emits; piping an unrestricted log or diff can overflow context or disclose data the task does not need.

git diff -- src/checkout.py | codex exec resume <session-id> -

3. Choose machine-readable output when needed

--json prints JSONL events for a consumer. --output-last-message writes the final response to a file, while --ephemeral runs without persisting new session files. Pick persistence deliberately.

codex exec resume --json --output-last-message result.txt <session-id> "Summarize the verified result."

Important distinctions

  • The resume subcommand still executes agent tools under its configured approval and sandbox policy; non-interactive does not mean harmless.
  • --last normally follows directory filtering. Use --all only when cross-directory newest is truly what the script intends.
  • A resumed exec run may be omitted from ordinary interactive pickers unless the picker includes non-interactive sessions.

Where Crowsnest fits

Crowsnest includes non-interactive Codex runs in its local gallery by asking app-server for those source kinds. It does not turn arbitrary shell pipelines into managed Crowsnest tasks.

Source and version

The exact text and flags on this page were checked against the installed codex-cli 0.146.0 binary on October 9, 2026. Version-specific behavior can change, so compare your own --help output before scripting around it. Official CLI documentation →

Reviewed from first-party CLI output and the released Crowsnest product source. No command on this page bypasses provider limits, billing, authentication, or native history rules.