convez.ai
MCP ServerProdutividadeIntermediário
jqueryscript

Codex Commands Cheat Sheet

jqueryscript/codex-commands-cheat-sheet

Guia completo de comandos do Codex CLI para desenvolvedores

Ver no GitHub
InicialPluginScore · de 0 a 100

Referência prática de comandos do OpenAI Codex CLI com separação clara entre comandos shell, slash commands interativos, flags, chaves de configuração e variáveis de ambiente. Facilita o uso correto de cada tipo de comando em seu contexto específico.

Instalação

$npx convez-ai jqueryscript/codex-commands-cheat-sheet

1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.

Métricas

Estrelas
3
Forks
0
Acompanhando
0
Saúde
28%
Último commit
há 2 semanas
Versão
—
Issues abertas
0
Contribuidores
1

Casos de uso

  • Consultar sintaxe e flags do Codex CLI durante desenvolvimento
  • Automatizar tarefas de análise e correção de código via CLI
  • Configurar ambientes de desenvolvimento com Codex

Veredito

Cheat sheet útil para quem usa Codex CLI regularmente, com boa organização entre tipos de comando. Porém é uma referência estática e pode ficar desatualizada conforme o Codex evolui — use como complemento à documentação oficial.

README

A tradução para o português deste README ainda está na fila.

Codex Commands Cheat Sheet

A practical command reference for OpenAI Codex CLI. This README separates shell commands, interactive slash commands, CLI flags, configuration keys, environment variables, and experimental features so developers can use each one in the right context.

Codex CLI changes over time. Use the official OpenAI Codex CLI docs as the primary source for command availability. Local codex --help output is useful for checking the installed version, but it can lag behind the latest CLI release or differ from Codex Desktop behavior.

Quick Start

Install Codex CLI:

npm install -g @openai/codex

Sign in:

codex login

Start an interactive session:

codex

Run a non-interactive task:

codex exec "Review this repository and summarize the highest-risk issues"

Resume the latest session:

codex resume --last

Command Types

TypeUsed inExample
CLI commandShellcodex exec "Fix failing tests"
CLI flagShellcodex --model <model>
Slash commandInteractive Codex TUI/status
Config key~/.codex/config.tomlsandbox_mode = "workspace-write"
Environment variableShell environmentCODEX_HOME=~/.codex-dev
Experimental commandShell or TUIcodex mcp-server
Deprecated or legacy itemShell or TUI--full-auto

Installation and Authentication

CommandWhat it doesNotes
npm install -g @openai/codexInstalls Codex CLI with npm.Official install path.
brew install --cask codexInstalls Codex CLI with Homebrew.Official macOS install path.
codex loginStarts the default ChatGPT sign-in flow.Opens a browser when possible.
codex login --device-authUses device-code authentication.Useful for remote or headless environments.
printenv OPENAI_API_KEY | codex login --with-api-keySigns in with an API key from stdin.Keep API keys out of committed files.
codex login statusShows active authentication status.Exits with status 0 when logged in.
codex logoutRemoves stored Codex credentials.Clears stored auth.
codex updateUpdates Codex when supported by the installed build.Version-dependent. Current local help may not list it.

Session Commands

CommandWhat it doesNotes
codexStarts an interactive session.Run from the project root.
codex "Explain this codebase"Starts the TUI with an initial prompt.Useful for analysis sessions.
codex resumeOpens a picker for saved sessions.Scoped to the current directory by default.
codex resume --lastResumes the most recent session.Add --all to ignore directory scope.
codex resume --include-non-interactiveIncludes non-interactive sessions in the picker and --last selection.Stable in current local CLI help.
codex resume <SESSION_ID>Resumes a specific session.Session IDs appear in status and session files.
codex forkForks a previous session.Useful when trying a different approach.
codex fork --lastForks the latest session.Keeps the original session intact.
codex exec resume --last "Continue the fix"Resumes a non-interactive session with a follow-up prompt.Useful for automation.
codex doctorChecks the installed Codex CLI environment.Use when diagnosing local setup issues.

Project and Workspace Commands

