The complete reference for Claude Code, Anthropic's agentic coding CLI. Every command, keyboard shortcut, CLI flag, configuration option, and workflow pattern in one place. Tested and verified on Claude Code's latest release.
Full article with screenshots and extended examples: computingforgeeks.com/claude-code-cheat-sheet
- Installation
- Keyboard Shortcuts
- Slash Commands
- CLI Flags
- CLAUDE.md - Project Instructions
- Permission Modes
- Models and Effort Levels
- MCP Servers
- Custom Skills
- Custom Subagents
- Hooks - Automation Triggers
- Context Window Management
- Git Worktrees
- Settings File Reference
- Environment Variables
- File Structure Reference
- Practical Workflow Tips
- Prompting Tips
- Token Saving Strategies
- Diagnostics
- IDE Integrations
- Auto Mode
- Automation Scripts
- Quick Reference Card
- Subcommands Reference
Install Claude Code on macOS, Linux, or Windows (WSL):
curl -fsSL https://claude.ai/install.sh | bashOn macOS via Homebrew:
brew install --cask claude-codeOn Windows (PowerShell):
irm https://claude.ai/install.ps1 | iexVerify and authenticate:
claude --version
claude auth loginThese work inside the interactive Claude Code terminal.
| Shortcut | Action |
|---|---|
Ctrl+C |
Cancel current generation or input |
Ctrl+D |
Exit Claude Code |
Ctrl+L |
Clear terminal screen |
Ctrl+R |
Reverse search command history |
Esc + Esc |
Rewind to previous checkpoint (undo) |
Shift+Tab |
Cycle permission modes (default/plan/auto) |
Ctrl+G |
Open input in external editor (vim, etc.) |
Ctrl+O |
Toggle verbose output |
Ctrl+T |
Toggle task list |
Ctrl+F |
Kill all background agents (press twice) |
| Shortcut | Action |
|---|---|
\ + Enter |
New line (multiline input) - works on macOS, Linux, and Windows |
Option+Enter (Mac) / Alt+Enter (Linux/Win) |
New line (platform default) |
Shift+Enter |
New line (iTerm2, WezTerm, Ghostty, Kitty, Windows Terminal) |
Ctrl+K |
Delete to end of line |
Ctrl+U |
Delete entire line |
Ctrl+Y |
Paste deleted text |
Alt+B / Alt+F |
Move cursor back/forward one word |
Cmd+V (Mac) / Ctrl+V (Linux/Win) |
Paste image from clipboard |
Up/Down |
Navigate command history |
| Shortcut | Action |
|---|---|
Option+P (Mac) / Alt+P (Linux/Win) |
Switch model (Sonnet/Opus/Haiku) |
Option+T (Mac) / Alt+T (Linux/Win) |
Toggle extended thinking |
Shift+Tab / Alt+M |
Cycle permission mode |
? |
Show all available shortcuts |
| Prefix | Action |
|---|---|
/ |
Open slash command menu |
! |
Run bash command directly |
@ |
Autocomplete file path mention |
| Command | What It Does |
|---|---|
/clear |
Wipe conversation history and free context window |
/compact [focus] |
Summarize conversation to free context, optionally focus on specific topic |
/cost |
Show token usage and API cost for current session |
/context |
Visualize what is consuming your context window |
/resume |
Pick and resume a previous session |
/rename [name] |
Name current session for easy resuming later |
/rewind |
Rewind to a previous checkpoint |
/diff |
View interactive diff of all changes made |
/copy |
Copy last response to clipboard |
/export [file] |
Export conversation as text file |
| Command | What It Does |
|---|---|
/model [name] |
Switch model (sonnet, opus, haiku) |
/effort [level] |
Set reasoning effort (low, medium, high, max) |
/config |
Open settings interface |
/permissions |
View and manage tool permissions |
/mcp |
Manage MCP server connections |
/terminal-setup |
Configure terminal keybindings for your shell |
/theme |
Change color theme |
/vim |
Toggle vim keybinding mode |
| Command | What It Does |
|---|---|
/init |
Initialize project, generates CLAUDE.md with project context |
/memory |
View and edit CLAUDE.md files and auto-memory |
/security-review |
Scan pending changes for security vulnerabilities |
/simplify |
Review changed code for quality issues and suggest improvements |
/pr-comments [PR] |
Fetch and address GitHub PR review comments |
/add-dir [path] |
Add another directory to the working context |
/plan |
Enter plan mode, read-only exploration before making changes |
/batch [task] |
Run large-scale changes across 5-30 parallel git worktrees |
/debug [description] |
Troubleshoot problems in the current session |
| Command | What It Does |
|---|---|
/help |
Show all available commands |
/doctor |
Diagnose installation, settings, auth, and MCP issues |
/insights |
Generate session analysis report |
/status |
Show version, model, and account info |
/login / /logout |
Sign in or out |
/bug |
Submit a bug report with session logs |
/stats |
View usage patterns, daily streaks, and session history |
/usage |
Show plan usage and rate limits |
/release-notes |
View changelog for current version |
/loop [interval] [prompt] |
Run a prompt or command on a recurring schedule |
/voice |
Toggle push-to-talk voice dictation (hold Space) |
/schedule |
Create, update, list, or run scheduled remote agents (cron tasks) |
/fast |
Toggle fast mode (same model, faster output) |
/hooks |
View and manage configured hooks |
/desktop |
Hand off current session to the Desktop app |
/teleport |
Pull a web/iOS session into your terminal |
# Start interactive session
claude
# Start with initial prompt
claude "refactor the auth module"
# Continue most recent session
claude -c
# Resume specific session by name
claude -r "auth-refactor"
# Name a session for later
claude -n "feature-payments"
# Run in isolated git worktree
claude -w feature-branch
# Run in worktree with tmux panes
claude -w feature-branch --tmux
# Resume session linked to a GitHub PR
claude --from-pr 42
# Fork a session (new ID, keeps context)
claude -c --fork-session
# Enable auto mode (AI decides permissions)
claude --permission-mode auto
# Bare mode (skip hooks, plugins, auto-memory)
claude --bareThe -p flag runs Claude Code non-interactively. It processes the prompt and exits. This is the key to integrating Claude Code into scripts, CI/CD pipelines, and Unix pipes:
# Simple query
claude -p "explain this error in server.log"
# Pipe input
cat error.log | claude -p "what caused this crash?"
# Git diff review
git diff main | claude -p "review for security issues"
# JSON output for scripting
claude -p "list all TODO comments" --output-format json
# Structured output with schema validation
claude -p "extract function names from auth.py" \
--output-format json \
--json-schema '{"type":"object","properties":{"functions":{"type":"array","items":{"type":"string"}}}}'
# Auto-approve tools (careful with this)
claude -p "run tests and fix failures" --allowedTools "Bash,Read,Edit"
# Set spending limit
claude -p "refactor the API layer" --max-budget-usd 5.00
# Limit turns
claude -p "fix the bug" --max-turns 3
# Fallback model when primary is overloaded
claude -p "review this code" --fallback-model haiku
# Restrict available tools
claude -p "analyze this" --tools "Read,Grep,Glob"
# Block specific tools (deny list)
claude -p "refactor auth module" --disallowedTools "Bash(rm:*),Bash(sudo:*)"
# Override system prompt entirely
claude -p "review this code" --system-prompt "You are a security auditor. Focus only on vulnerabilities."
# Append to default system prompt
claude -p "explain this function" --append-system-prompt "Always include time complexity analysis."
# Load MCP servers from external config file
claude -p "check open issues" --mcp-config ./ci-mcp.json
# Disable session persistence (ephemeral, for CI/CD)
claude -p "run lint check" --no-session-persistence
# Debug mode (logs API calls, tool usage, timings)
claude -p "fix the build" --debug
# Debug with category filter
claude -p "fix the build" --debug "api,hooks"
# Write debug output to a file
claude -p "fix the build" --debug-file /tmp/claude-debug.log
# Select a specific agent
claude -p "review auth.py" --agent code-reviewer
# Enable Chrome debugging integration
claude --chrome# Use specific model
claude --model opus
claude --model sonnet
claude --model haiku
# Set reasoning effort
claude --effort high # More thorough (costs more)
claude --effort low # Faster, cheaper
# Custom system prompt
claude --append-system-prompt "Always use TypeScript. Never use any."
# Load system prompt from file
claude --append-system-prompt-file ./coding-rules.txtCLAUDE.md is the single most important file for customizing Claude Code behavior on a per-project basis. It loads automatically at the start of every session.
| Location | Scope | Shared with Team? |
|---|---|---|
./CLAUDE.md |
This project only | Yes (commit to git) |
./.claude/CLAUDE.md |
This project only | Yes (commit to git) |
~/.claude/CLAUDE.md |
All your projects | No (personal) |
.claude/rules/*.md |
Path-specific rules | Yes (commit to git) |
# My Project
## Build and Test
- Run tests: `npm test`
- Build: `npm run build`
- Lint: `npm run lint`
## Code Style
- Use TypeScript strict mode
- Prefer functional components in React
- All API responses must include error handling
- Never commit .env files
## Architecture
- Backend: Express.js + PostgreSQL
- Frontend: React + TailwindCSS
- Auth: JWT tokens stored in httpOnly cookies
See @README.md for project overview.
See @package.json for available scripts.The @filename syntax imports content from other files. Claude reads them automatically.
Rules that only apply to certain files. Create .claude/rules/api.md:
---
paths:
- "src/api/**/*.ts"
---
# API Rules
- All endpoints must validate input with Zod
- Return proper HTTP status codes
- Include rate limiting on public endpointsGenerate a CLAUDE.md automatically for any project with /init.
Claude Code asks permission before running commands or editing files. Toggle between modes with Shift+Tab:
| Mode | Behavior | Use Case |
|---|---|---|
| default | Prompts on first use of each tool | Normal interactive work |
| plan | Read-only, no edits, no commands | Safe exploration and planning |
| acceptEdits | Auto-approves file edits, prompts for commands | Trusted editing sessions |
| dontAsk | Auto-denies unless pre-approved | Strict control |
| auto | AI classifier decides allow/deny per tool call | Trusted projects with clear CLAUDE.md rules |
| bypassPermissions | Skips all prompts (dangerous) | Containers/sandboxes only |
Via the CLI:
# Allow git commands and file reads without prompting
claude --allowedTools "Read,Bash(git *)"
# Block dangerous tools explicitly
claude --disallowedTools "Bash(rm:*),Bash(sudo:*),Bash(chmod:*)"
# Combine both: allow some, block others
claude --allowedTools "Bash(git:*),Read,Edit" --disallowedTools "Bash(rm -rf:*)"Or in .claude/settings.json:
{
"permissions": {
"allow": [
"Read",
"Bash(git *)",
"Bash(npm run *)",
"Bash(docker compose *)"
],
"deny": [
"Bash(rm -rf *)"
]
}
}| Model | Best For | Speed |
|---|---|---|
| sonnet (Claude Sonnet 4.6) | Daily coding, edits, refactors, tests | Fast |
| opus (Claude Opus 4.6) | Complex architecture, debugging, multi-file changes | Slower |
| haiku (Claude Haiku 4.5) | Simple tasks, quick questions | Fastest |
Switch models mid-session with /model opus or Option+P (Mac) / Alt+P (Linux/Windows).
Effort levels control how much reasoning Claude applies:
| Level | Use Case |
|---|---|
/effort low |
Simple questions, quick lookups |
/effort medium |
Default, balanced speed and quality |
/effort high |
Complex debugging, architecture decisions |
/effort max |
Hardest problems (Opus only, unlimited thinking budget) |
MCP (Model Context Protocol) lets Claude Code connect to external tools and data sources. Configure servers in .mcp.json at the project root or ~/.claude/.mcp.json for all projects.
Example configuration with GitHub and PostgreSQL servers:
{
"mcpServers": {
"github": {
"type": "stdio",
"command": "npx",
"args": ["@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "$GITHUB_TOKEN"
}
},
"postgres": {
"type": "stdio",
"command": "npx",
"args": ["@modelcontextprotocol/server-postgres"],
"env": {
"DATABASE_URL": "postgresql://user:pass@localhost:5432/mydb"
}
}
}
}Manage MCP connections with /mcp in the interactive session or pass a config file on the CLI:
# Load MCP servers from an external config
claude --mcp-config ./team-mcp.json
# Load multiple configs
claude --mcp-config ./github-mcp.json ./db-mcp.json
# Ignore all other MCP sources, only use this config
claude --mcp-config ./ci-mcp.json --strict-mcp-configThe --mcp-config flag is useful in CI/CD where you need consistent MCP server configuration across runs. --strict-mcp-config ensures only the specified servers are loaded, ignoring any from .mcp.json or user settings.
Skills are reusable prompts that show up as slash commands. Create them at .claude/skills/ (project) or ~/.claude/skills/ (personal).
Example: create a deploy skill:
mkdir -p .claude/skills/deployCreate .claude/skills/deploy/SKILL.md:
---
name: deploy
description: Deploy the application to production
argument-hint: "[environment]"
user-invocable: true
---
Deploy the application to the $0 environment (default: staging).
Steps:
1. Run the test suite
2. Build the production bundle
3. Deploy using the deploy script
4. Verify the deployment health checkNow use it: /deploy production
Subagents are specialized AI agents that Claude can delegate tasks to. Create them at .claude/agents/:
mkdir -p .claude/agents/code-reviewerCreate .claude/agents/code-reviewer/AGENT.md:
---
name: code-reviewer
description: Expert code reviewer. Use proactively after code changes.
tools: Read, Grep, Glob, Bash
model: sonnet
---
You are a senior code reviewer. When reviewing code:
- Check for security vulnerabilities (SQL injection, XSS, etc.)
- Verify error handling is complete
- Flag any hardcoded secrets or credentials
- Suggest performance improvements
- Check for proper input validationClaude automatically delegates code review tasks to this agent, or invoke it directly with @code-reviewer check my latest changes.
From the CLI, select an agent for the entire session:
# Use a named agent from .claude/agents/
claude --agent code-reviewer
# In print mode (CI/CD)
claude -p "review the latest commit" --agent code-reviewer
# Define agents inline (no files needed)
claude --agents '{"qa": {"description": "QA tester", "prompt": "You are a QA engineer. Write test cases for every change."}}'Hooks run shell commands automatically in response to Claude Code events. Configure in .claude/settings.json:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "npx prettier --write $(jq -r '.tool_input.file_path')"
}
]
}
],
"Notification": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"Claude needs input\" with title \"Claude Code\"'"
}
]
}
]
}
}Common hook events: SessionStart, PreToolUse, PostToolUse, Stop, Notification, UserPromptSubmit.
Claude Code has a finite context window. Managing it well is the difference between a productive session and hitting walls.
| Command | When to Use |
|---|---|
/compact |
Summarize conversation to free space mid-task |
/compact Focus on auth module |
Summarize but keep specific context intact |
/clear |
Complete reset between unrelated tasks |
/context |
See what is consuming your context |
- Use
/clearbetween unrelated tasks. Do not carry old context into new work - Run
/compactproactively when you notice slowdowns - Use subagents for verbose operations (test runs, log analysis). Their output stays in the subagent context
- Move detailed instructions to skills instead of typing them every time
- Keep CLAUDE.md under 200 lines. Move details to separate files and import with
@filename
Work on multiple tasks simultaneously without branch switching conflicts:
# Start Claude in a new worktree
claude -w feature-auth
# Batch changes across many files in parallel
/batch migrate all components from class-based to functionalThe -w flag creates an isolated git worktree. Changes happen in the worktree without affecting your main working directory. When the agent finishes, merge the worktree branch back.
| File | Scope |
|---|---|
.claude/settings.json |
Project (shared via git) |
.claude/settings.local.json |
Project (gitignored, personal) |
~/.claude/settings.json |
All projects (personal) |
Common settings:
{
"model": "sonnet",
"effortLevel": "medium",
"defaultMode": "default",
"autoMemoryEnabled": true,
"permissions": {
"allow": ["Read", "Bash(git *)"],
"deny": ["Bash(rm -rf *)"]
}
}| Variable | Purpose |
|---|---|
ANTHROPIC_MODEL |
Default model (e.g., opus) |
ANTHROPIC_API_KEY |
API key for direct API access |
CLAUDE_CODE_EFFORT_LEVEL |
Default effort (low/medium/high/max) |
CLAUDE_CODE_DISABLE_AUTO_MEMORY |
Set to 1 to disable auto-memory |
CLAUDE_CODE_DISABLE_1M_CONTEXT |
Set to 1 to disable 1M token context |
MAX_THINKING_TOKENS |
Custom thinking budget (default varies) |
HTTPS_PROXY |
HTTP proxy for corporate networks |
# User-level (personal, all projects)
~/.claude/
settings.json # Global settings
keybindings.json # Custom keyboard shortcuts
CLAUDE.md # Personal instructions
rules/ # Personal rules
agents/ # Personal subagents
skills/ # Personal skills
.mcp.json # Global MCP servers
# Project-level (shared with team)
.claude/
settings.json # Project settings (git tracked)
settings.local.json # Local overrides (gitignored)
CLAUDE.md # Project instructions
rules/ # Path-specific rules
agents/ # Project subagents
skills/ # Project skills
.mcp.json # Project MCP servers
CLAUDE.md # Project instructions (alternative location)
# In your project root
claude
/initThis scans your project and generates a CLAUDE.md with build commands, test instructions, and code conventions. Review and edit it. This file shapes every future interaction.
Press Shift+Tab to enter plan mode before asking Claude to make changes. In plan mode, Claude reads and analyzes but cannot edit anything. Once you approve the plan, switch back to default mode and say "implement the plan".
Press Esc + Esc to open the rewind menu. Choose "Restore code and conversation" to undo both the code changes and the conversation that led to them. Faster than git stash for quick experiments.
# Analyze logs
tail -500 /var/log/app.log | claude -p "find the root cause of errors"
# Review a PR
gh pr diff 42 | claude -p "security review this PR"
# Generate commit message
git diff --staged | claude -p "write a conventional commit message" --model haiku
# Translate
cat README.md | claude -p "translate to Japanese" > README.ja.md
# Docker container analysis
docker ps --format json | claude -p "which containers are using the most resources?"
# Kubernetes pod debugging
kubectl logs deployment/api --tail=200 | claude -p "why are requests failing?"
# Database structure review
pg_dump --schema-only mydb | claude -p "suggest index improvements"
# Summarize recent commits
git log --oneline -20 | claude -p "write release notes from these commits"
# Find config issues
cat /etc/nginx/nginx.conf | claude -p "check for misconfigurations"Need to ask something without derailing the current task? Use /btw:
/btw what was the name of that config file we edited earlier?
The response is ephemeral (not saved to context), low-cost (uses cache), and does not use any tools.
- Use
/costto check spend at any time - Use Sonnet for most work, Opus only for complex problems
- Use
/effort lowfor simple tasks - Run
/compactto reduce context size (fewer tokens per request) - Be specific in prompts. Vague requests cause more back-and-forth
- Use
--max-budget-usd 5.00in CI/CD to prevent runaway costs
The quality of Claude Code's output depends heavily on how you prompt it. These patterns consistently produce better results.
| Bad Prompt | Good Prompt |
|---|---|
| "fix the bug" | "the login endpoint returns 500 when email contains a plus sign, fix the input validation in src/auth/login.ts" |
| "make it faster" | "the /api/users endpoint takes 3s on 10k rows, add database indexing and pagination" |
| "write tests" | "write unit tests for the calculateDiscount function in src/pricing.ts covering edge cases: zero price, negative quantity, expired coupon" |
| "clean up the code" | "extract the duplicate validation logic in src/api/orders.ts and src/api/returns.ts into a shared validator" |
For complex tasks, switch to plan mode (Shift+Tab) and ask Claude to explore before coding:
# In plan mode:
"I need to add OAuth2 login with Google. Look at the existing auth flow
in src/auth/ and propose where to add the Google provider without
breaking the current email/password login."
Review the plan, then switch back to default mode and say "implement the plan".
Tell Claude how to verify its own work:
"Add rate limiting to the /api/auth endpoints. After implementing,
run npm test to make sure nothing breaks, and verify the rate limiter
works by checking the middleware is registered in the Express app."
Point Claude at specific files instead of making it search:
"look at @src/db/schema.ts and @src/api/users.ts - the User model
has a new 'role' field in the schema but the API doesn't expose it.
Add the role field to the GET /users/:id response."
If you see Claude going in the wrong direction, press Ctrl+C to stop and redirect. Do not wait for it to finish a large wrong change. If it already made bad changes, press Esc + Esc to rewind.
Instead of "build a user management system", split it:
- "Create the User database schema with id, email, name, role, created_at"
- "Add CRUD API endpoints for users with input validation"
- "Write tests for the user endpoints"
- "Add role-based access control middleware"
Each step gets verified before moving to the next. This avoids wasting tokens on a bad foundation.
Every message sent to Claude includes the full conversation context. Larger context means higher cost and slower responses.
| Strategy | How | Savings |
|---|---|---|
| Clear between tasks | /clear when switching to unrelated work |
Biggest impact, resets to zero |
| Compact proactively | /compact Focus on the auth module changes |
Keeps relevant context, drops noise |
| Check context usage | /context to see what is consuming space |
Identifies bloat sources |
| Use @file mentions | @src/auth.ts instead of "find the auth file" |
Avoids exploratory file reads |
| Use subagents | Delegate verbose tasks (test runs, log analysis) | Output stays in subagent context |
| Task | Model | Effort |
|---|---|---|
| Simple edits, renames, formatting | Sonnet | /effort low |
| Standard coding, tests, refactoring | Sonnet | /effort medium |
| Complex debugging, architecture | Opus | /effort high |
| Quick questions | Haiku (via /btw) |
N/A |
- Keep the main CLAUDE.md under 200 lines. It loads on every message
- Move detailed instructions into skills. They only load when invoked
- Use
@fileimports for large reference docs instead of pasting content - Put path-specific rules in
.claude/rules/. They only load when Claude touches matching files
- Disable unused MCP servers with
/mcp. Each server adds tool definitions to context - Use CLI tools (
gh,aws,gcloud) instead of MCP when a single command works - Set
ENABLE_TOOL_SEARCH=auto:5to auto-defer tool definitions when they exceed 5% of context
# Hard spending limit
claude -p "fix failing tests" --max-budget-usd 2.00
# Limit agentic turns
claude -p "review this file" --max-turns 3
# Use cheapest model for simple CI tasks
claude -p "check for linting errors" --model haikuWhen you need to see exactly what Claude Code is doing (API calls, tool invocations, timing):
# Full debug output to stderr
claude --debug
# Filter to specific categories
claude --debug "api,hooks"
# Write debug logs to a file (keeps terminal clean)
claude --debug-file /tmp/claude-debug.logUseful when MCP servers are not connecting, hooks are not firing, or API calls are failing silently.
Run /doctor when something is not working right. It checks:
- Claude Code version and auto-updater status
- Authentication state and token validity
- API connectivity
- Settings file syntax and conflicts
- MCP server health
- Permission configuration
Run /insights after a long session to get an analysis report covering:
- Token usage breakdown by category
- Most expensive operations in the session
- Patterns in how you use Claude Code
- Suggestions for improving efficiency
- Time spent waiting vs. actively working
Use this to identify habits that waste tokens and adjust your workflow.
Claude Code integrates with VS Code and JetBrains IDEs for inline diffs, context sharing, and side-by-side conversations.
- Install the "Claude Code" extension from the VS Code marketplace
- Open Command Palette (
Cmd+Shift+Pon Mac /Ctrl+Shift+Pon Linux/Windows) and search "Claude Code" - Works with Cursor editor too
- Install "Claude Code" from the JetBrains Marketplace
- Works across all JetBrains IDEs
- Supports interactive diffs and context sharing
Start Claude with IDE auto-detection:
claude --ideAuto mode uses an AI classifier to decide whether each tool call needs your approval. Instead of prompting on every command, it allows safe operations (reads, git status, test runs) and blocks risky ones (force push, rm -rf, production deploys) automatically. Enable it with --permission-mode auto or press Shift+Tab to cycle to it.
Inspect the classifier rules:
# View current auto-mode config
claude auto-mode config
# View default allow/deny rules
claude auto-mode defaults
# Get AI feedback on your custom rules
claude auto-mode critiqueCustomize rules in .claude/settings.json or ~/.claude/settings.json under the autoMode key with allow, soft_deny, and environment arrays.
Chain multiple claude -p calls in a bash script for repeatable workflows:
#!/bin/bash
# Automated PR review pipeline
git diff HEAD~1 > /tmp/diff.txt
cat /tmp/diff.txt | claude -p "review for security issues" --model sonnet > security_review.md
cat /tmp/diff.txt | claude -p "check for performance regressions" --model sonnet > perf_review.md
cat /tmp/diff.txt | claude -p "write a one-paragraph summary" --model haiku > summary.mdBatch process multiple files:
#!/bin/bash
# Generate docstrings for all Python files missing them
for f in $(grep -rL '"""' src/*.py); do
claude -p "add docstrings to functions missing them in $f" \
--allowedTools "Read,Edit" --max-turns 3
doneGenerate a changelog from git tags:
git log v1.0.0..v2.0.0 --oneline | \
claude -p "create a changelog grouped by feature, fix, and chore" \
--output-format text > CHANGELOG.mdThe /loop slash command runs a prompt or another slash command on a repeating interval within your session:
# Check deploy status every 5 minutes
/loop 5m check if the deploy on staging is complete
# Run tests every 10 minutes (default interval)
/loop /test
# Custom interval with a slash command
/loop 2m /security-reviewThe loop runs in the background until you stop it or end the session. Each iteration gets its own context, so long-running loops do not bloat the conversation.
The 20 commands and shortcuts you will use every day:
| Action | How |
|---|---|
| Start new session | claude |
| Continue last session | claude -c |
| Initialize project | /init |
| Switch to plan mode | Shift+Tab |
| Switch model | /model opus or Option+P / Alt+P |
| Undo changes | Esc + Esc |
| Free context space | /compact |
| Start fresh | /clear |
| Check costs | /cost |
| Review changes | /diff |
| Security scan | /security-review |
| Name session | /rename my-feature |
| Resume session | /resume or claude -r |
| Mention a file | @path/to/file |
| Run bash directly | !ls -la |
| Multiline input | \ + Enter |
| Cancel generation | Ctrl+C |
| Exit | Ctrl+D |
| Non-interactive | claude -p "query" |
| Show all commands | /help |
| Subcommand | What It Does |
|---|---|
claude agents |
List configured agents and their descriptions |
claude auth |
Manage authentication (login, logout, token info) |
claude auto-mode config |
Print effective auto-mode classifier rules |
claude auto-mode defaults |
Show default allow/deny rules |
claude auto-mode critique |
Get AI feedback on your custom auto-mode rules |
claude doctor |
Health check for auto-updater, auth, MCP, settings |
claude install [target] |
Install specific version (stable, latest, or version number) |
claude mcp |
Configure and manage MCP servers from the CLI |
claude plugins |
Manage Claude Code plugins |
claude setup-token |
Set up a long-lived auth token (requires subscription) |
claude update |
Check for and install updates |
- Official Claude Code Documentation
- Claude Code for DevOps Engineers
- Full cheat sheet with screenshots
- Anthropic API Documentation
- MCP Documentation
Found a missing command or outdated flag? Open an issue or submit a PR. All contributions are welcome.
This project is licensed under the MIT License. See LICENSE for details.