简繁EN
← ToolsTools · Guide

A Claude Code Command Cheat Sheet

Slash commands, shortcuts, input prefixes and launch flags, grouped by when you need them, plus a few habits for beginners.

Date
Reading2 min read
Tags#Claude Code

Claude Code is Anthropic’s AI assistant for the terminal. I can’t write code, yet I built this site with it. Here are the commands I use, grouped by situation.

Slash commands

Type / in the prompt to open the command list.

Everyday

Command What it does
/help Show help and every available command
/clear Clear the conversation and start fresh (use it between tasks)
/compact Compress the conversation history to save context
/resume Resume an earlier conversation
/rewind Go back to an earlier step, including undoing code edits
/exit Quit Claude Code

Settings and models

Command What it does
/model Switch model (Opus / Sonnet / Haiku)
/fast Toggle fast mode
/config Open settings (theme, default model and more)
/permissions Choose which actions no longer need your approval
/statusline Customize the status line
/login Sign in; /logout signs out

Projects and memory

Command What it does
/init Generate a CLAUDE.md guide for the current project
/memory Edit memory files so Claude remembers your preferences
/add-dir Give Claude access to another folder
/context See how much context is in use

Usage and diagnostics

Command What it does
/cost Token spend for this conversation
/usage Plan usage and limits
/status Account, model and version details
/doctor Check the installation for problems
/export Export the conversation

Advanced

Command What it does
/mcp Manage MCP servers (connections to outside tools)
/agents Manage subagents
/hooks Set up automations, such as “run X every time a file changes”
/plugin Install and manage plugins
/code-review Review code changes for bugs
/loop 5m task Repeat a task on an interval

Keyboard shortcuts

Keys What it does
Esc Interrupt what Claude is doing
Esc Esc Press twice to go back to an earlier message
Shift + Tab Cycle modes: normal → auto-accept edits → plan mode
↑ ↓ Browse what you typed before
\ + Enter New line in the prompt
Ctrl + C Cancel input; press twice to quit
Ctrl + V Paste an image, such as a screenshot

Input prefixes

Prefix What it does Example
@ Reference a file or folder @plan.pdf summarize this
! Run a shell command directly ! ls
/ Run a slash command /clear

Launching from the terminal

Before you’re inside Claude Code, run these in the terminal:

claude                  # start an interactive session
claude "question"       # start with a first question
claude -c               # continue the last conversation
claude -r               # pick an earlier conversation to resume
claude -p "question"    # answer once and exit, handy in scripts
claude --model opus     # start with a specific model
claude update           # update to the latest version

Habits for beginners

  1. Run /clear before a new task so the old conversation doesn’t interfere.
  2. For bigger tasks, press Shift + Tab into plan mode. Claude proposes a plan and waits for your approval.
  3. If Claude heads the wrong way, press Esc, and undo unwanted edits with /rewind.
  4. When a long conversation makes Claude forgetful, run /compact.
  5. Run /init once at the start of a project so Claude gets up to speed quickly every time.

Commands change between versions. For the definitive list, type /help on your own machine.