Getting started
Introduction
Claude Code is Anthropic's AI coding assistant for the terminal. This reference covers the most commonly used commands, flags, and settings.
- Claude Code documentation (code.claude.com)
- GitHub repository (github.com)
Install
curl -fsSL https://claude.ai/install.sh | bash # native install
brew install --cask claude-code # Homebrew (macOS)
mise use -g claude # mise.jdx.dev
npm install -g @anthropic-ai/claude-code # npm (deprecated)
On Windows: irm https://claude.ai/install.ps1 | iex in PowerShell, or winget install Anthropic.ClaudeCode.
Sign in
claude # first run opens a browser login
claude auth login # sign in again
claude auth status # show the current account
Claude Code needs a Pro, Max, Team, or Enterprise plan, a Console account, or a cloud provider (Amazon Bedrock, Google Cloud, or Microsoft Foundry). ANTHROPIC_API_KEY also works.
Sessions
claude # start interactive session
claude "explain this repo" # start with a prompt
claude -p "summarize README" # print mode: answer and exit
git diff | claude -p "review this diff"
Use claude -c to continue the last conversation, or claude -r "auth-refactor" to resume one by name. See: Quickstart
CLI reference
Commands
Sessions
| Command | Description |
|---|---|
claude | Start interactive session |
claude "query" | Start with an initial prompt |
claude -p "query" | Print response and exit |
claude -c | Continue most recent conversation |
claude -r <session> | Resume a session by ID or name |
Setup
| Command | Description |
|---|---|
claude update | Update to latest version |
claude doctor | Check install and settings |
claude mcp | Configure MCP servers |
claude auth status | Show authentication status |
claude setup-token | Generate a token for CI |
Flags
| Flag | Description |
|---|---|
-p, --print | Print response and exit |
-c, --continue | Continue most recent conversation |
-r, --resume | Resume a session by ID or name |
--model sonnet | Choose the model |
--effort high | Set reasoning effort |
--permission-mode plan | Start in a permission mode |
--add-dir ../lib | Add extra working directories |
--verbose | Show full turn-by-turn output |
Other flags
| Flag | Description |
|---|---|
--debug | Enable debug mode |
--settings file.json | Load settings for this session |
--ide | Auto-connect to your IDE |
-w, --worktree | Start in an isolated git worktree |
--dangerously-skip-permissions | Skip all permission prompts |
Slash commands
Session
Conversation
| Command | Description |
|---|---|
/help | Show available commands |
/clear | Start a new conversation |
/compact | Summarize to free up context |
/context | Show context window usage |
History
| Command | Description |
|---|---|
/resume | Resume a previous conversation |
/rewind | Restore code and conversation |
/export | Export the conversation as text |
Usage
| Command | Description |
|---|---|
/status | Show version, model, and account |
/usage | Show cost and plan limits |
Setup
Settings
| Command | Description |
|---|---|
/config | Open settings or set a value |
/model | Switch the AI model |
/effort | Set reasoning effort |
/memory | Edit memory files |
Project
| Command | Description |
|---|---|
/init | Generate a starter CLAUDE.md |
/permissions | Manage permission rules |
/mcp | Manage MCP connections |
/doctor | Run a setup checkup |
Account
| Command | Description |
|---|---|
/login | Sign in to your account |
/logout | Sign out |
Review
Changes
| Command | Description |
|---|---|
/diff | Review working-tree changes |
/review | Review changes or a pull request |
Security
| Command | Description |
|---|---|
/security-review | Scan changes for vulnerabilities |
Interactive mode
Keyboard shortcuts
Session
| Shortcut | Description |
|---|---|
Ctrl+C | Interrupt, or clear the input |
Ctrl+D | Exit Claude Code |
Esc | Interrupt Claude, or close dialogs |
Esc Esc | Clear the draft, or rewind |
Ctrl+B | Background running tasks |
Prompt
| Shortcut | Description |
|---|---|
Shift+Tab | Cycle permission modes |
Alt+P | Switch model |
Alt+T | Toggle extended thinking |
Ctrl+V | Paste an image from the clipboard |
Display
| Shortcut | Description |
|---|---|
Ctrl+L | Redraw the screen |
Ctrl+R | Search prompt history |
Ctrl+O | Toggle the transcript viewer |
On macOS, use Option instead of Alt.
Input modes
| Input | Effect |
|---|---|
/ | Slash commands and skills |
! | Run a shell command directly |
@ | Mention a file path |
: | Insert an emoji by shortcode |
? | Show the shortcut help panel |
For a newline without sending, press \ + Enter or Ctrl+J — both work in any terminal. Shift+Enter works in many terminals; run /terminal-setup if it doesn't.
Configuration
Settings files
~/.claude/settings.json # user settings
.claude/settings.json # project settings, committed
.claude/settings.local.json # personal project settings
Run /config to edit settings, or pass --settings file.json for one session. See: Settings
Environment variables
| Variable | Purpose |
|---|---|
ANTHROPIC_API_KEY | API key used instead of a subscription |
ANTHROPIC_MODEL | Default model name |
ANTHROPIC_BASE_URL | Route requests through a gateway |
API_TIMEOUT_MS | API timeout (default 600000) |
BASH_DEFAULT_TIMEOUT_MS | Bash tool timeout (default 120000) |
CLAUDE_CODE_DISABLE_AUTO_MEMORY | Turn auto memory off |
DISABLE_AUTOUPDATER | Turn background updates off |
Settings files can also set env vars under an env key. See: Environment variables
Memory
CLAUDE.md # project instructions, committed
CLAUDE.local.md # personal project notes, not committed
~/.claude/CLAUDE.md # instructions for all your projects
/init generates a project CLAUDE.md; /memory edits memory files and auto memory. Import files with @path/to/file.md. See: Memory
Common workflows
Reviewing code
git diff | claude -p "review this diff for bugs"
claude -p "check src/ for security issues"
Inside a session, /review reviews the current diff and /security-review scans it for vulnerabilities.
Scripting
# One-shot JSON output for scripts
claude -p "list the failing tests" --output-format json
# Pipe logs in
cat build.log | claude -p "explain this failure"
Also see
- CLI reference (code.claude.com)
- Commands (code.claude.com)
- Interactive mode (code.claude.com)
- Changelog (code.claude.com)
0 Comments for this cheatsheet. Write yours!