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 | Session state + context usage |
| /context | Detailed token breakdown |
| /plan | Enter Plan Mode (no changes) |
| /execute | Exit Plan Mode (apply changes) |
| /model | Switch model (sonnet/opus/opusplan) |
| /exit | Quit (or Ctrl+D) |
Keyboard Shortcuts
| Shift+Tab | Cycle permission modes |
| Esc × 2 | Rewind (undo) |
| Ctrl+C | Interrupt |
| Ctrl+R | Retry last operation |
| Ctrl+L | Clear screen (keeps context) |
| 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
Permission Modes
| Mode | Editing | Execution |
|---|---|---|
| Default | Asks | Asks |
| Auto-accept | Auto | Asks |
| Plan Mode | None | None |
Shift+Tab to switch modes
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
└── 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 × 2 | Enter Plan Mode |
| /model opusplan | Opus planning, Sonnet execution |
Thinking Mode (Opus 4.5+)
| Default | Thinking ON at max budget (v2.0.67+) |
| Alt+T | Toggle thinking on/off (session) |
| /config | Configure thinking (permanent) |
Typical Workflow
1. Start session → claude
2. Check context → /status
3. Plan Mode → Shift+Tab × 2
4. Describe task → Clear, specific prompt
5. Review changes → Always read the diff!
6. Accept/Reject → y/n
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 |
| Context7 | Library documentation |
| Sequential | Structured reasoning |
| Playwright | Browser automation |
| Postgres | Database queries |
Check status:
/mcpCLI Flags
| -p "query" | Non-interactive mode |
| -c | Continue last session |
| -r <id> | Resume specific session |
| --model sonnet | Change model |
| --add-dir ../lib | Allow outside CWD |
| --debug | Debug output |
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 → TodoWrite 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