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

CommandWhat it DoesWhen to Use
/helpShow all available commands and usage tipsWhen you forget a command or want to explore options
/clearClear the conversation history and start freshWhen switching topics or if Claude seems confused
/compactSummarize the conversation to reduce token usageDuring long sessions to save context space and cost
/costShow token usage and cost for the current sessionTo monitor spending during a session
/initCreate a CLAUDE.md file for your projectFirst time setting up Claude Code in a project
/statusShow current session info (model, mode, project)To confirm which project or mode you are in
/reviewAsk Claude to review your recent code changesBefore committing to catch issues early
/bugReport a bug to the Claude Code teamWhen 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
Tip
Use /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.

ShortcutAction
Ctrl + CCancel the current operation or interrupt Claude mid-response
Up ArrowCycle through previous messages (command history)
EscapeCancel the current input line or dismiss a prompt
Shift + EnterInsert a new line in your message (multi-line input)
EnterSend the current message
TabAutocomplete 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
Use with Caution
Only use this flag when you fully trust the operations Claude will perform, ideally on a project with Git version control so you can revert any unintended changes. This mode is best suited for well-defined, low-risk tasks.

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.

FlagDescription
claudeStart 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 --continueResume the most recent conversation
claude --resumePick a previous conversation to resume
claude --modelSpecify 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
Quick Reference
You do not need to memorize all of these right now. Start with just four commands: /help, /clear, /compact, and /cost. You can always type /help to discover the rest.