Keyboard Shortcuts
| SHORTCUT | ACTION |
|---|---|
| Enter | Submit prompt (single-line mode) |
| Shift+Enter | New line in multi-line mode |
| Esc | Cancel current generation / go back |
| Ctrl+C | Interrupt running tool / cancel |
| Ctrl+L | Clear screen |
| Ctrl+D | Exit Claude Code |
| Tab | Autocomplete file paths in prompt |
| Up | Cycle through prompt history |
| Ctrl+R | Search prompt history |
Slash Commands
| COMMAND | WHAT IT DOES |
|---|---|
| /help | Show help and available commands |
| /clear | Clear conversation history, start fresh |
| /compact | Compress conversation to save context window |
| /cost | Show token usage and cost for current session |
| /doctor | Check Claude Code installation and diagnose issues |
| /init | Create a CLAUDE.md file for the current project |
| /login | Switch accounts or re-authenticate |
| /logout | Sign out of the current session |
| /model | Switch between Claude models (opus, sonnet, haiku) |
| /permissions | View and edit tool permission settings |
| /review | Review code changes and suggest improvements |
| /status | Show current session info (model, cost, tokens) |
| /vim | Toggle vim keybindings mode |
| /fast | Toggle fast output mode (same model, faster) |
You can also create custom slash commands by adding Markdown files to .claude/commands/. See our Slash Commands Guide.
CLI Flags & Options
Starting a session
| FLAG | USAGE |
|---|---|
| claude | Start interactive session in current directory |
| claude "prompt" | Start with an initial prompt |
| claude -p "prompt" | Print mode — single response, no interactivity |
| claude -c | Continue the most recent conversation |
| claude -r "id" | Resume a specific conversation by ID |
| cat file | claude -p | Pipe input as context for the prompt |
Model & output
| FLAG | USAGE |
|---|---|
| --model opus | Use Claude Opus 4.6 (most capable) |
| --model sonnet | Use Claude Sonnet 4.6 (balanced) |
| --model haiku | Use Claude Haiku 4.5 (fastest, cheapest) |
| --output-format json | Output as JSON (for scripting) |
| --output-format stream-json | Stream JSON events |
| --verbose | Show detailed tool execution info |
| --max-turns N | Limit the number of agentic turns |
Permissions & tools
| FLAG | USAGE |
|---|---|
| --allowedTools "Bash,Read" | Restrict which tools the agent can use |
| --disallowedTools "Edit" | Block specific tools |
| --permission-mode plan | Require approval before edits |
| --dangerously-skip-permissions | Skip all permission prompts (CI/CD only) |
CLAUDE.md Quick Reference
The CLAUDE.md file gives Claude project-specific context and instructions. It's loaded automatically at the start of every session.
| LOCATION | SCOPE |
|---|---|
| ~/.claude/CLAUDE.md | Global — applies to all projects |
| ./CLAUDE.md | Project root — applies to this repo |
| ./src/CLAUDE.md | Directory — applies when working in src/ |
| ./.claude/CLAUDE.local.md | Personal — gitignored, your preferences |
What to put in CLAUDE.md
# Project: My App
## Build & Test
- `npm run dev` to start dev server
- `npm test` to run tests
- `npm run lint` to check linting
## Architecture
- React frontend in src/components/
- Express API in src/api/
- PostgreSQL database, migrations in db/
## Conventions
- Use TypeScript strict mode
- Prefer functional components with hooks
- Write tests for all new features
- Use conventional commits (feat:, fix:, etc.)
Keep CLAUDE.md concise. Claude reads it every session — long files waste tokens. Focus on build commands, architecture overview, and coding conventions that Claude wouldn't know from the code alone.
Hook Events
Hooks let you run custom scripts when specific events occur.
| EVENT | WHEN IT FIRES |
|---|---|
| PreToolUse | Before a tool is executed (can block) |
| PostToolUse | After a tool completes |
| Stop | When Claude finishes responding |
| SubagentStop | When a subagent finishes |
| SessionStart | When a new session begins |
| SessionEnd | When a session ends |
| UserPromptSubmit | When user submits a prompt (can modify) |
| PreCompact | Before conversation context is compressed |
| Notification | When Claude sends a notification |
Hook config example
// In .claude/settings.json
{
"hooks": {
"PreToolUse": [{
"matcher": "Bash",
"command": "echo 'Bash command about to run'"
}],
"Stop": [{
"command": "echo 'Claude finished'"
}]
}
}
Agent Types
Built-in subagent types you can reference:
| TYPE | BEST FOR |
|---|---|
| Explore | Fast codebase search, file discovery, architecture questions |
| Bash | Running terminal commands (git, npm, docker, tests) |
| Plan | Designing implementation strategies, architecture decisions |
| general-purpose | Complex multi-step research, web search, multi-tool tasks |
Permission Modes
| MODE | BEHAVIOR |
|---|---|
| default | Ask before file edits and shell commands |
| plan | Require approval for the plan before any edits |
| acceptEdits | Auto-approve file edits, still ask for bash |
| dontAsk | Auto-approve most actions (still blocks risky ones) |
| bypassPermissions | Skip all prompts (for CI/CD pipelines only) |
Key Files & Directories
| PATH | PURPOSE |
|---|---|
| CLAUDE.md | Project instructions (auto-loaded) |
| .claude/settings.json | Project settings, hooks, permissions |
| .claude/commands/ | Custom slash commands (Markdown files) |
| ~/.claude/CLAUDE.md | Global instructions for all projects |
| ~/.claude/settings.json | Global settings (API keys, preferences) |
| ~/.claude/projects/ | Auto memory, per-project persistent context |
| .mcp.json | MCP server configuration for this project |
| ~/.claude/.mcp.json | Global MCP server configuration |
Pro Tips
Use /compact when context gets large. Claude compresses the conversation into a summary, freeing up tokens for more work. Do this proactively before hitting limits.
Drag files into the terminal or use Tab completion to reference files by path. Claude reads them automatically — no need to say "read the file at...".
Pipe anything into Claude: git diff | claude -p "review this" or cat error.log | claude -p "what's wrong?". Great for quick analysis without starting a full session.
Start with sonnet for most tasks. Switch to opus mid-conversation with /model opus only when you need deeper reasoning. Use haiku for simple refactoring.
Install community skills to unlock specialized capabilities: claude plugin add owner/repo. Browse available skills at Skills Playground.
Use claude -c to continue your last conversation. All context is preserved — perfect for picking up where you left off after a break.
Toggle /fast for faster output using the same model. Ideal for repetitive tasks where speed matters more than deep analysis.
Extend Claude with MCP servers for database access, API integrations, and more. Add them to .mcp.json in your project root.