Commands & Shortcuts
Master the slash commands, keyboard shortcuts, and configuration options that make your Claude Code sessions faster and more efficient.
Slash Commands
Slash commands are special instructions you type at the Claude Code prompt. They start with a forward slash (/) and give you quick access to features that would be awkward to express in natural language.
Essential Slash Commands
| Command | What it Does | When to Use |
|---|---|---|
| /help | Show all available commands and usage tips | When you forget a command or want to explore options |
| /clear | Clear the conversation history and start fresh | When switching topics or if Claude seems confused |
| /compact | Summarize the conversation to reduce token usage | During long sessions to save context space and cost |
| /cost | Show token usage and cost for the current session | To monitor spending during a session |
| /init | Create a CLAUDE.md file for your project | First time setting up Claude Code in a project |
| /status | Show current session info (model, mode, project) | To confirm which project or mode you are in |
| /review | Ask Claude to review your recent code changes | Before committing to catch issues early |
| /bug | Report a bug to the Claude Code team | When you encounter unexpected behavior |
The /init Command
This is one of the most important commands you will use. When you run /init in a project, Claude analyzes your codebase and generates a CLAUDE.md file tailored to your project. This file acts as persistent memory—Claude reads it at the start of every session to understand your project's conventions, structure, and preferences.
> /init Claude will: 1. Scan your project structure 2. Read key files (package.json, README, config files) 3. Generate a CLAUDE.md with: - Project description - Tech stack and dependencies - Build and test commands - Code conventions it detected - File organization notes
We cover CLAUDE.md in depth in the next lesson. For now, just remember that /init is how you create it.
The /compact Command
Every message in your conversation uses tokens. Long conversations get expensive and can bump up against context limits. The /compact command tells Claude to summarize the conversation so far into a condensed form, freeing up tokens while keeping the essential context.
> /compact # You can also provide a focus for the compaction: > /compact focus on the database migration work we discussed
/compact proactively during long sessions. A good rule of thumb: if you have been working for more than 20–30 exchanges, run /compact to keep things snappy. You can also use /cost first to check how much context you have been accumulating.Keyboard Shortcuts
These keyboard shortcuts work directly in the Claude Code terminal interface and can significantly speed up your workflow.
| Shortcut | Action |
|---|---|
| Ctrl + C | Cancel the current operation or interrupt Claude mid-response |
| Up Arrow | Cycle through previous messages (command history) |
| Escape | Cancel the current input line or dismiss a prompt |
| Shift + Enter | Insert a new line in your message (multi-line input) |
| Enter | Send the current message |
| Tab | Autocomplete slash commands and file paths |
Interrupt and Redirect
One of the most useful patterns is Ctrl + C to interrupt. If Claude starts going down the wrong path—editing the wrong file, writing an approach you do not want, or just taking too long—press Ctrl + C to stop it. Then clarify what you actually want. This is far better than waiting for Claude to finish something you will throw away.
> Add authentication to the API # Claude starts implementing JWT but you wanted OAuth... # Press Ctrl+C to interrupt > Actually, I want OAuth 2.0 with Google as the provider, not JWT tokens
Permission Modes
Claude Code has permission modes that control how much autonomy Claude has when working with your files and running commands. Understanding these helps you find the right balance between safety and speed.
Default Mode
In the default mode, Claude asks for permission before performing potentially impactful actions. You will be prompted before:
- Writing or editing files
- Running bash commands
- Installing packages
This is the recommended mode for beginners. You maintain full control and can review every action before it happens.
Trusting Claude: --dangerously-skip-permissions
For experienced users who want maximum speed, you can launch Claude Code with the flag --dangerously-skip-permissions. In this mode, Claude executes all file operations and commands without asking first.
$ claude --dangerously-skip-permissions
Allowlisting Specific Tools
A middle ground between default mode and full trust: you can allow specific tools (file editing, bash commands, etc.) so Claude does not ask for those particular operations. Configure this in your settings or via the permission prompt by typing always when prompted.
Command-Line Flags
When launching Claude Code from the terminal, you can pass flags to customize behavior.
| Flag | Description |
|---|---|
| claude | Start an interactive session in the current directory |
| claude "prompt" | Start a session with an initial prompt |
| claude -p "prompt" | Run a one-shot prompt (non-interactive, prints and exits) |
| claude --continue | Resume the most recent conversation |
| claude --resume | Pick a previous conversation to resume |
| claude --model | Specify which Claude model to use |
Piping Input to Claude
You can pipe data from other commands directly into Claude Code. This is extremely powerful for integrating Claude into scripts and workflows.
# Pipe a file for review $ cat src/api.ts | claude -p "Review this code for bugs" # Pipe git diff for a commit message $ git diff --staged | claude -p "Write a commit message for these changes" # Pipe error logs for analysis $ npm run build 2>&1 | claude -p "Explain these build errors and how to fix them"
Daily Workflow Patterns
Here are the commands and patterns that experienced Claude Code users rely on daily.
Starting Your Day
# Navigate to your project $ cd ~/Projects/my-app # Resume yesterday's conversation (if relevant) $ claude --continue # Or start fresh $ claude > What changed in the codebase since yesterday? Check git log.
Mid-Session Management
# Check how much you've spent > /cost # Conversation getting long? Compress it > /compact # Switching to a different task? Clear and start fresh > /clear # Need to see Claude's status? > /status
Ending Your Session
# Ask Claude to summarize what was accomplished > Give me a summary of everything we did today # Check final cost > /cost # Exit > /exit # Or press Ctrl+D
/help, /clear, /compact, and /cost. You can always type /help to discover the rest.