Skip to content

The command reference for Claude Code, Codex and Cursor lists the flags, subcommands and slash commands that exist in the current releases, checked against Claude Code 2.1.296 and Codex CLI 0.162.1. It also names the stale commands to delete from scripts, and the commands that verify an agent’s output without a line-by-line read.

This page is for developers who drive agents from a terminal or CI, and for tech leads who maintain the team’s scripts. The usual trigger: a nightly job that ran codex -a on-failure or claude -p … /review last month now exits with “invalid value” or quietly does something different, and nobody knows which flags are still real.

The page was first checked on 2026-09-26 against Claude Code 2.1.283 (the latest channel) and Codex CLI 0.157.1. Its flag, subcommand and slash-command tables were checked again on 2026-10-12 against Claude Code 2.1.296 (stable is 2.1.292 on 2026-10-17) and the --help output of Codex CLI 0.162.1, and an entry added in a newer release names the version that added it. A row that carries no later date, such as the think harder row, still stands on the 2026-09-26 check.

  • The session, headless and MCP commands for each tool, in one table per tool, with the flag spellings the installed CLI accepts today.
  • A list of removed and renamed commands, so you can grep your scripts for them.
  • The review and verification commands that let you accept agent work on evidence: diffs, review findings, schema-checked output and budgets.
  • Two copy-paste prompts: one that audits your scripts for stale flags, one that runs a pre-merge check before you open the PR.

Keyboard bindings live on the keyboard shortcuts reference, and settings files on the configuration reference.

Which commands start, resume and script a session?

Section titled “Which commands start, resume and script a session?”

The three tools share a shape: an interactive session, a one-shot headless mode for scripts, a way to resume, and a model switch. The spellings differ.

Terminal window
claude # interactive session in this directory
claude "explain the auth module" # interactive, with a first prompt
claude -p "list TODOs in src/" # headless: print the answer and exit
claude -c # continue the most recent conversation here
claude -r # open the session picker (or pass an ID)
claude --model opus # alias for the latest Opus; also sonnet, fable
claude --effort high # low | medium | high | xhigh | max
claude -w feature-x # new git worktree for this session
claude --bg "fix the flaky test in tests/api" # background session; see `claude agents`
claude --desktop # open this directory in the Claude Desktop app and exit (v2.1.285)

Which model each tool starts on, and what it costs, changes monthly. Check the models hub instead of hardcoding a model ID into a script; start on the default and raise effort before you switch model.

Claude Code CLI flags that matter in scripts

Section titled “Claude Code CLI flags that matter in scripts”

Every flag below appears in claude --help for Claude Code 2.1.296 (checked 2026-10-12). Flags marked “print only” have no effect without -p.

FlagWhat it doesExample
-p, --printRun headless and print the result. Skips the workspace trust dialog, so run it only in directories you trustclaude -p "summarise this diff"
--output-formattext, json or stream-json (print only)--output-format json
--json-schemaValidate the final answer against a JSON Schema--json-schema "$(cat verdict.schema.json)"
--max-budget-usdStop spending past a dollar cap (print only)--max-budget-usd 2
--permission-modemanual, acceptEdits, plan, auto, dontAsk, bypassPermissions--permission-mode plan
--allowedTools / --disallowedToolsPre-approve or deny named tools and command patterns. Pre-approving does not remove the other tools--allowedTools "Read Grep Bash(npm test *)"
--toolsLimit which built-in tools exist in the session at all--tools "Read,Grep,Glob"
--add-dirGive access to another directory--add-dir ../shared
--mcp-config, --strict-mcp-configLoad MCP servers from a file, and only those--mcp-config ci.mcp.json --strict-mcp-config
--bareSkip hooks, plugins, auto-memory and CLAUDE.md discovery; from v2.1.286 it also connects only the MCP servers named on the command line, sends no system reminders and starts no background tasksclaude --bare -p "…"
--safe-modeStart with all customisations off, to debug a broken setupclaude --safe-mode
--restrictedRemove code-running tools and ignore user and project settingsclaude --restricted -p "…"
--from-prResume a session linked to a PRclaude --from-pr 123
--fallback-modelTry other models when the primary is unavailable--fallback-model sonnet
--dangerously-skip-permissionsBypass every permission checkOnly in a disposable sandbox with no network access

