Command Reference Cheatsheet
PLThe 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.
What you get from this command reference
Section titled “What you get from this command reference”- 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.
claude # interactive session in this directoryclaude "explain the auth module" # interactive, with a first promptclaude -p "list TODOs in src/" # headless: print the answer and exitclaude -c # continue the most recent conversation hereclaude -r # open the session picker (or pass an ID)claude --model opus # alias for the latest Opus; also sonnet, fableclaude --effort high # low | medium | high | xhigh | maxclaude -w feature-x # new git worktree for this sessionclaude --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)codex # interactive TUIcodex "explain the auth module" # interactive, with a first promptcodex exec "list TODOs in src/" # headless (alias: codex e)codex resume --last # continue the most recent sessioncodex fork --last # branch the most recent sessioncodex -m gpt-6-astra # pick a model by IDcodex --worktree # run in a new managed git worktreecodex apply # git-apply the latest diff Codex producedcodex cloud # [experimental] browse Codex cloud tasksCursor is IDE-first, and its terminal command is agent (Cursor’s CLI installation and overview pages, checked 2026-10-12); cursor-agent appears on no Cursor documentation page. Install it with curl https://cursor.com/install -fsS | bash on macOS, Linux and WSL, or irm 'https://cursor.com/install?win32=true' | iex on Windows.
agent --version # confirm the installagent # interactive sessionagent -p "list TODOs in src/" --output-format text # headless: print mode, for scripts and GitHub Actionsagent persist # persistent sessions (CLI v2026.08.26)agent update # update the CLIIn a session, the CLI’s modes are Agent (the default), Plan (Shift+Tab, /plan, --plan or --mode=plan) and Ask (/ask or --mode=ask); it also has /debug. Plan Mode “creates detailed implementation plans before writing any code” (Cursor’s docs, read 2026-08-28). Prefix a message with & to hand it to a Cloud Agent. /goal gives the agent “a long-lived objective to work towards until it’s fully complete” and is still rolling out in Cursor’s docs (checked 2026-10-12). /run-everything [on|off|status] switches the run mode, with /auto-run as an alias, and /rewind is listed among the CLI slash commands (Cursor’s docs, read 2026-08-28). agent persist also has attach, list, stop and --resume forms. On 2026-10-12 the latest CLI release is v2026.10.08 (Cursor’s CLI changelog) and the desktop editor is Cursor 3.24, released 2026-10-09 (Cursor’s release notes).
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.
| Flag | What it does | Example |
|---|---|---|
-p, --print | Run headless and print the result. Skips the workspace trust dialog, so run it only in directories you trust | claude -p "summarise this diff" |
--output-format | text, json or stream-json (print only) | --output-format json |
--json-schema | Validate the final answer against a JSON Schema | --json-schema "$(cat verdict.schema.json)" |
--max-budget-usd | Stop spending past a dollar cap (print only) | --max-budget-usd 2 |
--permission-mode | manual, acceptEdits, plan, auto, dontAsk, bypassPermissions | --permission-mode plan |
--allowedTools / --disallowedTools | Pre-approve or deny named tools and command patterns. Pre-approving does not remove the other tools | --allowedTools "Read Grep Bash(npm test *)" |
--tools | Limit which built-in tools exist in the session at all | --tools "Read,Grep,Glob" |
--add-dir | Give access to another directory | --add-dir ../shared |
--mcp-config, --strict-mcp-config | Load MCP servers from a file, and only those | --mcp-config ci.mcp.json --strict-mcp-config |
--bare | Skip 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 tasks | claude --bare -p "…" |
--safe-mode | Start with all customisations off, to debug a broken setup | claude --safe-mode |
--restricted | Remove code-running tools and ignore user and project settings | claude --restricted -p "…" |
--from-pr | Resume a session linked to a PR | claude --from-pr 123 |
--fallback-model | Try other models when the primary is unavailable | --fallback-model sonnet |
--dangerously-skip-permissions | Bypass every permission check | Only 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).
Claude Code slash commands by job
Section titled “Claude Code slash commands by job”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).
| Job | Commands |
|---|---|
| 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.
Codex CLI flags and approval policies
Section titled “Codex CLI flags and approval policies”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.
| Flag | What it does | Example |
|---|---|---|
-m, --model | Model for the session | codex -m gpt-6-sol |
-a, --ask-for-approval | on-request (the model decides when to ask) or never. Not accepted by codex exec: put it before the subcommand | codex -a never exec "…" |
-s, --sandbox | read-only, workspace-write or danger-full-access | codex exec -s read-only "…" |
-c key=value | Override one config.toml value, for example a beta permission profile | -c default_permissions=":workspace" |
--approve-for-me | Route approval requests through automatic review in the workspace-write sandbox | codex --approve-for-me |
-p, --profile | Layer $CODEX_HOME/<name>.config.toml over your config | codex -p ci exec "…" |
-C, --cd, --add-dir | Set the working root; add writable directories | codex -C services/api |
--search | Enable live web search | codex --search |
--json, -o FILE, --output-schema FILE | JSONL 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 it | codex exec --cyber-access-program standard "…" |
--dangerously-bypass-approvals-and-sandbox | No approvals and no sandbox | Only 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.
Codex slash commands by job
Section titled “Codex slash commands by job”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.
| Job | Commands |
|---|---|
| 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).
claude mcp add --transport http sentry https://mcp.sentry.dev/mcpclaude mcp add -s project playwright -- npx -y @playwright/mcp@0.0.83 # writes .mcp.json; pin versions in shared configclaude mcp list # health-checks approved serversclaude mcp serve # expose Claude Code itself as an MCP serverIn a session, /mcp reconnect all retries every server that failed to connect or needs authentication (v2.1.284).
codex mcp add sentry --url https://mcp.sentry.dev/mcpcodex mcp add playwright -- npx -y @playwright/mcp@latestcodex mcp listcodex mcp add takes --oauth-client-id <CLIENT_ID> and, from 0.158.0, --oauth-client-secret <CLIENT_SECRET> for a pre-registered OAuth client; read the secret from your secret store instead of typing it into a script. In the TUI, /mcp login <name> signs in to a server (0.161.0). codex mcp has list, get, add, remove, login and logout, and still no --transport flag (0.162.1, checked 2026-10-12).
Codex can no longer run as an MCP server (removed in 0.154.0). Use codex exec or the Codex SDK to drive it from code.
Cursor’s documentation says MCP “enables Cursor to connect to external tools and data sources”, and Cursor plugins “package rules, skills, agents, commands, MCP servers, and hooks into distributable bundles”, so a team can ship its servers as one plugin. This page documents no Cursor command-line flow for adding a server, and does not name the config file: neither was checked for this page on 2026-10-12. The MCP hub covers setup per tool.
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.
Custom commands: skills and command files
Section titled “Custom commands: skills and command files”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 testargument-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.
# 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 capgit 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# Review uncommitted work, the branch against main, or one commitcodex review --uncommittedcodex review --base maincodex review --commit <sha>
# Headless, in CI: read-only sandbox, no prompts, schema-shaped answercodex -a never exec -s read-only --output-schema .ci/verdict.schema.json \ -o review.json "Review the changes on this branch against main for correctness bugs"Cursor’s pull-request reviewer is Bugbot, which “reviews pull requests and identifies bugs, security issues, and code quality problems”. Plan Mode gives you a plan to approve before any edit. For a scripted check, run the Cursor CLI in print mode (agent -p) inside the same CI job that runs your tests; Cursor documents the CLI for “GitHub Actions and other CI/CD systems”. PR Routing & Approval “assigns reviewers based on code ownership and commit history, and can approve low-risk PRs when your criteria are met”, so write those criteria as checks the pipeline can prove.
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.
| Stale | Use instead | Checked 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 profile | Codex 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-server | codex 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 suggestions | Delete the key: the setting and the feature were removed in 0.159.0 | Codex 0.159.0 release notes; absent from the 0.162.1 config schema (2026-10-12) |
The bundled plugin-creator skill | None named in the release notes; the bundled sample skills in 0.162.1 are imagegen, openai-docs, review-agent, skill-creator and skill-installer | Removed in Codex 0.159.0; checked against 0.162.1 (2026-10-12) |
claude project purge | claude 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 shell | Claude Code 2.1.296 / commands docs (2026-10-12) |
/ultraplan | /plan (plan mode) | Claude Code 2.1.296 / commands docs (2026-10-12) |
/agents wizard | Ask Claude, or edit .claude/agents/ | Claude Code 2.1.296 / commands docs (2026-10-12) |
think harder as a budget keyword | /effort or --effort | Claude Code 2.1.283 / commands docs (2026-09-26) |
When commands misbehave in scripts
Section titled “When commands misbehave in scripts”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”- Configuration reference:
CLAUDE.md,AGENTS.md,config.tomland settings files side by side. - Keyboard shortcuts: the key bindings this page leaves out.
- Codex non-interactive mode and
/goalworkflows: the headless and long-running patterns in depth. - Glossary: terms such as subagent, skill and permission profile.
- What’s new: commands added since this page’s last update.
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.