Some links in this article are affiliate links. We earn a commission at no extra cost to you when you purchase through them. Full disclosure.
Quick reference for Claude Code β Anthropicβs terminal AI coding agent.
Install & setup
# Install
npm install -g @anthropic-ai/claude-code
# Start in your project
cd your-project
claude
# With a specific prompt
claude "Explain this codebase"
Slash commands
| Command | What it does |
|---|---|
/help | Show all commands |
/compact [focus] | Summarize context, keep going. Add focus: /compact focus on auth refactor |
/clear | Clear all context, start fresh |
/rewind | Go back to a previous message (also: double-tap Esc) |
/model | Switch model (Sonnet, Opus, Haiku) |
/cost | Show token usage and cost for this session |
/tokens | Show current context size |
/config | Open settings |
/permissions | View/edit permission settings |
/bug | Report a bug to Anthropic |
/ultrareview | π Dedicated review session β reads changes, flags bugs and design issues a careful reviewer would catch. Pro/Max get 3 free. |
/quit | Exit (also: Ctrl+C twice) |
Keyboard shortcuts
| Shortcut | Action |
|---|---|
Esc Esc (double-tap) | Rewind to previous message |
Ctrl+C | Cancel current generation |
Ctrl+C Ctrl+C | Exit Claude Code |
Tab | Accept suggestion |
Enter | Send message |
Shift+Enter | New line in message |
Context management
# Check how much context you're using
/tokens
# Summarize and compress (best before context gets too long)
/compact
# Summarize with focus
/compact Focus on the database migration. Drop the CSS debugging.
# Nuclear option: start fresh with a handoff note
/clear
# Then paste: "We're refactoring auth. Files: src/auth/. Approach: JWT. Ruled out: OAuth2."
When to use each:
/rewindβ undo a bad attempt, try a different approach/compactβ session getting long, keep working on same task/clearβ switching to a completely different task
See our long-running agents guide for advanced context strategies.
Permission settings
// .claude/settings.json
{
"permissions": {
"allow": ["read_file", "list_directory", "search_files"],
"ask": ["write_file", "shell_command"],
"deny": ["delete_file"]
}
}
| Level | Behavior |
|---|---|
allow | Auto-approved, no prompt |
ask | Claude asks before each action |
deny | Blocked, Claude canβt do it |
Fix permission issues: Claude Code Permission Denied Fix
Subagents
# Tell Claude to use a subagent for isolated work
"Spin up a subagent to analyze the test coverage"
"Use a subagent to read the API docs and summarize the auth endpoints"
Subagents get their own context window. Only the result comes back. Use for: research tasks, file analysis, anything where you need the conclusion but not the intermediate steps.
Routines (cloud automation)
Set up at claude.ai/code/routines:
| Trigger | Example |
|---|---|
| Schedule | βEvery weekday at 9am: review new PRsβ |
| API call | POST to trigger post-deployment checks |
| GitHub event | On PR opened: automated code review |
See our Claude Code Routines guide for setup.
Model selection
| Model | Best for | Speed | Cost |
|---|---|---|---|
| Sonnet | Daily coding (default on free) | Fast | $$ |
| Opus 4.8 | Complex architecture, hard bugs, agentic tasks, dynamic workflows | Slow | $$$$ |
| Haiku | Quick questions, formatting | Fastest | $ |
/model sonnet # Switch to Sonnet
/model opus # Switch to Opus for hard problems
/model haiku # Switch to Haiku for quick tasks
Effort levels π
Opus 4.8 supports effort levels from low to max, with high as the default. Use ultracode to enable dynamic workflows (hundreds of parallel subagents for codebase-scale tasks).
| Level | When to use | Token usage |
|---|---|---|
low | Simple questions, formatting | Minimal |
medium | Standard coding tasks | Moderate |
high | Complex multi-file changes | High |
xhigh | Hard bugs, architecture decisions (default) | High |
max | Absolute best result, latency doesnβt matter | Very high |
Set effort via the API effort parameter or let Claude Code manage it automatically.
Use with other models via API
# Use GLM-5.1 through Z.ai
export ANTHROPIC_BASE_URL="https://api.z.ai/api/anthropic"
export ANTHROPIC_AUTH_TOKEN="your-zai-key"
claude
See our GLM-5.1 + Claude Code setup guide.
Common patterns
# Code review
claude "Review src/auth/ for security issues"
# Refactoring
claude "Refactor the payment module to use the strategy pattern"
# Debugging
claude "The tests in src/auth/__tests__/ are failing. Fix them."
# Documentation
claude "Add JSDoc comments to all exported functions in src/lib/"
# Git workflow
claude "Create a PR description for the changes in this branch"
Pricing
| Plan | Price | Includes |
|---|---|---|
| Pro | $20/mo | Sonnet + Haiku, generous limits |
| Max | $100/mo | Opus + Sonnet + Haiku, 5x limits |
| API | Pay-per-token | Full control, no subscription |
Speed up your workflow β Raycast lets you trigger Claude Code from a keyboard shortcut.
Related: How to Use Claude Code Β· Claude Code Routines Guide Β· Claude Code Desktop App Β· What Is Claude Dispatch? Β· What Is Claude Cowork? Β· Claude Code vs Codex CLI vs Gemini CLI Β· GLM-5.1 + Claude Code Setup Β· Claude Code Permission Denied Fix