Subcommands you run from the shell: claude mcp (servers), claude plugin (plugins), claude agents (lists background sessions; --json for scripts), claude attach <id>, claude logs <id>, claude stop <id> and claude rm <id> (manage one background session), claude doctor (install health), claude import codex|gemini|cursor (bring config across), claude ultrareview (cloud multi-agent review of the branch or a PR) and claude update.

Added since v2.1.283 (checked 2026-10-12): claude --desktop (v2.1.285) opens the Claude Desktop app on the current directory and exits. claude purge [path] (v2.1.288, both channels on 2026-10-17) deletes all Claude Code state for a project, with --dry-run to preview, -y to skip the prompt, -i to confirm each item and --all for every project; the old name, claude project purge, still works and prints a notice. claude plugin configure <plugin> (v2.1.285) shows a plugin’s options and which are unset, or saves values piped to --values-stdin. claude plugin install takes --config <key=value> (repeatable; the plugins CLI reference lists no minimum version), which since v2.1.285 also accepts <server>.<key>=<value> for a bundled .mcpb MCP server’s own settings, and --marketplace <source> (v2.1.292, both channels on 2026-10-17), and claude plugin test runs a mod’s tests. claude attach and claude logs accept part of a session name (v2.1.290, both channels on 2026-10-17).

The in-session list is long and includes bundled skills. These are the ones a working day needs, grouped by what you are trying to do. Type / in a session for the full list. Every command in the table is in Claude Code’s commands reference as of 2026-10-12 (Claude Code 2.1.296).

JobCommands
Context/clear (new conversation), /compact [focus] (summarise and continue), /context (what fills the window), /add-dir, /cd (move the session, keep the conversation), /memory (edit CLAUDE.md)
Mode and depth/plan [task] (plan mode), /model, /effort [low…max|auto|status|ultracode [on|off]] (since v2.1.284, ultracode is a toggle that keeps the session’s effort level), /permissions, /config
Long-running work/goal <condition> (keep going until the condition holds), /loop [interval] [prompt], /background, /fork, /subtask, /tasks, /batch <instruction>, /schedule (cloud routines), /workflows
Checking the work/diff, /code-review [level] [--fix] [--comment] [--max-findings n|all|default] [pr|branch|path] (--max-findings needs v2.1.288, both channels on 2026-10-17), /security-review, /simplify, /verify, /rewind (alias /undo)
Setup and cost/init, /mcp (/mcp reconnect all retries every server that failed or needs authentication, v2.1.284), /skills, /hooks, /plugin, /doctor, /usage (aliases /cost, /stats), /rate-limit-options (ways to keep working when a claude.ai usage limit blocks a request), /import codex|gemini|cursor

Three prefixes work at the prompt: / for commands and skills, @ for a file-path mention, and ! to run a shell command and hand its output to Claude.

Every flag below appears in codex --help or codex exec --help for both 0.157.1 and 0.162.1 (checked 2026-10-12), except the one that names its own version.

