Codex Command Line Tool (CLI)

The CLI is useful for terminal-first workflows, scripting, CI, and power users.

Start And Basic Usage

codex

Run from the repository you want Codex to inspect, or pass a working directory when supported.

Subcommands

Common subcommands include interactive sessions, non-interactive exec, login/logout, and diagnostic commands.

Common Flags

Use flags and -c overrides to set model, permissions, working directory, and feature behavior for one run.

CLI Configuration

The CLI reads config.toml from CODEX_HOME unless overridden.

CLI Sandbox And Safety

Use read-only mode for planning and workspace-write for normal local coding. Avoid full access unless you trust the environment.

sandbox_mode = "workspace-write"
approval_policy = "on-request"

CLI Skills

Skills work in the CLI as specialized instruction bundles. Invoke them explicitly or let Codex trigger them when appropriate.

CLI Model Selection

Switch models through config, flags, or session commands such as /model when available.

CLI Prompting Tips

  • State the goal and verification command.
  • Mention files or directories.
  • Keep constraints explicit.
  • Ask for a concise final summary.

CLI Practical Examples

codex exec "Find the failing test, fix the bug, and run the related test only."
codex exec "Review this branch for regressions and list findings with file lines."

Next Steps

Finish with Resources.

评论