How to install Claude Code
npm install -g @anthropic-ai/claude-code
Requires Node.js 18+
| Verify install | which claude |
| Start session | claude |
| Health check | claude doctor |
Essential commands
| /help | Contextual help |
| /clear | Reset conversation |
| /compact | Free up context |
| /status | Status tab: version, model, account, connectivity |
| /context | Detailed token breakdown |
| /plan | Enter Plan Mode (no changes). Exit by approving the plan or Shift+Tab |
| /code-review [level] | Review the diff for correctness bugs. --fix applies them |
| /model | Choose a model; Enter saves, s applies once |
| /insights | Usage analytics + optimization |
| /teleport | Teleport session from web |
| /tasks | Monitor background tasks |
| /fast | Opus 5.5 fast: $8/$40 per MTok input/output |
| btw [question] | Side question overlay. Read-only ephemeral agent, no history pollution, no tools. |
| /loop [interval] [prompt] | Recurring scheduler. /loop 5m check the deploy (self-paced without an interval) |
| /usage | Usage graph, favorite model, streak (v2.1.118) |
| /stats | Usage graph, favorite model, streak (alias for /usage) |
| /cost | Session cost summary (alias for /usage) |
| /rename [name] | Name or rename current session |
| /copy | Interactive picker to copy a code block or full response |
| /debug | Enable debug logging and troubleshoot from the session log (bundled skill) |
| /remote-env | Configure cloud environment |
| /simplify | Review cleanup opportunities and apply fixes; use /code-review for bugs |
| /output-style | Default, Proactive, Concise, Explanatory, Learning, or custom |
| /autocompact | Save the compaction window; auto restores the model default |
| /batch | Large-scale refactors via 5β30 parallel worktree agents |
| /exit | Quit (or Ctrl+D) |
Keyboard shortcuts
| Shift+Tab | Cycle permission modes |
| Esc x 2 | Rewind (undo) |
| Ctrl+C | Interrupt |
| Ctrl+R | Search command history |
| Ctrl+L | Clear screen (keeps context) |
| Ctrl+B | Background tasks |
| Ctrl+X Ctrl+K | Stop background subagents |
| Alt+T | Toggle thinking where supported; no effect on Opus 5.5/Fable |
| Tab | Autocomplete |
| Shift+Enter | New line |
| Ctrl+D | Exit |
IDE shortcuts
| VS Code | Alt+K |
| JetBrains | Cmd+Option+K |
File references
@path/to/file.ts → Reference a file
@agent-name → Call an agent
!shell-command → Run shell command
Hidden but official features
| Feature | Since | What It Does |
| Tasks API | v2.1.16 | Task lists with dependencies; newer models opt in with CLAUDE_CODE_ENABLE_TODO_TOOLS=1 |
| Background Agents | v2.0.60 | Sub-agents work while you code |
| Agent Teams | v2.1.32 | Multi-agent coordination (TeamCreate/SendMessage) |
| Auto-Memories | v2.1.32 | Automatic cross-session context capture |
| Session Forking | v2.1.19 | Rewind + create parallel timeline |
| LSP Tool | v2.0.74 | Code intelligence (go-to-def, refs) |
| /code-review | v2.1.146 | Code review with optional effort level (e.g. /code-review high). /review is an alias; /simplify handles cleanup separately. |
| /batch | v2.1.63 | Spawns 5β30 agents in isolated worktrees, each opens a PR |
| /loop | v2.1.71 | Recurring scheduler: run any prompt or command on an interval (5m, 10m...) while you work |
| /usage | v2.1.118 | Usage graph, cost breakdown, favorite model, streak (replaces /cost and /stats) |
| /recap | v2.1.x | Session recap: structured summary of what was done |
| /undo | v2.1.x | Undo last change (file-level undo) |
| /tui | v2.1.x | Terminal UI mode: structured interface for session navigation |
| /focus | v2.1.x | Toggle the compact focus view in fullscreen mode |
| /ultrareview | v2.1.x | Cloud multi-agent code review; alias for /code-review ultra |
| Routines | v2.1.x (Apr 14) | Cloud automation: schedule recurring agents to run without local session |
Pro tip: These aren't "secrets." They're in the
CHANGELOG. Read it!
Permission modes
| Mode | Editing | Execution |
| Manual (default) | Permission rules | Permission rules |
| Auto-accept | Auto | Asks |
| Plan Mode | No file changes | Read-only tools |
Memory & settings
| Level | Path | Scope |
| Project | .claude/ | Team (git) |
| Personal | ~/.claude/ | You only |
.claude/ structure
.claude/
βββ CLAUDE.md # Local memory
βββ settings.json # Hooks (committed)
βββ settings.local.json # Permissions
βββ agents/ # Custom agents
βββ commands/ # Slash commands
βββ hooks/ # Event scripts
βββ rules/ # Auto-loaded rules
βββ skills/ # Knowledge modules
Context management
Work freely
Be selective
/compact NOW
/clear required
Model: Sonnet | Ctx: 89.5k | Ctx(u): 56.0%
Watch Ctx(u): >70% = /compact, >85% = /clear
| Sign | Action |
| Short responses | /compact |
| Frequent forgetting | /clear |
| >70% context | /compact |
| Task complete | /clear |
Plan mode & thinking
| Shift+Tab x 2 | Enter Plan Mode |
| /model opusplan | Opus planning, Sonnet execution |
Current models and effort
| Model | Input/output per MTok | Default effort |
| Opus 5.5 | $4 / $20 | medium |
| Sonnet 5.5 | $2 / $10 | medium |
| Haiku 5.5 | $0.10 / $0.50 (prompts up to 100K tokens) | medium |
| Fable 5.1 | $10 / $50 | high |
Standard direct-API rates verified October 27, 2026; Haiku 5.5 costs $0.50 / $2.50 above 100K-token prompts. Provider aliases differ. Opus 5.5 is the direct-service default; organization settings can override it.
/effort saves levels through xhigh per model. Press s for this session only; max is session-only. Opus 5.5, Sonnet 5.5, Haiku 5.5 and Fable always use thinking. The ultrathink keyword adds guidance without changing API effort.
Full model and provider reference
Typical workflow
1. Start session → claude
2. Check context → /status
3. Plan Mode → Shift+Tab x 2
4. Describe task → Clear, specific prompt
5. Review changes → Always read the diff!
6. Accept/Reject → Enter/Esc
7. Verify → Run tests
8. Commit → When task complete
9. /compact → When context >70%
Prompting formula
WHAT: [Concrete deliverable]
WHERE: [File paths]
HOW: [Constraints, approach]
VERIFY: [Success criteria]
Example
Add input validation to the login form.
WHERE: src/components/LoginForm.tsx
HOW: Use Zod schema, show inline errors
VERIFY: Empty email shows error
Model Context Protocol (MCP) servers
MCP extends Claude Code with external tools and data sources
| Serena | Indexation + session memory |
| grepai | Semantic search + call graph |
| Context7 | Library documentation |
| Sequential | Structured reasoning |
| Playwright | Browser automation |
| Postgres | Database queries |
| doobidoo | Semantic memory + Knowledge Graph |
Check status: /mcp
CLI flags
| -p "query" | Non-interactive mode |
| -c | Continue last session |
| -r <id> | Resume specific session |
| --model sonnet | Change model |
| --teleport | Teleport session from web |
| --add-dir ../lib | Allow outside CWD |
| --allowedTools | Pre-approve tools; --tools restricts availability |
| --debug | Debug output |
| --debug='mcp' | Debug MCP servers |
| --from-pr | Load context from PR (GitLab/Bitbucket/GHE, v2.1.119) |
| --print | Print output then exit (non-interactive, v2.1.119) |
Search the full reference in a real terminal β
Anti-patterns
Vague prompts
Specify file + line with @
Accept without reading
Read every diff
Ignore warnings
Use /compact at 70%
Skip permissions
Never in production
Cost optimization
| Model | Use For | Cost |
| Haiku | Simple fixes, reviews | $ |
| Sonnet | Most development | $$ |
| Opus | Architecture, complex bugs | $$$ |
| OpusPlan | Plan + Execute | $$ |
Quick decision tree
Simple task → Just ask Claude
Complex task → Tasks API to plan first
Risky change → Plan Mode first
Repeating task → Create agent/command
Context full → /compact or /clear
Need docs → Use Context7 MCP
Deep analysis → Use Opus (thinking on by default)
The golden rules
- Always review diffs before accepting
- Use /compact before context >70%
- Be specific (WHAT, WHERE, HOW, VERIFY)
- Plan Mode first for complex/risky tasks
- Create CLAUDE.md for every project
- Commit frequently after each task
- Know what's sent to Anthropic
Quick fixes
| Command not found | Check PATH, reinstall |
| Context >70% | /compact immediately |
| Slow responses | /compact or /clear |
| MCP not working | claude mcp list |
| Permission denied | settings.local.json |
Health check
which claude && claude doctor && claude mcp list