CommandWhat it doesNotes
codex --cd <path>Starts Codex in a specific working directory.Also available as -C.
codex --add-dir <path>Grants access to another directory.Repeatable. Prefer this over disabling the sandbox.
codex --image screenshot.png "Fix this UI"Attaches an image to the initial prompt.Also available as -i.
codex completion zshPrints shell completions.Supports bash, zsh, fish, powershell, and elvish.
codex appOpens Codex Desktop from the terminal.Listed in current official docs; local CLI behavior may vary by install.
codex app <PATH>Opens a workspace path in Codex Desktop.Listed in current official docs.
codex app --download-urlPrints the Codex Desktop download URL.Listed in current official docs.

Interactive Slash Commands

Slash commands work inside the interactive Codex TUI. They are not shell commands.

CommandWhat it doesNotes
/statusShows model, approval policy, sandbox, writable roots, token usage, and session details.First command to run when diagnosing a session.
/modelChanges model and reasoning effort when available.TUI-only.
/ideManages IDE integration when available.TUI-only and feature-dependent.
/goalSets or views an experimental goal for a long-running task.Official slash command. Requires features.goals.
/permissionsChanges approval behavior during a session.TUI-only.
/approveApproves a pending action when a session is waiting for approval.TUI-only.
/rawSends raw input without Codex command parsing.TUI-only.
/diffShows current Git diff, including untracked files.Useful before review or commit.
/reviewReviews the current working tree.Focuses on bugs, regressions, and missing tests.
/resumeOpens a saved-session picker.TUI equivalent of codex resume.
/newStarts a new conversation.Keeps the CLI open.
/clearClears the terminal and starts a fresh chat.Different from only clearing the screen.
/compactSummarizes earlier context to reduce context usage.Useful during long sessions.
/mention <path>Adds a file or folder to the conversation.Helps focus Codex on specific code.
/initGenerates an AGENTS.md scaffold.Review before committing.
/mcpLists available MCP tools.Add verbose for more detail.
/statuslineConfigures TUI footer fields.Persists to tui.status_line.
/titleConfigures terminal title fields.Persists to tui.terminal_title.
/keymapRemaps TUI keyboard shortcuts.Persists to tui.keymap.
/themeChanges the TUI color theme.TUI-only.
/vimToggles Vim keybindings.TUI-only.
/memoriesOpens memory management when available.Feature-dependent.
/skillsOpens installed skills when available.Feature-dependent.
/hooksOpens hook configuration when available.Feature-dependent.
/agentCreates, switches, lists, or manages delegated agents when available.Feature-dependent.
/psLists background terminals or tasks when available.Feature-dependent.
/stopStops running tasks when available.Feature-dependent.
/logoutSigns out of Codex from inside the TUI.TUI-only.
/feedbackOpens feedback flow from inside the TUI.TUI-only.
/exitExits Codex.Alias of /quit.

Code Editing and Review

CommandWhat it doesNotes
codex exec "Run tests and fix failures"Runs Codex non-interactively until the task finishes.Good for scripted repair tasks.
codex exec reviewRuns a review through the codex exec command tree.Stable in current local CLI help.
codex reviewRuns a non-interactive code review.Stable in current local CLI help.
codex review --uncommittedReviews staged, unstaged, and untracked changes.Useful before committing.
codex review --base mainReviews changes against a base branch.Useful for PR review.
codex review --commit <SHA>Reviews one commit.Useful for release or regression checks.
codex review --title "Title"Sets an optional title in the review summary.Stable in current local CLI help.
codex exec --output-last-message result.md "Summarize the patch"Writes the final response to a file.Good for CI output.
codex exec --output-schema schema.json "Return JSON"Validates final output against a JSON Schema.Use for structured automation.
codex apply <TASK_ID>Applies the latest diff from a Codex Cloud task.Requires task access. Alias: codex a.

Model and Mode Controls

CommandWhat it doesNotes
codex --model <model>Overrides the model for one interactive session.Also available as -m.
codex exec --model <model> "Task"Overrides the model for one non-interactive run.Useful for task-specific model choice.
codex --profile <name>Loads a named config profile.Also available as -p.
codex --ossUses a local open source provider.Requires local provider setup.
codex features listLists feature flags and effective state.Official command.
codex features enable <feature>Enables a feature flag persistently.Writes to config.
codex features enable goalsEnables the experimental goals feature when supported.Required before /goal is available.
codex features disable <feature>Disables a feature flag persistently.Writes to config.

Useful config keys:

model = "<model>"
model_reasoning_effort = "medium"
model_reasoning_summary = "auto"
model_verbosity = "medium"
model_provider = "openai"
review_model = "<model>"

Permissions and Sandbox

CommandWhat it doesNotes
codex --sandbox read-onlyPrevents file edits.Good for audits and explanations.
codex --sandbox workspace-writeAllows edits inside the workspace.Common development mode.
codex --sandbox danger-full-accessDisables sandbox restrictions.Use only in an isolated environment.
codex --ask-for-approval on-requestLets Codex ask when it needs higher-permission action.Practical interactive default.
codex --ask-for-approval neverPrevents approval prompts.Use with a safe sandbox for automation.
codex --add-dir <path>Grants access to another directory.Prefer this over disabling the sandbox.
codex --dangerously-bypass-approvals-and-sandboxRuns without approvals or sandboxing.Dangerous outside a hardened container or VM.
codex --yoloAlias for bypassing approvals and sandboxing.Same risk as the full bypass flag.
codex --full-autoRuns with low-friction sandboxed automatic execution in builds that support it.Prefer explicit sandbox and approval flags in new scripts.
/sandbox-add-read-dir C:\absolute\pathGrants read access to another directory during a Windows TUI session.Windows-only slash command.

Useful config keys:

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

[sandbox_workspace_write]
writable_roots = ["/path/to/extra/workspace"]
network_access = false

MCP and Integrations

CommandWhat it doesNotes
codex mcp listLists configured MCP servers.Add --json for machine-readable output.
codex mcp get <name>Shows one MCP server config.Useful for debugging.
codex mcp add <name> -- <command...>Adds a stdio MCP server.Command after -- starts the server.
codex mcp add <name> --url https://...Adds a streamable HTTP MCP server.Use token env vars for secrets.
codex mcp login <name>Starts OAuth login for an HTTP MCP server.Server must support OAuth.
codex mcp login <name> --scopes scope1,scope2Requests specific OAuth scopes.Experimental MCP flow.
codex mcp logout <name>Removes stored OAuth credentials.HTTP MCP servers only.
codex mcp remove <name>Removes an MCP server definition.Does not remove external server code.
codex mcp-serverRuns Codex as an MCP server over stdio.Experimental.

Example:

codex mcp add docs -- node ./mcp-docs-server.js
codex mcp list

Common CLI Flags

FlagWhat it doesNotes
--cd, -C <path>Sets the working directory.Use before the task starts.
--config, -c key=valueOverrides config for one run.Values parse as TOML when possible.
--enable <feature>Enables a feature flag for one run.Repeatable. Equivalent to -c features.<name>=true.
--disable <feature>Disables a feature flag for one run.Repeatable. Equivalent to -c features.<name>=false.
--model, -m <model>Overrides the model.Global flag.
--profile, -p <name>Loads a config profile.Global flag.
--sandbox, -s <mode>Sets sandbox policy.read-only, workspace-write, or danger-full-access.
--ask-for-approval, -a <policy>Sets approval behavior.untrusted, on-request, or never.
--image, -i <path>Attaches images to the initial prompt.Repeatable.
--add-dir <path>Adds an accessible directory.Repeatable.
--searchEnables live web search.Uses native web search.
--no-alt-screenKeeps terminal scrollback visible.Useful in terminal multiplexers.
--jsonPrints JSONL events in codex exec.Automation-friendly.
--output-last-message <file>Writes the final message to a file.codex exec only.
--output-schema <file>Validates the final response shape.codex exec only.
--local-provider <provider>Selects a local OSS provider.Current local help lists lmstudio and ollama.
--remote <ws://host:port>Connects the TUI to a remote app-server endpoint.Used with remote app-server workflows.
--remote-auth-token-env <ENV_VAR>Sends a bearer token to a remote app-server endpoint.Requires --remote.
--yoloAlias for --dangerously-bypass-approvals-and-sandbox.Dangerous outside a hardened container or VM.

Environment Variables

VariableWhat it doesNotes
OPENAI_API_KEYProvides an OpenAI API key.Use with codex login --with-api-key.
CODEX_HOMEChanges Codex config, auth, logs, and session storage.Defaults to ~/.codex.
CODEX_CA_CERTIFICATEPoints Codex at a custom CA bundle.Falls back to SSL_CERT_FILE when unset.
SSL_CERT_FILEFallback custom CA path.Useful behind enterprise TLS inspection.
RUST_LOGControls Rust logging verbosity.Useful for debugging.
CODEX_REMOTE_AUTH_TOKENExample bearer-token variable for remote TUI auth.Pass the variable name with --remote-auth-token-env.
Custom MCP token env varsSupplies MCP bearer tokens.Referenced by bearer_token_env_var.

