Claude Code is controlled in three layers. Shell commands start and resume sessions, flags change the behavior of one launch, and slash commands work inside an open session. All three layers are laid out in tables below, with no loose retelling and no invented flags: if the code.claude.com documentation does not confirm a command, it did not make it into this cheatsheet.
How to see the command list in the terminal itself
You do not have to keep this page open. In an open session, type / and a list of available commands and skills appears, narrowing as you type letters. The --help flag works too, but Anthropic's documentation warns plainly: it does not show every flag at once, and a flag missing from --help does not mean it does not exist.
Shell commands
You run these from a regular terminal, before entering a Claude Code session.
| Command | What it does |
|---|---|
claude | Open an interactive session |
claude "task" | Open a session right away with a first request |
claude -p "query" | Run a request and exit, with no interactive mode |
claude -c | Continue the last conversation in the current folder |
claude -r "<session>" | Return to a session by ID or name |
claude update | Update Claude Code to the latest version |
claude doctor | Check the install and settings without opening a session |
claude mcp | Configure MCP servers |
claude auth login / claude auth logout | Sign in to or out of an Anthropic account |
claude auth status | Print the authorization status as JSON |
claude agents | Open the panel of background parallel sessions |
claude install [version] | Install or reinstall the native binary; you can set a version, or stable or latest |
People often forget this: claude can read a pipe. The command git diff main --name-only | claude -p "check the changed files for vulnerabilities" hands the agent a list of files with no extra manual steps.
Flags of the claude command
You set flags at launch. They apply to a specific session or to a single run in -p mode.
| Flag | What it does |
|---|---|
-p, --print | Print the answer without interactive mode, for scripts and CI |
-c, --continue | Load the last conversation in the current folder |
-r, --resume <session> | Continue a specific session by ID or name |
--model | Pick the model for a session: an alias (sonnet, opus, haiku, fable) or a full name |
--fallback-model | A model or list of models to switch to automatically if the main one is unavailable |
--add-dir | Attach one more working directory that the agent can read and edit |
--permission-mode | Start the session in a given permission mode (plan, acceptEdits, bypassPermissions and others) |
--allowedTools, --allowed-tools | Tools that run without a permission prompt |
--disallowedTools, --disallowed-tools | Tools that are forbidden |
--dangerously-skip-permissions | Never ask for permissions, the same as --permission-mode bypassPermissions |
--output-format | Output format in -p mode: text, json or stream-json |
--max-turns | Limit the number of agent turns in -p mode |
--max-budget-usd | Stop the run when spending reaches a dollar limit, in -p mode |
--append-system-prompt | Add your own text to the end of the system prompt |
--mcp-config | Connect MCP servers from a JSON file or string |
--bare | Minimal mode: no hooks, skills, MCP servers, auto memory or CLAUDE.md |
--verbose, -v | Verbose output |
--version | Show the Claude Code version |
The --dangerously-skip-permissions flag does exactly what its name says: the agent stops asking for permission before it acts. For a one-off script in an isolated container this is sometimes justified. In everyday work on your own code, where the agent could delete the wrong file by accident, do not use it.
Slash commands inside a session
They work only after the session is already open via the claude command.
| Command | What it does |
|---|---|
/help | Show help and the list of commands |
/clear [name] | Start a new conversation with a clean context |
/compact [instructions] | Compress the conversation history and free up context |
/resume [name] | Go back to one of the earlier conversations from the /clear history |
/model [model] | Switch the model and save it as the default for new sessions |
/agents | A reminder of how to create and edit subagents in .claude/agents/ |
/mcp | Manage MCP server connections and OAuth |
/permissions | Manage permission rules for tools: allow, ask, deny |
/status | Show the status of the current session |
/usage (alias /cost) | Show token usage and the cost of the current session |
/init | Create a CLAUDE.md file for the project |
/code-review (alias /review) | Check the current diff, PR or branch for errors |
/security-review | Check the current diff for vulnerabilities |
/doctor | The same install check as claude doctor, but from inside a session |
/diff | Show changes in the working directory, including the agent's own edits |
/undo | Undo the latest file changes made by the agent |
/rewind [checkpoint] | Roll the code and the conversation back to an earlier state |
/export [file] | Save the current conversation to a text file |
/login / /logout | Sign in to or out of an Anthropic account |
/add-dir <path> | Attach a working directory without leaving the session |
/bug [text] | Report a bug or send the conversation to Anthropic |
The full list is noticeably longer: some commands cover skills, design, task planning and cloud sessions. The official reference at code.claude.com/docs/en/commands describes each of them.
Hotkeys that save time
| Combination | What it does |
|---|---|
Ctrl+C | Interrupt execution; if nothing is running, the first press clears the input field and the second exits |
Ctrl+D | Exit the session (press twice in a row to confirm) |
Shift+Tab | Cycle the permission mode: manual, acceptEdits, plan, bypassPermissions, auto |
Esc | Stop the agent's current answer or close an open dialog |
Esc Esc | Clear the input draft, or open the rewind menu if the field is empty |
Ctrl+R | Search the command history in reverse order |
Ctrl+O | Show or hide the detailed log of tool calls |
Tab | Accept an autocomplete suggestion |
How these commands work through codexkey
If Claude Code points at codexkey through ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN and ANTHROPIC_DEFAULT_*, every command and flag in the tables above works unchanged. codexkey answers over the same Anthropic Messages API protocol, so the CLI cannot tell the endpoints apart. Only the --model flag deserves a check: the available aliases and full model names depend on what is connected on your gateway. The current list is on the codexkey models page.
For CI and scripts, -p together with --output-format json is especially handy, since you can then parse the answer programmatically.
export ANTHROPIC_BASE_URL="https://api.codexkey.online"
export ANTHROPIC_AUTH_TOKEN="sk_cdx_YOUR_KEY"
export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus-5-5[1m]"
export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-5[1m]"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-sonnet-5"
claude -p "write tests for the auth module and run them" \
--output-format json \
--max-turns 5
The ANTHROPIC_DEFAULT_* lines are mandatory: without them Claude Code requests its own default models and replies "There's an issue with the selected model".
The environment variables and the settings.json setup for codexkey are covered in the Claude Code guide.
FAQ
How do I see all the commands right inside Claude Code?
Type / in the input field of an open session: a list of slash commands and skills appears and filters as you type. For shell commands, meaning the ones you run before entering a session, there is a single reference, claude --help, though it is not exhaustive.
What does the -p flag do, and how does it differ from a normal launch?
-p (or --print) runs the request once and exits without opening a conversation. It is the mode for scripts, CI and pipes. For example, cat log.txt | claude -p "find anomalies" runs the file through the agent and returns the text of the answer right away.
How do I continue yesterday's conversation with Claude Code?
In the same project folder, claude -c is enough: it picks up the last session on its own. Need a specific older conversation? Run claude -r with the session ID or name, which you can find through /resume in an already open session.
What does claude doctor check, and when should I run it?
The command prints diagnostics for the install and settings: the state of the binary, errors in configuration files, and warnings with ready-made hints for fixing them. No session starts. Run it right after installing, after an update, and any time Claude Code behaves differently from what you expected.
How do I limit what the agent does without asking?
The --allowedTools and --disallowedTools flags set lists of allowed and forbidden tools at launch, and the /permissions command inside a session opens the same settings as an interface. If you need full control over a project, these rules are usually moved into settings.json instead of being repeated as flags on every launch.
Do these flags work the same on Windows, macOS and Linux?
Yes, the CLI commands and flags are identical on every platform because it is the same binary. Only the shell you launch it from differs. On Windows that is PowerShell or CMD, and the environment variable syntax there is not the same as in bash, but the claude flags themselves are written the same everywhere.