1 / 6
THE COMPLETE REFERENCE

Claude Code
Command Cheat Sheet

Every command, shortcut, and trick you need to go from beginner to power user


Core CLI Commands

claude Launch interactive REPL session in the current directory
claude "fix the login bug" Start a session with an initial prompt already loaded
claude -p "query" Print mode: get one answer and exit (great for scripts and CI)
claude -c Continue your most recent session with full context preserved
claude -r "session-id" Resume a specific named session by its ID
claude -w feature-branch Work in an isolated git worktree (changes don't touch main)
claude update Update Claude Code to the latest version
--model opus Switch to a specific model
--max-turns 5 Limit conversation turns
--max-budget-usd 5 Cap spending per session
--output-format json Structured output for scripts
--allowedTools Permit specific tools only
--effort high Set reasoning effort level
--verbose Show detailed execution logs
--add-dir ./libs Add extra working directories
!
First thing on any new project: Run /init to auto-generate a CLAUDE.md file. This saves tokens and dramatically improves consistency by giving Claude project context upfront.
2 / 6
IN-SESSION COMMANDS

Slash Commands

Session Management
/clear Wipe history, free context window
/compact Summarize to recover token space
/cost Show token usage and API costs
/context Visualize context consumption
/resume Pick and resume a past session
/rename Name the current session
/diff Interactive diff of all changes
/export Export conversation as text file
Configuration & Mode
/model Switch model (sonnet, opus, haiku)
/effort Set reasoning: low / medium / high
/config Open interactive settings editor
/fast Toggle Fast Mode (2.5x speed)
/plan Read-only exploration mode
/vim Enable vim-style keybindings
/theme Change terminal color theme
/terminal-setup Install terminal key shortcuts
Project Tools
/init Generate CLAUDE.md for project
/memory View and edit CLAUDE.md directly
/security-review Scan uncommitted changes for vulns
/simplify 3-agent code quality review
/review <PR#> Full code review on a pull request
/pr-comments Fetch PR review feedback
/batch Parallel changes via worktrees
/add-dir Add extra directory to context
Integration & System
/mcp Manage MCP server connections
/hooks Configure automation triggers
/agents Manage sub-agents and skills
/doctor Diagnose env, auth, MCP health
/btw Quick side question (no derailing)
/help Show all available commands
/loop 5m /task Run command on recurring interval
/voice Toggle push-to-talk dictation
TOP 3 COMMANDS MOST PEOPLE MISS
/btw
Ask a quick side question without polluting context. Claude sees your full conversation but won't add to history.
/compact
Running out of context? Compress your conversation. Add a focus keyword to keep specific topics intact.
/batch
Need changes across many files? Spawns parallel agents in isolated worktrees. Merge back when done.
3 / 6
WORK AT TERMINAL SPEED

Keyboard Shortcuts & Notation

General Controls
Ctrl+C Cancel current generation
Ctrl+D Exit the session
Ctrl+L Clear screen (keeps history)
Ctrl+G Edit prompt in external editor
Ctrl+O Toggle verbose / thinking output
Ctrl+R Search through command history
Ctrl+V Paste image from clipboard
Ctrl+B Background running tasks
Ctrl+T Toggle task list visibility
Power Shortcuts
Esc + Esc Rewind to checkpoint (undo!)
Shift+Tab Cycle: normal / auto / plan
Alt+P Switch model mid-prompt
Alt+T Toggle extended thinking
Hold Space Push-to-talk voice input
Tab Accept prompt suggestion
? Show all available shortcuts
Text Editing
Ctrl+K Delete to end of line
Ctrl+U Delete entire line
Ctrl+Y Paste deleted text
Alt+B / Alt+F Move word back / forward
Prompt Notation (Quick Prefixes)
/
Slash Commands
Access all slash commands and custom skills. Type any letters after to filter the list.
/compact focus on auth
!
Bash Mode
Run shell commands directly. Output is added to conversation context. No approval needed.
!npm test
@
File Mention
Autocomplete file and directory paths. Supports globs for pattern matching across files.
@src/api/**/*.ts
#
Memory Add
Add content directly to your CLAUDE.md project instructions file for persistent context.
#always use TypeScript strict
MULTILINE INPUT METHODS
\ + Enter
Works in all terminals
Option+Enter
Default on macOS
Shift+Enter
iTerm2, WezTerm, Ghostty
Ctrl+J
Line feed character
4 / 6
PROJECT SETUP

Configuration & Files

File Structure
User-Level (Personal)
~/.claude/
  settings.json global prefs
  keybindings.json custom keys
  CLAUDE.md global rules
  rules/ modular rules
  agents/ custom agents
  skills/ personal commands
  .mcp.json global MCP config
Project-Level (Shared)
.claude/
  settings.json team settings
  settings.local.json gitignored
  rules/ path-scoped rules
  agents/ project agents
  skills/ team commands
CLAUDE.md project instructions
.mcp.json project MCP servers
CLAUDE.md: Your Project's Brain
This file gives Claude context about your project. It saves tokens, prevents hallucinations, and makes every session consistent. Run /init to generate one automatically.
Build & test commands so Claude knows how to run your project
Code style rules to match your team's conventions
Architecture overview so Claude understands the system
@file references pointing to key docs and configs
Do's and don'ts specific to your project domain
Path-scoped rules via .claude/rules/ for subsystems
Permission Modes (Toggle with Shift+Tab)
?
Normal
Prompts for permission before each file edit or command. The safe default for exploration and review.
Default
Auto-Accept
Approves all tool uses automatically. Use when you trust the task scope and want hands-free execution.
Fast Work
Plan Mode
Read-only exploration. Claude reads files and analyzes code but makes zero edits. Great for research first.
Read Only
Pre-Approve Tools in Settings
Allow (auto-approve)
"Read"
"Bash(git *)"
"Bash(npm run *)"
"Bash(npx *)"
Deny (block always)
"Bash(rm -rf *)"
"Read(.env)"
"Write(prod.config.*)"
"Bash(curl * | sh)"
Settings Priority (Highest to Lowest)
1
Managed
(Enterprise)
2
CLI
Flags
3
Local
Settings
4
Project
Settings
5
User
Settings
5 / 6
LEVEL UP

Power Features

Hooks (Automation Triggers)
Shell commands that run automatically at key lifecycle events. Configure via /hooks or in .claude/settings.json.
PreToolUse
Before tool runs
PostToolUse
After tool completes
SessionStart
Session begins
Stop
Claude stops work
Notification
Alerts & updates
UserPrompt
Before prompt sent
Auto-format code
PostToolUse: run Prettier after every file write to keep code clean automatically.
Lint on save
PostToolUse: run ESLint on edited .ts files. Catch issues before they reach review.
Inject context
SessionStart: load team-specific rules, inject docs, or set env variables at launch.
MCP (Model Context Protocol)
Connect Claude to external tools and services. MCP servers give Claude access to GitHub, Jira, databases, browsers, and anything with an API.
# Add a new MCP server
claude mcp add github -- npx @mcp/server-github
# Check status in session
/mcp
Custom Skills
.claude/skills/deploy/SKILL.md
Reusable slash commands written in Markdown. Define a workflow once, invoke it with a single command across all sessions.
Supports arguments ($1, $2), frontmatter for permissions, and auto-invocation triggers based on file patterns.
Sub-Agents
.claude/agents/reviewer/AGENT.md
Specialized Claude instances with isolated context windows. Delegate verbose tasks to protect your main session's context.
Each agent can have its own model, tools, and persona. Create with /agents or edit the Markdown directly.
Models & Effort Levels
Sonnet
Fast, balanced
Daily coding (default)
Opus
Most capable
Complex architecture
Haiku
Lightweight
Simple tasks, CI/CD
EFFORT:
low
medium
high
max
6 / 6
BECOME A POWER USER

Pro Workflows & Tips

Piping Patterns (Non-Interactive Automation)
Use claude -p in scripts and CI pipelines. Pipe any text in, get structured answers out.
Debug Errors
tail -500 app.log | claude -p "find root cause"
Feed error logs directly to Claude for instant triage and suggested fixes.
Security Review
gh pr diff 42 | claude -p "security review"
Pipe a PR diff for automated vulnerability scanning on every pull request.
Commit Messages
git diff --staged | claude -p "write commit msg"
Generate precise commit messages from your staged changes. Never write "misc fixes" again.
Structured Output
claude -p "list deps" --output-format json
Get machine-readable JSON output for integration with other tools and dashboards.
Cost Control Strategies
/cost
Check spending in real time. Monitor tokens used and API costs per session.
/effort low
Reduce thinking tokens on simple questions. Save budget for complex tasks.
/compact
Compress conversation history. Free up context window without losing key points.
--max-budget-usd 5
Hard spending cap per session. Prevents runaway costs on long-running tasks.
/clear
Start fresh between unrelated tasks. Don't waste tokens on stale context.
--model haiku
Use the cheapest model for simple CI tasks, quick lookups, and formatting.
10 Tips That Save Hours
1
Plan Before Edit
Press Shift+Tab for Plan Mode. Explore the codebase read-only, then switch back to implement.
2
Use @file Mentions
Point Claude to exact files with @path/to/file instead of letting it search. Saves tokens and time.
3
Undo with Esc+Esc
Made a mistake? Double-tap Escape to rewind code and conversation to a previous checkpoint.
4
Side Questions: /btw
Need a quick answer without derailing? Use /btw for ephemeral questions that don't touch history.
5
Name Your Sessions
Run /rename feature-auth so you can resume later with claude -r "feature-auth" and pick up where you left off.
6
Break Large Tasks
Give Claude one clear step at a time. Small, focused prompts get better results than huge specifications.
7
Background Tasks
Press Ctrl+B to background long-running commands. Keep prompting while builds or tests run.
8
Git Worktrees: -w
Use claude -w to experiment in an isolated copy. If it works, merge. If not, discard with zero risk.
9
Voice Input
Hold Space for push-to-talk dictation. Describe complex requirements verbally instead of typing paragraphs.
10
Run /init First
Always initialize CLAUDE.md on new projects. It saves tokens, prevents hallucinations, and improves every session.
SAVE THIS CHEAT SHEET
Bookmark for daily reference. The difference between a beginner and a power user is knowing which 10 commands to reach for. Master these shortcuts, pipe everything, and let Claude Code handle the heavy lifting.
Rizvi Haider by Rizvi Haider