Skip to content
DevPedia

Getting startedGuide 3 of 12

Essential commands and shortcuts

Commands and shortcuts for everyday work with Claude Code, plus how to pick a model based on the task.

Updated 6 min read

This is the quick reference: the most frequently used commands and shortcuts, grouped by what they solve.

Context management

CommandWhat it does
/compactSummarizes the conversation history to free up space, without losing the thread of what you’re doing.
/clearWipes the whole history and starts from scratch. Use it when you switch tasks completely.
/contextShows you what’s taking up your context window — useful for deciding whether to compact.

Planning and change control

CommandWhat it does
/planA mode where Claude explores and puts together a plan without touching your code yet. Ideal before a large task.
/diffShows the changes made, so you can review them at a glance before committing.
/rewind (or double Esc Esc)Undoes code and conversation changes, returning to an earlier point. Useful when the current approach isn’t working and it’s better to back out.

Permissions

Command / shortcutWhat it does
/permissionsOpens the panel for viewing and editing which commands/tools are allowed, denied, or require confirmation.
Shift+TabCycles through the permission modes without typing anything (see Permissions in Claude Code).

Everyday work / repo

CommandWhat it does
/initGenerates an initial CLAUDE.md by analyzing your repo. Ideal when starting a new project.
/memoryLists and opens your memory files, and turns auto memory on or off. See Memory and context.
/agentsManages subagents: creating, editing, and invoking them.
/mcpView and manage the connected MCP servers.
/security-reviewRuns a security review over the changes on your current branch. See Security when working with Claude Code.

Model and effort

CommandWhat it does
/modelSwitches between models (Sonnet, Opus, Haiku) depending on the complexity of the task.
/effortAdjusts how much the model “thinks” before answering (low to xhigh, plus max and auto) — more effort helps with complex debugging, but burns more quota.

How to choose a model based on the task

/model accepts aliases (haiku, sonnet, opus) that always resolve to the latest version of that family — it’s the most stable way to refer to a model in settings.json or in a subagent, because it doesn’t break every time Anthropic ships a new version. The logic for choosing between families holds even as the specific versions change:

  • Haiku → consider it for high-frequency, low-risk tasks: quick file exploration, linting, subagents running in a loop, or when you’re about to hit your usage limit. Don’t use it for architecture decisions or for debugging a non-obvious root cause.
  • Sonnet → the reasonable default for 80% of daily work: implementing features, contained refactors, writing tests. It’s the starting point until you have a concrete reason to switch.
  • Opus → save it for problems where the cost of a bad decision is high: architecture design, a bug that has already survived a couple of attempts, a security review. Avoid it for repetitive or low-risk work — it’s the most expensive and slowest of the three.

There are two axes, independent of each other, that are worth not confusing: the model (how capable it is) and /effort (how much reasoning time it spends before answering). You can run Sonnet at high effort for a one-off debugging session without escalating to Opus, and it’s almost always cheaper than moving up a family.

Start on Sonnet as your default. Move up to Opus only once Sonnet has already given you an unconvincing answer on a genuinely hard problem, not preemptively. Drop to Haiku for mechanical, high-volume work — an exploration subagent invoked twenty times in the same session is a good candidate.

Command / shortcutWhat it does
/add-dirGives it access to another folder besides the current one — useful in monorepos.
/cdMoves the session to another directory without losing the conversation.
@Attaches a specific file to your message (autocompletes with the file explorer).
!Starting a message with ! runs a shell command directly, without going through Claude.
EscInterrupts Claude while it’s working.

Related documentation: this is a curated selection — the complete command reference includes several more, among them /doctor, /code-review, and the ones added by the SDK or by installed plugins.

Share this guide

Search by concept, pattern or practice.