Skip to content

Claude Code commands & shortcuts cheatsheet

Quick-reference tables explaining every useful Claude Code slash command, keyboard shortcut, and hidden feature.

Tuan Tran Van
9 min read
Contents (8 sections)
  1. Essential commands for everyday sessions
  2. Managing context and cost
  3. Setup and configuration commands
  4. Keyboard shortcuts worth memorizing
  5. Hidden commands and lesser-known features
  6. Create your own custom slash commands
  7. FAQ
  8. References

Claude Code commands are the /-prefixed slash commands that control Claude Code from inside a session — switch models, manage permissions, clean up context, or run a whole workflow with a single line.

Together with the keyboard shortcuts, they are the fastest way to get fluent with the tool. This article collects every useful command and shortcut into quick-reference tables you can use immediately.

Most of the friction new users hit doesn't come from commands being hard — it comes from not knowing a command already exists. A command is only recognized at the start of your message; any text after the command name is passed to it as arguments. You don't need to memorize this cheatsheet — you only need to know each command exists so you can reach for it at the right moment.

If you've never used the tool before, read What is Claude Code first, then come back to this reference.

Claude Code session in a terminal with the slash-command menu open after typing /, listing available commands with short descriptions

Essential commands for everyday sessions

These Claude Code commands carry you through a normal working session: starting new work, returning to old work, undoing mistakes, and getting results out.

CommandPurpose
/helpList all available commands
/clearStart a new conversation with empty context; the old one stays available. Aliases: /reset, /new
/resumeReopen a previous session by name, or open the session picker. Alias: /continue
/rewindRoll code and conversation back to an earlier checkpoint. Aliases: /undo, /checkpoint
/modelView or switch the active model, with arrow keys to adjust effort level
/planEnter plan mode before a large change, optionally with a task description
/btwAsk a quick side question without bloating the main conversation
/diffOpen an interactive diff viewer: uncommitted changes and per-turn diffs
/copyCopy the last response, or pick individual code blocks
/exportExport the conversation to a file or the clipboard
/renameName the current session so it's easy to find in /resume
/exitQuit the CLI. Alias: /quit

The standout here is /rewind: every change is checkpointed automatically, so you can try a bold direction and return to your starting point without losing anything. Press Esc twice and the rewind menu appears instantly.

Managing context and cost

The context window is the total amount of text the model can hold. The longer the session, the fuller it gets — and these commands let you see it, clean it, and price it.

Comparison of /clear wiping the conversation versus /compact compressing it into a summary, with auto-compact triggering at about 95% of the context window

CommandPurpose
/contextVisualize context usage as a colored grid, with warnings and optimization suggestions
/compactSummarize the conversation to free context; optionally pass focus instructions
/usageShow session cost, plan limits, and activity stats. Aliases: /cost, /stats

The quick distinction: /clear wipes everything for a different task, /compact condenses so you can continue the current one. When context hits about 95%, auto-compact kicks in and preserves the essential information, so long sessions continue without breaking.

Setup and configuration commands

A first session in a repo usually follows this sequence: /init generates a starter CLAUDE.md, /memory refines it, /mcp and /agents connect the servers and subagents the project needs, then /permissions sets the approval rules you want.

CommandPurpose
/initInitialize the project with a CLAUDE.md guide
/memoryView and edit CLAUDE.md files, toggle auto-memory
/permissionsManage allow / ask / deny rules per tool. Alias: /allowed-tools
/configOpen settings: theme, default model, editor mode. Alias: /settings
/mcpManage MCP (Model Context Protocol) server connections and OAuth
/agentsCreate and manage subagents for delegated work
/hooksView hook configurations — shell commands that run on tool events
/skillsList available skills, hide the ones you don't use
/add-dirGrant file access to an additional directory outside the project
/statusShow version, model, account, and connectivity
/doctorDiagnose installation and settings; press f to have Claude fix reported issues
/login / /logoutSign in or out of your Anthropic account

CLAUDE.md is read automatically each session — it's where project conventions, architecture, and constraints live so you don't repeat them every time you open the terminal.

