Getting Started
Install via npm
Install Claude Code globally using npm
npm install -g @anthropic-ai/claude-code
Install via curl
Alternative installation method using curl
curl -sL https://install.anthropic.com | sh
Update to Latest
Keep Claude Code up to date
claude update
Keyboard Shortcuts
Configuration
📁 Settings File Locations (Priority Order)
/etc/claude-code/managed-settings.json
(highest priority).claude/settings.local.json
(personal, git-ignored).claude/settings.json
(team settings)~/.claude/settings.json
(personal defaults)View all settings
List current configuration
claude config list
Get setting value
Check specific setting
claude config get <key>
Set configuration
Change a setting value
claude config set <key> <value>
Add to list setting
Push to arrays like permissions
claude config add <key> <value>
Remove from list
Remove from array settings
claude config remove <key> <value>
⚙️ Most Useful Settings
Theme Settings
claude config set -g theme dark
Disable Auto-updates
claude config set -g autoUpdates false
Enable Verbose Output
claude config set -g verbose true
Set Default Model
Choose your preferred AI model
claude config set model claude-opus-4-1-20250805
claude config set model claude-sonnet-4-20250514
claude config set model claude-3-5-haiku-20241022
Disable Co-authored By in Git
claude config set includeCoAuthoredBy false
Set Model via Environment
echo 'export ANTHROPIC_MODEL="claude-opus-4-1-20250805"' >> ~/.zshrc
echo 'export ANTHROPIC_MODEL="claude-opus-4-1-20250805"' >> ~/.bashrc
Slash Commands - Interactive Session Control
⚡ Interactive Session Commands
Control Claude's behavior during interactive sessions. Type commands directly in the Claude Code chat interface.
📋 Built-in Commands
/add-dir
Add additional working directories/agents
Manage custom AI subagents for specialized tasks/bug
Report bugs (sends conversation to Anthropic)/clear
Clear conversation history/compact [instructions]
Compact conversation with optional focus instructions/config
View/modify configuration/cost
Show token usage statistics/doctor
Check Claude Code installation health/help
Get usage help/init
Initialize project with CLAUDE.md guide/login
Switch Anthropic accounts/logout
Sign out from your Anthropic account/mcp
Manage MCP server connections and OAuth authentication/memory
Edit CLAUDE.md memory files/model
Select or change the AI model/permissions
View or update permissions/pr_comments
View pull request comments/review
Request code review/status
View account and system statuses/terminal-setup
Install Shift+Enter key binding (iTerm2/VSCode)/vim
Enter vim mode for alternating insert/command modes🎯 Custom Slash Command Templates
Basic Project Command
Create a simple project-specific command
Analyze this code for performance issues and suggest optimizations:
Personal Command
Create a user-wide command available in all projects
Review this code for security vulnerabilities:
Command with Arguments
Use $ARGUMENTS placeholder for dynamic values
Fix issue #$ARGUMENTS following our coding standards
Git Commit Command
Advanced command with bash execution and file references
---
allowed-tools: Bash(git add:*), Bash(git status:*), Bash(git commit:*)
argument-hint: [message]
description: Create a git commit
---
## Context
- Current git status: !`git status`
- Current git diff: !`git diff HEAD`
- Current branch: !`git branch --show-current`
- Recent commits: !`git log --oneline -10`
## Your task
Based on the above changes, create a single git commit.
💡 Usage Tips
.claude/commands/
(shared with team)~/.claude/commands/
(available across all projects)$ARGUMENTS
placeholder for dynamic values!`command`
to run commands before processing@filename
to include file contents/mcp__server__prompt_name
Hooks - Automation & Control
⚠️ Security Warning
Hooks execute shell commands automatically with your credentials. Always review hook code before adding. Malicious hooks can damage your system or exfiltrate data.
Use hooks to automate formatting, logging, notifications, and custom permissions instead of relying on Claude to remember these tasks.
📋 Hook Events
PreToolUse
Runs before tool calls (can block them)PostToolUse
Runs after tool calls completeUserPromptSubmit
Runs when user submits a prompt, before Claude processes itNotification
Runs when Claude Code sends notificationsStop
Runs when Claude Code finishes respondingSubagentStop
Runs when subagent tasks completePreCompact
Runs before compact operationSessionStart
Runs when Claude Code starts/resumes sessionSessionEnd
Runs when Claude Code session ends🛠️ Hook Management Commands
/hooks
Open hooks configuration interfaceclaude --debug
Run with debug output to see hook executionmkdir -p .claude/hooks
Create project hooks directorychmod +x .claude/hooks/script.sh
Make hook script executable🎯 Ready-to-Use Hook Examples
Auto Format Code
Run prettier on edited files
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "npx prettier --write $FILE_PATH"
}
]
}
]
}
}
Log Activity
Keep a log of all Claude sessions
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "echo \"$(date): $CONVERSATION_SUMMARY\" >> ~/.claude/activity.log"
}
]
}
]
}
}
🏗️ Hook Structure & Tips
~/.claude/settings.json
(user) or .claude/settings.json
(project)Bash
, Edit|Write
, *
)$CLAUDE_PROJECT_DIR
for relative paths0
=success, 2
=block & show to Claude, other=errorjq
to parse)claude --debug
to see hook execution detailsMCP Servers & Extensions
🔌 Model Context Protocol (MCP)
Extend Claude Code with external tools and integrations. MCP servers provide additional capabilities like browser automation, database access, and API integrations.
📋 MCP Management Commands
claude mcp add <name> <command> [args...]
Add MCP server with commandclaude mcp add --transport sse <name> <url>
Add SSE transport MCP serverclaude mcp add --transport http <name> <url>
Add HTTP transport MCP serverclaude mcp list
List installed MCP serversclaude mcp remove <name>
Remove MCP server⚡ Popular MCP Integrations
Context7
Documentation library access
claude mcp add --transport http context7 https://mcp.context7.com/mcp
Puppeteer
Browser automation
claude mcp add puppeteer -s user -- npx -y @modelcontextprotocol/server-puppeteer
Playwright
Advanced browser automation
claude mcp add playwright npx @playwright/mcp@latest
Linear
Project/issue management
claude mcp add linear -s user -- npx -y mcp-remote https://mcp.linear.app/sse
Sentry
Error tracking and monitoring
claude mcp add --transport http sentry https://mcp.sentry.dev/mcp
Supabase
Database operations
claude mcp add supabase -s local -e SUPABASE_ACCESS_TOKEN=your_token -- npx -y @supabase/mcp-server-supabase@latest
Digital Ocean
Cloud hosting management
claude mcp add digitalocean-mcp-local -e DIGITALOCEAN_API_TOKEN=YOUR_TOKEN -- npx "@digitalocean/mcp"
Git Worktrees - Parallel Development
🚀 Why Use Git Worktrees with Claude Code?
- No Context Loss: Each Claude session keeps full project understanding
- Parallel Work: Handle hotfixes while continuing feature development
- Safe Experiments: Test risky changes in complete isolation
- Model Comparison: Run different AI models on identical tasks
- Zero Switching Cost: No more git stash, checkout, restart cycle
📋 Essential Worktree Commands
git worktree add <path> <branch>
Create worktree with existing branchgit worktree add <path> -b <branch> <start-point>
Create worktree with new branchgit worktree list
List all worktrees and their branchesgit worktree remove <path>
Remove a worktree directorygit worktree prune
Clean up worktree referencesgit worktree move <worktree> <new-path>
Move worktree to new location💡 Powerful Workflow Examples
Parallel Feature Development
Work on multiple features simultaneously
git worktree add ../myapp-auth -b feature/auth main
git worktree add ../myapp-api -b feature/api main
cd ../myapp-auth && claude
cd ../myapp-api && claude
Hotfix While Developing
Handle urgent fixes without losing context
git worktree add ../myapp-hotfix -b hotfix/critical main
cd ../myapp-hotfix
claude "fix the critical bug"
# Original work continues in main directory
Safe Experiment Testing
Test risky changes in isolation
git worktree add ../myapp-experiment -b experiment/refactor main
cd ../myapp-experiment
claude "refactor the entire auth system"
# If it fails, just delete the directory
Model Comparison
Compare different AI implementations
git worktree add ../ml-sonnet -b experiment/sonnet main
git worktree add ../ml-opus -b experiment/opus main
cd ../ml-sonnet && claude --model sonnet
cd ../ml-opus && claude --model opus
Code Review Preparation
Polish code without affecting main work
git worktree add ../myapp-review -b review/cleanup feature-branch
cd ../myapp-review
claude "add docs, tests, and clean up code style"
git merge review/cleanup
Subagents - Specialized AI Assistants
🤖 Why Use Subagents?
- Context Preservation: Each subagent has separate context from main conversation
- Specialized Expertise: Fine-tuned prompts for specific domains and tasks
- Reusable Workflows: Share subagents across projects and with your team
- Tool Control: Grant specific tool access per subagent for security
- Automatic Delegation: Claude proactively uses appropriate subagents
📁 Subagent Locations
.claude/agents/
(highest priority, team shared)~/.claude/agents/
(personal, all projects)📋 Essential Subagent Commands
/agents
Open subagents management interfaceclaude "Use the [name] subagent to..."
Explicitly invoke a specific subagentmkdir -p .claude/agents
Create project subagents directorymkdir -p ~/.claude/agents
Create user subagents directory🎯 Ready-to-Use Subagent Templates
Code Reviewer
Expert code review after writing/modifying code
---
name: code-reviewer
description: Expert code review specialist. Proactively reviews code for quality, security, and maintainability. Use immediately after writing or modifying code.
tools: Read, Grep, Glob, Bash
---
You are a senior code reviewer ensuring high standards of code quality and security.
When invoked:
1. Run git diff to see recent changes
2. Focus on modified files
3. Begin review immediately
Review checklist:
- Code is simple and readable
- Functions and variables are well-named
- No duplicated code
- Proper error handling
- No exposed secrets or API keys
- Input validation implemented
- Good test coverage
- Performance considerations addressed
Provide feedback organized by priority:
- Critical issues (must fix)
- Warnings (should fix)
- Suggestions (consider improving)
Include specific examples of how to fix issues.
Debugger
Debugging specialist for errors and test failures
---
name: debugger
description: Debugging specialist for errors, test failures, and unexpected behavior. Use proactively when encountering any issues.
tools: Read, Edit, Bash, Grep, Glob
---
You are an expert debugger specializing in root cause analysis.
When invoked:
1. Capture error message and stack trace
2. Identify reproduction steps
3. Isolate the failure location
4. Implement minimal fix
5. Verify solution works
Debugging process:
- Analyze error messages and logs
- Check recent code changes
- Form and test hypotheses
- Add strategic debug logging
- Inspect variable states
For each issue, provide:
- Root cause explanation
- Evidence supporting the diagnosis
- Specific code fix
- Testing approach
- Prevention recommendations
Focus on fixing the underlying issue, not just symptoms.
💡 Usage Tips
"Use the code-reviewer subagent to check my code"
"Use debugger then optimizer subagents"
📝 Subagent File Format
---
name: your-subagent-name
description: When this subagent should be invoked
tools: Read, Edit, Bash # Optional - inherits all if omitted
---
Your subagent's system prompt goes here.
Include specific instructions, examples, and constraints.
Define the subagent's role, capabilities, and approach
to solving problems within its domain.
Permissions & Security
🔒 Ready-to-Use Permission Templates
Copy complete settings.json configurations for different security levels. Save to .claude/settings.json
in your project.
Basic Security
Block sensitive files, allow common dev commands
{
"permissions": {
"allow": [
"Bash(npm run *)",
"Bash(git status)",
"Bash(git diff)",
"Bash(git add *)",
"Bash(git commit *)"
],
"ask": [
"Bash(git push:*)",
"Bash(npm install *)"
],
"deny": [
"Read(./.env*)",
"Read(./secrets/**)",
"Read(./**/credentials*)",
"Bash(rm -rf:*)",
"Bash(curl:*)"
]
}
}
Strict Security
Maximum security for sensitive projects
{
"permissions": {
"ask": [
"Bash(*)",
"Write(*)",
"Edit(*)"
],
"deny": [
"Read(./.env*)",
"Read(./secrets/**)",
"Read(./config/**)",
"Read(./**/credentials*)",
"Read(./**/*.key)",
"Read(./**/*.pem)",
"WebFetch",
"Bash(curl:*)",
"Bash(wget:*)",
"Bash(ssh:*)"
]
}
}
Printable Cheatsheet

Printable Version
Special version for printing or keeping as a desktop reference. Contains all essential keyboard shortcuts, commands, configurations, and file locations in a compact format.