← All Cheatsheets
AI
CLI commands · Slash commands · Memory · Hooks · MCP · Best practices
# Install
npm install -g @anthropic-ai/claude-code
# Launch in project directory
claude
# One-shot command
claude -p "explain this codebase"
# Continue last session
claude --continue
CLAUDE.md (Project)
Place in repo root. Auto-loaded every session. Store architecture decisions, coding standards, common commands.
~/.claude/CLAUDE.md (User)
Global preferences across all projects. Preferred languages, style, tools.
# CLAUDE.md example
## Stack
- TypeScript, Next.js 14, Tailwind
## Commands
- Build: npm run build
- Test: npm test --run
## Standards
- No default exports except pages
| Flag | Short | Description |
|---|---|---|
| -p | Non-interactive: print response and exit | |
| --continue | -c | Resume the most recent conversation |
| --resume <id> | Resume a specific conversation by ID | |
| --model <name> | Specify model (claude-opus-4, sonnet-4, etc.) | |
| --output-format | json | text | stream-json for scripting | |
| --max-turns <n> | Limit agentic loop iterations | |
| --allowedTools | Comma-separated list of permitted tools | |
| --no-tools | Disable all tools (pure chat mode) | |
| --dangerously-skip-permissions | Skip all permission prompts (CI use) |
# Add MCP server
claude mcp add my-server
# List MCP servers
claude mcp list
# Config location
.claude/settings.json
Automate actions triggered by Claude Code events. Defined in .claude/hooks/
# Hook runs npm test after agent stops
{"hooks": {"Stop": [{"type": "command", "command": "npm test"}]}}