Title card: Claude Code commands, CLI flags, slash commands and shortcuts, with three example commands: claude -c, /compact and /rewind.
All articles

Claude Code commands: CLI flags, slash commands and shortcuts

A Claude Code commands cheat sheet: claude -c, -r and -p flags, /compact, /clear, /rewind and other slash commands, input prefixes and key shortcuts.

Claude Code has two command surfaces, and most confusion comes from mixing them up. CLI commands and flags are what you type in your shell before a session starts, such as claude -c or claude --permission-mode plan. Slash commands are what you type inside a running session, such as /compact or /rewind. This cheat sheet covers the ones you will use every day, grouped by the job they do, with the exact syntax from the official documentation as of October 2026.

VibeiDE runs your coding agents in parallel. Watch them as an Office or a Grid.14 days free

Run claude --help for the flags your installed version knows, and type / inside a session to see every command available to you, including your own skills. The official CLI reference notes that --help does not list every flag, so check the docs when a flag seems missing.

Two panels: shell commands such as claude -c, claude -r billing-fix and claude -w start or resume a session; an arrow leads to slash commands such as /compact, /plan, /rewind and /usage used inside it.
Shell commands and flags choose the session; slash commands steer it once it runs.

Start, continue and resume sessions

These shell commands decide which conversation you land in. Picking the right one saves you from re-explaining a task.

CommandWhat it does
claudeStart an interactive session in the current directory
claude "explain this project"Start a session with a first prompt
claude -cContinue the most recent conversation in this directory
claude -r "auth-refactor"Resume a session by ID or name
claude -rOpen the session picker
claude -n "auth-refactor"Give a new session a name you can resume later
claude --resume abc123 --fork-sessionResume, but write to a new session ID
claude -w feature-authStart in an isolated git worktree under .claude/worktrees/
claude updateUpdate to the latest version

A few habits make these work better:

  • Name sessions you will come back to. claude -n "billing-fix" is easier to find than a UUID, and claude -r billing-fix jumps straight back.
  • Use -c only when the last conversation is the one you want. It picks the most recent session in the current directory. If you ran something else in between, use -r and the picker.
  • Fork before you experiment. --fork-session keeps the original conversation intact while you try a different direction.

The difference between continue and resume matters most when you run several sessions in one repository. We cover that workflow in run multiple Claude Code sessions.

Control a session with slash commands

Inside a session, a command is only recognized at the start of your message, and any text after it becomes its arguments. These are the built-in commands that change what Claude is working with.

CommandUse it to
/clear [name]Start a new conversation with empty context
/compact [instructions]Summarize the conversation so far to free context
/contextSee context usage as a colored grid
/resume [session]Switch to another conversation by ID or name
/rename [name]Rename the current session
/branch [name]Branch the conversation at this point and switch into the branch
/rewindRestore the conversation or code to an earlier point (aliases /checkpoint and /undo)
/export [filename]Save the conversation as plain text
/exitLeave the CLI (alias /quit)

The pair people mix up most is /clear and /compact. /clear throws the context away and starts fresh, which is right when you switch to an unrelated task. /compact keeps working on the same task with a summary instead of the full history, which is right when a long task is running out of room. You can steer the summary: /compact keep the failing test names and the migration plan. For what survives compaction and how to read /context, see our guide to the Claude Code context window.

Left panel /clear: five blocks of conversation history disappear and the context starts empty. Right panel /compact: the same five blocks are replaced by one green block labelled Summary of the task.
/clear empties the context for a new task; /compact replaces the history with a summary so the same task can continue.

/rewind is the safety net. Pressing Esc twice on an empty prompt opens the same rewind menu, where you can restore code, conversation or both to an earlier message.

Plan, permissions, model and effort

These commands change how Claude works rather than what it knows.

CommandUse it to
/plan [description]Enter plan mode, optionally with the task, for example /plan fix the auth bug
/permissionsView and edit allow, ask and deny rules
/model [model]Switch the model; with no argument it opens a picker
/effort [level]Set the effort level, or /effort status to print it
/configOpen settings, or set one directly, for example /config theme=dark
/output-style [style]List output styles or switch to one

Shift+Tab cycles permission modes without typing a command: default, acceptEdits, plan, and the others your setup allows. If you want a session to start in a mode, set it from the shell instead with claude --permission-mode plan. Our guides to Claude Code plan mode and Claude Code permissions explain when each mode is safe.

Project setup, memory and extensions

CommandUse it to
/initCreate a CLAUDE.md guide for the project
/memoryEdit CLAUDE.md files and manage auto memory
/skillsList available skills
/agentsGet help creating or managing subagents
/hooksView hook configurations
/mcpManage MCP server connections and authentication
/add-dir <path>Give the session access to another directory
/statuslineConfigure the status line (see our Claude Code statusline guide)