FlagWhat it doesExample
-m, --modelModel for the sessioncodex -m gpt-6-sol
-a, --ask-for-approvalon-request (the model decides when to ask) or never. Not accepted by codex exec: put it before the subcommandcodex -a never exec "…"
-s, --sandboxread-only, workspace-write or danger-full-accesscodex exec -s read-only "…"
-c key=valueOverride one config.toml value, for example a beta permission profile-c default_permissions=":workspace"
--approve-for-meRoute approval requests through automatic review in the workspace-write sandboxcodex --approve-for-me
-p, --profileLayer $CODEX_HOME/<name>.config.toml over your configcodex -p ci exec "…"
-C, --cd, --add-dirSet the working root; add writable directoriescodex -C services/api
--searchEnable live web searchcodex --search
--json, -o FILE, --output-schema FILEJSONL events, last message to a file, schema-shaped final answer (exec only)codex exec --output-schema verdict.json -o out.json "…"
--cyber-access-program <PROGRAM>Request an experimental Cyber access program for this turn, OpenAI provider only: standard, daybreak_blue or daybreak_red. exec takes it (0.161.0); exec review does not support itcodex exec --cyber-access-program standard "…"
--dangerously-bypass-approvals-and-sandboxNo approvals and no sandboxOnly in an externally sandboxed, disposable runner

OpenAI now prefers permission profiles (beta, selected with default_permissions) over the legacy --sandbox flag, and says the two systems “do not compose”. Pick one per invocation. The trade-offs are on the permissions and sandboxing page.

Shell subcommands: codex exec (headless), codex review (--uncommitted, --base <branch>, --commit <sha>), codex mcp (list, get, add, remove, login, logout), codex plugin, codex agents (session dashboard), codex resume, codex fork, codex apply, codex doctor, codex features list and codex update.

Taken from the TUI’s command table in the 0.157.1 source and checked again against the 0.162.1 source on 2026-10-12: every command below is in the 0.162.1 list.

JobCommands
Context/new, /clear, /compact, /mention (add a file), /cd, /init (create AGENTS.md)
Mode and depth/plan, /model (model and reasoning effort), /fast (toggles a Fast service tier when the model catalog exposes one; it is not in the static command list, and Codex hides it when the current model has no Fast tier), /permissions, /approve (retry one auto-review denial), /experimental
Long-running work/goal, /agents (command center), /subagents, /worktree (start or continue a conversation in a new worktree; 0.162.0 added managed worktree tools that create and list worktrees from trusted projects), /fork, /side (alias /btw, a side conversation in an ephemeral fork)
Checking the work/diff (includes untracked files), /review (review current changes), /status (config and token use)
Setup and cost/mcp (lists MCP tools; /mcp verbose shows them in full and, from 0.161.0, /mcp login <name> signs in to a server), /skills, /plugins, /hooks, /memories, /import (from Claude Code, per the 0.162.1 source), /usage, /resume, /copy (copy the last response or part of it; in the 0.162.0 release notes), /daybreak (turn Daybreak on or off; opt-in since 0.161.0, so it is unavailable until you enable the cli_daybreak feature, for example with --enable cli_daybreak)

Codex’s own manual still lists /personality, /sandbox-add-read-dir and /agent. The 0.162.1 command list has none of them and names the agent switcher /subagents, so trust the binary. There is no /loop in Codex 0.162.1 (checked 2026-10-12 in the command list and the developer-commands reference); use /goal or your CI.

Connect an MCP server from the command line

Section titled “Connect an MCP server from the command line”

The syntax differs by tool, and the result is the same: the agent gains the server’s tools. The example uses the Sentry HTTP server shown in claude mcp add --help and Microsoft’s Playwright server (@playwright/mcp, 0.0.83 on npm, published 2026-09-28).

Terminal window
claude mcp add --transport http sentry https://mcp.sentry.dev/mcp
claude mcp add -s project playwright -- npx -y @playwright/mcp@0.0.83 # writes .mcp.json; pin versions in shared config
claude mcp list # health-checks approved servers
claude mcp serve # expose Claude Code itself as an MCP server

In a session, /mcp reconnect all retries every server that failed to connect or needs authentication (v2.1.284).

Scope matters in Claude Code: -s local (the default) is private to you in this project, -s project writes a shared .mcp.json that each teammate approves once, and -s user follows you across projects.

In Claude Code, custom commands have merged into skills. .claude/commands/fix-issue.md and .claude/skills/fix-issue/SKILL.md both create /fix-issue; prefer the skill folder for new work because it can hold scripts and reference files. Codex exposes the same idea through /skills.