Keyboard shortcuts worth memorizing

Shortcuts save more keystrokes than commands do, because they work even while Claude is mid-response.

Shift+Tab cycling through the three permission modes: default, auto-accept edits, and read-only plan mode

ShortcutAction
Shift+TabCycle permission modes: default → auto-accept edits → plan mode
EscInterrupt the current response immediately
Esc EscOpen the rewind / checkpoint menu
Ctrl+CCancel current input, or exit on an empty prompt
Ctrl+RReverse-search your prompt history
Ctrl+OExpand the verbose transcript view
Ctrl+GOpen an external editor — handy for multi-line input
Ctrl+TToggle the running task list
Ctrl+VPaste an image from the clipboard — Ctrl even on Mac, not Cmd
/ Scroll through previous prompts
@ + pathReference files or directories right in the prompt
?Show the shortcut table for your current terminal / IDE

Shift+Tab is the most valuable row in the table: plan mode lets Claude read and analyze the codebase in read-only mode before proposing an implementation — success rates on larger tasks improve noticeably. If you work in VS Code or certain terminals, also run /terminal-setup to configure Shift+Enter for newlines.

Hidden commands and lesser-known features

Anthropic ships features frequently, and not everything stands out in the docs. The group below is little known but immediately useful.

Command / featurePurpose
claude -p "..."Non-interactive mode: returns a result and exits, and accepts piped input from other commands
! + shell commandRun a shell command directly (e.g. !git status) and feed its output into the conversation
/statuslineCustomize the status line — track token consumption in real time
/insightsGenerate a report analyzing your sessions: project areas, interaction patterns, friction points
/tasksView and manage everything running in the background of the current session
/backgroundDetach the current session to run as a background agent and free the terminal. Alias: /bg
/teleportPull a Claude Code on the web session into this terminal
/output-styleSwitch response styles: default (concise), Explanatory, or Learning
/release-notesBrowse the changelog per version right in the CLI

The -p mode fits automation scripts and CI/CD because it needs no interactive session:

bash
claude -p "explain this function"
cat logs.txt | claude -p "summarize the main errors"

There's also an experimental feature for large projects: set the environment variable CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 to enable agent teams — a lead agent coordinates multiple independent Claude Code instances running in parallel.

Create your own custom slash commands

A custom command is just a Markdown file. Put it in .claude/commands/ for a project-specific command, or ~/.claude/commands/ for one that works everywhere. The filename becomes the command name.

Custom command flow: a Markdown file placed in .claude/commands/ becomes the /unit-test command, with arguments substituted into $ARGUMENTS

markdown
<!-- .claude/commands/unit-test.md -->
 
Generate comprehensive unit tests for $ARGUMENTS.
Include edge cases and error handling.

Type /unit-test src/utils.js and src/utils.js is substituted into $ARGUMENTS. The rule of thumb for what to turn into a command: anything you repeat — commits in your team's format, test runs, production builds — deserves a Markdown file.

When a command needs a multi-step workflow or references to supporting files, upgrade it to a skill: the same mechanism but more powerful, with disable-model-invocation: true available if you want it to be user-invoked only.

FAQ

How do I quickly see every command I have? Type / to open the full command menu, then keep typing letters to filter. /help lists everything with descriptions. Note that not every command appears for every user — availability depends on your platform, plan, and environment.

What's the difference between /clear and /compact? /clear wipes the conversation — use it when switching to a completely new task. /compact summarizes the conversation to save context — use it mid-task to keep going. A cleared conversation can still be reopened with /resume.

Do custom commands work across all my projects? It depends on where the file lives: ~/.claude/commands/ works in every project on your machine, while .claude/commands/ only works inside the project that contains it. Keep general-purpose and project-specific commands in those two separate folders.

Do I need to memorize all the Claude Code commands? No. Knowing about ten core ones — /clear, /compact, /plan, /resume, /rewind, /permissions — plus Shift+Tab covers smooth daily work; look the rest up in the tables when needed.

References

Read more

Share this article