Custom commands have been merged into skills. A file at .claude/commands/deploy.md and a skill at .claude/skills/deploy/SKILL.md both create /deploy, and existing command files keep working. If you are writing new commands, start with a skill. Our Claude Code skills guide shows the file layout and frontmatter.

Review, usage and diagnostics

CommandUse it to
/diffReview the changes in your working tree, including Claude's edits
/code-reviewReview the current diff, a branch or a pull request for correctness bugs (alias /review)
/security-reviewCheck the changes on your branch for security problems
/usageShow session cost, plan usage limits and activity (aliases /cost and /stats)
/statusShow version, model, account and connectivity
/doctorRun a setup checkup that diagnoses and proposes fixes
/tasksView and manage background work in the session
/btw [question]Ask a side question without adding it to the conversation

/status, /tasks and /usage run immediately even while Claude is responding, so you can check your limits mid-task. If you hit a limit often, our guide to Claude Code usage limits explains the session and weekly windows.

Input prefixes and shortcuts

Not everything is a slash command. Three prefixes change what your input means:

  • / at the start runs a command or skill.
  • ! at the start runs a shell command directly, adds its output to the session and lets Claude respond to it. ! npm test is a quick way to show Claude a failure.
  • @ triggers file path autocomplete, so you can point Claude at a file without pasting it.

And a handful of keys do the rest:

KeyEffect
EscInterrupt Claude mid-turn; work done so far is kept
Esc EscClear the input draft, or open the rewind menu when the input is empty
Shift+TabCycle permission modes
Ctrl+RSearch your prompt history
Ctrl+OToggle the transcript viewer with detailed tool output
Ctrl+BSend running Bash commands and agents to the background
Ctrl+CInterrupt, or clear the input; a second press on an empty prompt exits

The full list, including vim mode, is in the interactive mode reference.

Flags for scripts and CI

When Claude Code runs without you watching, these flags do most of the work:

# One answer, printed, then exit
claude -p "summarize the open TODOs in src/"

# Structured output for a script
claude -p "list failing tests" --output-format json

# Bound the run
claude -p --max-turns 5 --max-budget-usd 2.00 "fix the lint errors"

# Skip auto-discovery for a faster, predictable start
claude --bare -p "explain this function"

# Pre-approve specific tools
claude -p "review the diff" --allowedTools "Bash(git diff *)" "Read"

--max-turns and --max-budget-usd only apply in print mode. --bare skips hooks, skills, plugins, MCP servers, auto memory and CLAUDE.md, which makes scripted calls faster but also means your project rules do not load. Our guide to Claude Code headless mode covers output formats, schemas and resuming in scripts.

A command line claude -p --max-turns 5 --max-budget-usd 2.00 above a progress bar of turns used that fills up until a red label reads limit reached: exit. Notes explain --output-format json and --bare.
In print mode, --max-turns and --max-budget-usd stop a run that would otherwise keep going; --output-format json and --bare make it script friendly.

Keep track when you run many sessions

Commands are per session. Once you have several Claude Code sessions open across projects, the hard part is no longer remembering /compact; it is remembering which terminal holds which request. VibeiDE is a desktop app that coordinates the Claude Code, Codex and OpenCode CLIs you already installed. Claude Code runs in embedded terminals that show the original CLI interface, so every command in this guide works as usual. Each project has its own task queue, each task keeps its saved provider conversation so a follow-up can continue it, and finished tasks wait in Ready for review. See Claude Code orchestration across your projects for how that fits around your existing setup.

Takeaways

  • Shell commands and flags choose the session; slash commands steer it once it runs.
  • Use claude -n to name sessions and claude -r <name> to return to them; use -c only for the last one.
  • /clear is for a new task, /compact is for a long task that needs room, and /rewind undoes a wrong turn.
  • /plan, /permissions, /model and /effort change how Claude works; Shift+Tab cycles modes without typing.
  • Custom commands are now skills; /skills lists them.
  • For scripts, combine -p with --output-format, --max-turns and --max-budget-usd.
  • The commands reference is the source of truth; type / in a session to see what your version supports.

Share this article

Post on XShare on LinkedIn

Related articles

Necessary cookies support sign-in, security, your language and this choice. Optional categories stay off until accepted.

First-party page views and acquisition measurement, plus Google Analytics 4 (Google Ireland, data may reach the US). Advertising personalization stays off.

With Analytics enabled, retain Google, Microsoft and Reddit ad click identifiers and share download, signup, activation and purchase conversions with the relevant ad provider. No personalized advertising.

Privacy · Cookie inventory