العربية
Back

AI

Codex CLI Global Flags Reference

The main global flags in the Codex CLI with what each does, from OpenAI's official reference, and which ones are risky.

Last reviewed:

What this page is

A reference for the global flags usable with codex, as OpenAI lists them in the developer commands reference. We state each meaning in our own words and leave the full table and per-subcommand details (such as codex exec, codex review, codex mcp and codex cloud) to the official page.

Access and config flags

  • Flag --add-dir: grant additional directories write access alongside the main workspace. Repeat for multiple paths.
  • Flag --ask-for-approval, -a: on-request or never: when Codex pauses for human approval before running a command.
  • Flag --approve-for-me, --not-so-yolo: automatic approval review with on-request approvals and the workspace-write sandbox. Conflicts with --sandbox and --yolo.
  • Flag --cd, -C: set the working directory before the agent starts.
  • Flag --config, -c: override config values as key=value, parsed as TOML when possible.
  • Flag --sandbox, -s: read-only, workspace-write or danger-full-access for model-generated shell commands.
  • Flag --search: enable live web search (web_search = live instead of cached).
  • Flag --image, -i: attach images to the initial prompt, comma-separated or by repeating the flag.

Other flags

  • Flag --profile, -p: layer the profile-name.config.toml file from the CODEX_HOME folder on top of the base user config.
  • Flag --model, -m: override the model set in configuration.
  • Flag --worktree: start in a new managed Git worktree; requires local execution.
  • Flag --strict-config: error when config.toml has fields this Codex does not recognize.
  • Flag --oss and --local-provider: use a local open source provider (lmstudio or ollama).
  • Flag --remote: connect to a remote app-server endpoint over WebSocket or a Unix socket; --remote-auth-token-env reads a bearer token from an environment variable, sent only over wss:// or local-only ws:// URLs.
  • The flag that skips approvals and the sandbox (named in the official CLI reference, with a yolo alias): runs every command without approvals or sandboxing. Only inside an externally hardened environment.
  • The flag that bypasses hook trust (in the official reference): runs enabled hooks without persisted trust, only for automation that vets hook sources.

Risky flags

Three flags remove protection: the flag that skips approvals and the sandbox, the flag that bypasses hook trust, and the sandbox flag set to danger-full-access, which gives full file and network access. Our tip: use them only inside an isolated container.

Common combinations

  1. Read-only: --sandbox read-only.
  2. Work in the project with prompts: --sandbox workspace-write --ask-for-approval on-request.
  3. For one extra writable folder: add --add-dir with the path.
  4. To try a config value: --config key=value.

Common mistakes

  • Combining --approve-for-me with --sandbox or --yolo, which conflict per the reference.
  • Using --remote over a public network without wss://, since the token is only sent over wss:// or local ws://.

Next steps

  • For non-interactive runs: exec scripts and CI.
  • For permanent settings: config basics.

Latest updates

No dated update on this topic was found on the official page read on 2026-11-30. We add updates when they appear.

Similar tools

Standalone pages for similar items are added after their official sources are read. We name nothing without a full page.

Related pages

Sources

Wording is ours, from the official source. Images and video belong to their owners and are credited with a link to the official page.

#ai#codex#cli#flags#reference#dev

Frequently asked questions

--sandbox vs --ask-for-approval?

The first sets what a command can access (read-only, workspace-write or danger-full-access); the second sets when Codex pauses to ask (on-request or never). (OpenAI)

Codex: Sandbox, Approvals and Network Access

Should I use --yolo?

OpenAI says it runs every command without approvals or sandboxing and should only be used in an externally hardened environment. (OpenAI)

Codex exec: Run Codex in Scripts and CI

How do I try a setting once?

With --config key=value to override a value for this run without editing the file. (OpenAI)

Codex Config Basics: config.toml and Precedence