Real Workflows

Start a new project:

mkdir my-app
cd my-app
git init
codex --sandbox workspace-write --ask-for-approval on-request "Create a small starter app with tests"

Explain an existing repository without edits:

codex --sandbox read-only "Explain the architecture and identify the main entry points"

Fix a failing test:

codex exec --sandbox workspace-write --ask-for-approval never "Run the relevant tests, fix the failure, and summarize the patch"

Review a pull request locally:

git fetch origin
git checkout feature-branch
codex review --base main

Run a review through codex exec:

codex exec review --uncommitted --json

Resume previous work:

codex resume --last

Run headless and save the final response:

codex exec --json --output-last-message codex-result.md "Audit this package and report actionable issues"

Use one extra directory safely:

codex --sandbox workspace-write --add-dir ../shared "Update this project and the shared package together"

Reduce context during a long TUI session:

/status
/compact
/status

Set a long-running goal:

codex features enable goals
codex
/goal ship the parser refactor without changing public behavior

Use this when a longer task needs a persistent target that Codex can track across the session.

Experimental, Legacy, and Version-Dependent Items

ItemStatusNotes
codex cloudExperimentalRequires Codex Cloud access.
codex cloud exec --env <ENV_ID> "Task"ExperimentalSubmits a new Codex Cloud task from the shell.
codex cloud list --jsonExperimentalLists cloud tasks in machine-readable form.
codex cloud status <TASK_ID>ExperimentalShows task status.
codex cloud diff <TASK_ID>ExperimentalShows a unified task diff.
codex cloud apply <TASK_ID>ExperimentalApplies a cloud task locally.
codex app-serverExperimentalLocal development and debugging command.
codex app-server generate-tsExperimentalGenerates app-server TypeScript bindings.
codex app-server generate-json-schemaExperimentalGenerates app-server JSON Schema.
codex app-server remote-controlExperimentalRuns remote-control app-server tooling.
codex mcp-serverExperimentalRuns Codex as an MCP server.
codex sandboxExperimentalOS-specific sandbox helpers.
codex execpolicyPreviewTests execpolicy rules.
codex debug app-server send-message-v2Debug toolingSends an app-server protocol message for debugging.
codex debug models --bundledDebug toolingLists bundled model definitions.
codex plugin marketplaceExperimentalManages plugin marketplace sources.
codex cloud-tasksDeprecated aliasPrefer codex cloud.
/apps, /plugins, /skillsFeature-dependentAvailability depends on installed connectors, plugins, or skills.
/goalExperimentalOfficial slash command. Requires features.goals; enable it with /experimental or codex features enable goals.
/approvalsLegacy aliasPrefer /permissions.
/cleanLegacy aliasPrefer /stop.
--full-autoCompatibility/deprecated depending on docs/versionPrefer explicit --sandbox and approval flags.
--yoloDangerous compatibility aliasSame risk profile as --dangerously-bypass-approvals-and-sandbox.
--experimental-jsonAliasPrefer --json.
codex --upgradeOlder help contentTreat as outdated unless codex --help for the installed version confirms it.
codex updateVersion-dependent update commandUse only when the installed build or official docs list it.

Related Resources

Suggested Repository Metadata

Recommended repository name:

codex-commands-cheat-sheet

Recommended GitHub description:

OpenAI Codex CLI commands cheat sheet for developers: slash commands, flags, config, sandboxing, MCP, and workflows.

Recommended topics:

codex, openai, codex-cli, cli, developer-tools, cheat-sheet, mcp, ai-coding

Update Policy

  • Verify unstable commands against the official Codex CLI reference.
  • Treat official OpenAI Codex CLI docs as the primary source.
  • Use codex --help and subcommand help only as local installed-version checks.
  • Keep shell commands, slash commands, flags, config keys, and environment variables in separate sections.
  • Mark experimental, deprecated, legacy, community, or unverified commands clearly.
Ver o original no GitHub

Bom para

Relacionados