What it is:
- the interactive TUI/CLI session.
Syntax:
codex
codex "fix the first failing test in this repo"
codex -C /path/to/repoUse when:
- you need exploration;
- you want iterative back-and-forth;
- the task may branch.
Do not use when:
- you need a non-interactive CI step;
- you only need a machine-readable result.
What it is:
- non-interactive execution.
Syntax:
codex exec "run tests, fix the first failure, summarize the changes"Use when:
- you want repeatable one-shot runs;
- shell automation matters;
- you need JSON or structured output.
What it is:
- non-interactive code review.
Syntax:
codex review --uncommitted
codex review --base main
codex review --commit <sha>Use when:
- self-reviewing changes before a commit or PR;
- checking staged, unstaged, or commit-based diffs.
resumecontinues an older session;forkcreates a new branch of thought from an older session.
Use when:
- you want to restore context;
- you want an alternative solution path without destroying the original one.
- quick auth health check.
- generate shell completion scripts.
Example:
codex completion bash
codex completion zsh- set the working root explicitly;
- use it when the repo is not your current directory.
- pin the model explicitly;
- use it when repeatability matters.
- load a profile from
config.toml; - use it for repeatable modes such as
review,fast, ordeep.
- control filesystem access;
- common modes:
read-only,workspace-write,danger-full-access.
- control command confirmation behavior;
on-requestis usually a good default for interactive use.
- enable web search;
- use it only when the task truly needs fresh external facts.
- low-friction automatic mode;
- use it only in a trusted repo with a narrow, well-defined task.
codex -C /path/to/repoThen start with:
Study the repository first. Find the entrypoint, tests, run commands, and main risks. Do not change anything before a short plan.
- https://developers.openai.com/codex/cli
- local
codex --help,codex exec --help,codex review --help