---
description: Fix a GitHub issue and prove it with a failing-then-passing test
argument-hint: "[issue-number]"
allowed-tools:
- Bash(gh issue view *)
- Bash(npm test *)
- Read
- Edit
---
Issue details:
!`gh issue view $ARGUMENTS`
1. Write a test that reproduces the issue and confirm it fails.
2. Fix the code until that test and the rest of `npm test` pass.
3. Report the test name, the before/after result and the files you changed.

$ARGUMENTS is everything typed after the command ($0, $1 for positional arguments). A line of the form !`command` runs before Claude reads the skill and is replaced by its output. allowed-tools pre-approves the listed tools for the turn that invokes the skill; it does not restrict Claude to them. The custom commands guide covers arguments, invocation control and sharing.

How do you verify agent output from the command line?

Section titled “How do you verify agent output from the command line?”

A fast agent is only useful if accepting its work does not mean reading every line. Wire these commands into the loop so that what you review is evidence, not the raw diff.

Terminal window
# In a session: set a stop condition that a check can prove
/goal npm test and npm run lint both exit 0 with no skipped tests
# In a session: review the branch, then apply the fixes it finds
/code-review high --fix
/code-review high --max-findings all # report every finding, not the usual limit (v2.1.288, both channels)
/security-review
# Headless, in CI: a read-only review with a schema-checked verdict and a spend cap
git diff origin/main...HEAD | claude -p "Review this diff for correctness bugs. Return blocking findings only." \
--bare --setting-sources "" --strict-mcp-config \
--tools "Read,Grep,Glob" \
--json-schema "$(cat .ci/verdict.schema.json)" \
--output-format json --max-budget-usd 3 > review.json

On pull requests from forks, --bare skips the fork’s hooks, plugins and CLAUDE.md, and --strict-mcp-config limits MCP servers to the ones you pass with --mcp-config. Neither flag ignores the fork’s .claude/settings.json; --setting-sources "" does, which is why the CI example above passes all three. For untrusted forks, you can also use --restricted --strict-mcp-config: --restricted also ignores user, project and local settings files and removes the command-running tools unless --tools names them. Alternatively, run the review against a checkout of the base branch. The headless agents in CI page covers the full fork policy.

Who signs off: the pipeline decides pass or fail from the test run, the lint and type gates, and the review verdict file; the engineer who owns the change reads the findings and the test evidence, then merges. The agent PR review workflow and headless agents in CI pages show the full pipeline, including the security rules for untrusted pull requests.

Which commands and flags were removed or renamed?

Section titled “Which commands and flags were removed or renamed?”

Grep your scripts and runbooks for the left column. Each row names the CLI version and the date it was checked against.

StaleUse insteadChecked against
codex -a untrusted, codex -a on-failure-a on-request or -a never (both old values fail with “invalid value”)Codex 0.157.1–0.162.1 (2026-10-12)
codex --full-auto, codex exec --full-auto--approve-for-me, --sandbox workspace-write, or a permission profileCodex 0.157.1–0.162.1 (2026-10-12)
codex exec -a never "…"codex -a never exec "…"Codex 0.157.1–0.162.1 (2026-10-12)
codex mcp-servercodex exec, the Codex SDK or codex app-server (experimental)Codex 0.157.1–0.162.1 (2026-10-12)
tui.prompt_suggestions in config.toml, and the automatic follow-up prompt suggestionsDelete the key: the setting and the feature were removed in 0.159.0Codex 0.159.0 release notes; absent from the 0.162.1 config schema (2026-10-12)
The bundled plugin-creator skillNone named in the release notes; the bundled sample skills in 0.162.1 are imagegen, openai-docs, review-agent, skill-creator and skill-installerRemoved in Codex 0.159.0; checked against 0.162.1 (2026-10-12)
claude project purgeclaude purge (the old name still works and prints a notice; v2.1.288, both channels on 2026-10-17)Claude Code 2.1.296 (claude --help, 2026-10-12)
/review, /cost, /stats as separate Claude Code commands/code-review and /usage (the old names are aliases)Claude Code 2.1.296 / commands docs (2026-10-12)
/ultrareview as the preferred command/code-review ultra in a session (/ultrareview still works as an alias), claude ultrareview from the shellClaude Code 2.1.296 / commands docs (2026-10-12)
/ultraplan/plan (plan mode)Claude Code 2.1.296 / commands docs (2026-10-12)
/agents wizardAsk Claude, or edit .claude/agents/Claude Code 2.1.296 / commands docs (2026-10-12)
think harder as a budget keyword/effort or --effortClaude Code 2.1.283 / commands docs (2026-09-26)

