> codex
OpenAI's coding agent in your terminal — run interactive sessions, script it with codex exec, and control exactly how much it can touch with approvals and sandboxing
// getting started
6 commandsInstall the Codex CLI
$ npm install -g @openai/codexSign in with your ChatGPT account
$ codex loginAuthenticate with an OpenAI API key
$ printenv OPENAI_API_KEY | codex login --with-api-keyCheck which account is signed in or sign out
$ codex login statusStart Codex in your project
$ codexUpdate Codex and check its version
$ codex update// interactive sessions
6 commandsResume a previous session
$ codex resumeFork a session into a new branch
$ codex forkPick a model for the run
$ codex -m gpt-5.6-sol "refactor the auth module"Attach a screenshot to your prompt
$ codex -i mockup.png "build this screen"Point Codex at another directory
$ codex -C ~/projects/api "review this service"Let Codex search the web
$ codex --search "find the current recommended way to configure Vite"// exec & automation
8 commandsRun a one-off task without the TUI
$ codex exec "fix the failing unit tests"Pipe a file or command output into Codex
$ cat error.log | codex exec "diagnose this stack trace"Stream machine-readable JSON events
$ codex exec --json "list the top 5 risky files" | jqSave the final answer to a file
$ codex exec "write release notes for the last 10 commits" -o notes.mdForce a structured JSON result
$ codex exec "extract project metadata" --output-schema schema.json -o meta.jsonResume a non-interactive session
$ codex exec resume --last "now fix the issues you found"Run Codex in CI without a login prompt
$ printenv OPENAI_API_KEY | codex login --with-api-keyApply a Codex Cloud task diff locally
$ codex cloud// approvals & sandbox
6 commandsChoose what the sandbox can touch
$ codex --sandbox read-only "audit this code for injection bugs"Control when Codex stops to ask
$ codex --ask-for-approval on-request "refactor and run the tests"Let Codex work unattended in the workspace
$ codex --full-auto "run the tests and fix whatever breaks"Bypass every guardrail
$ codex --yolo "set up the dev environment from scratch"Grant the sandbox extra write or network access
$ codex --add-dir ../shared-lib "update the shared types"Change permissions mid-session
$ /permissions// configuration
5 commandsFind and edit the config file
$ cat ~/.codex/config.tomlSet your default model and reasoning effort
$ /modelOverride any setting for a single run
$ codex -c sandbox_mode="read-only" "just review, do not touch anything"Keep separate setups with profiles
$ codex --profile ci "run the checks"Give Codex project-specific instructions
$ /init