A headless run stops short or edits nothing. claude -p starts in Manual mode on first-party installs with telemetry on, so in an unattended job nobody is there to approve a tool call that needs approval; on third-party providers or with telemetry off it starts in auto mode from v2.1.285, and a classifier decides instead. Pre-approve exactly what the job needs with --allowedTools, or use --permission-mode plan for read-only analysis. Pre-approval is not a restriction: to make a job genuinely read-only, remove the other tools with --tools "Read,Grep,Glob". Do not reach for --dangerously-skip-permissions outside a disposable, network-restricted sandbox.

--output-format json returns plain text. The flag works only with -p. Add -p, and add --json-schema when you need a validated shape rather than prose.

Auto mode set in the repository is ignored. Claude Code ignores auto and bypassPermissions as defaultMode in project settings; they belong in user or managed settings. This is deliberate: a cloned repository cannot switch off your prompts.

A background command ends partway through a headless run. From v2.1.285, background Bash and PowerShell commands stop after a time limit: their own timeout, 30 minutes by default and at most 2 hours. Since v2.1.288 the limit applies only in unattended sessions (-p, the Agent SDK, CI and cloud sessions). Give the command a longer timeout, up to the 2-hour maximum, or run a longer job outside the agent.

Codex rejects a flag that worked yesterday. Run codex --help and codex exec --help and compare; the approval and sandbox flags changed between releases. Pin the CLI version in CI (npm install -g @openai/codex@0.162.1) and bump it on purpose.

A slash command from a blog post does not exist. Commands are removed and aliased often. Type / and filter, or check the Claude Code changelog and the Codex changelog. If a whole configuration seems broken, start once with claude --safe-mode to rule out your own hooks, plugins and skills.

Where to go next after the command reference

Section titled “Where to go next after the command reference”

Frequently asked questions

How do you run Claude Code and Codex non-interactively?

Claude Code uses claude -p "prompt", with --output-format json or --json-schema for machine-readable output. Codex uses codex exec "prompt", with --json, -o FILE or --output-schema FILE. The approval flag goes before the subcommand: codex -a never exec ….

Which approval values does codex -a accept?

In Codex CLI 0.157.1 through 0.162.1 (checked 2026-10-12), -a accepts only on-request and never. untrusted and on-failure fail with "invalid value", and --full-auto is no longer in codex --help. Sandboxing is a separate choice: --sandbox read-only, workspace-write or danger-full-access.

What replaced /review and /cost in Claude Code?

/code-review is the review command and /review is its alias; /code-review ultra runs the cloud review. /usage shows cost, plan limits and activity, with /cost and /stats kept as aliases.

Are Claude Code custom slash commands still in .claude/commands/?

Files in .claude/commands/ still work, but custom commands have merged into skills: .claude/skills/<name>/SKILL.md creates the same slash command and can carry supporting files. allowed-tools pre-approves tools for that turn; it does not restrict them.

What replaced the think / think harder / ultrathink ladder?

think, think hard and think more are ordinary prompt text. ultrathink asks for deeper reasoning on one turn without changing the effort sent to the API. Durable depth is set with /effort or claude --effort.