Skip to main content

CLAUDE CODECHEATSHEET

Complete reference with commands, shortcuts, configuration, plugins, skills, MCP integrations, and automation workflows

Getting Started

Install via curl (macOS/Linux)

Recommended installation method

curl -fsSL https://claude.ai/install.sh | bash

Install via Homebrew

Install using Homebrew on macOS

brew install --cask claude-code

Install via PowerShell (Windows)

Install on Windows using PowerShell

irm https://claude.ai/install.ps1 | iex

Install via npm

Install globally using npm (requires Node.js 18+)

npm install -g @anthropic-ai/claude-code

Start Claude Code

Launch Claude Code in your project

cd your-project && claude

Update to Latest

Keep Claude Code up to date

claude update

Keyboard Shortcuts

!Bash mode prefix
@Mention files/folders
\Line break (backslash + Enter)
EscInterrupt Claude
Esc+EscOpen rewind menu (undo changes)
Ctrl+RFull output/context
Ctrl+VPaste image
Shift+TabAuto-accept ("yolo mode")
Shift+Tab+TabPlan mode
Cmd+Esc / Ctrl+EscQuick launch in IDEs
Cmd+Option+K / Alt+Ctrl+KInsert file references

Configuration

📁 Settings File Locations (Priority Order)

1. Enterprise: /etc/claude-code/managed-settings.json (highest priority)
2. Project Local: .claude/settings.local.json (personal, git-ignored)
3. Project Shared: .claude/settings.json (team settings)
4. User Global: ~/.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>

Checkpointing - Undo & Rewind

⏮️ Automatic Safety Net

Claude Code automatically tracks all file edits, letting you quickly rewind to previous states if changes go wrong.

⌨️ Rewind Commands

Esc+EscOpen rewind menu to restore previous states
/rewindOpen rewind menu via slash command

✨ Rewind Options

Automatic Tracking

Every user prompt creates a new checkpoint

Conversation Rewind

Restore to previous user message while keeping code

Code Rewind

Revert file changes while keeping conversation

Full Rewind

Restore both code and conversation to prior state

⚠️ Limitations

Bash changes not tracked: Files modified by bash commands (rm, mv, cp) cannot be undone
External changes not tracked: Manual edits outside Claude Code aren't captured
Not version control: Checkpoints complement Git but don't replace it
💡 Use checkpoints for quick recovery, Git for permanent history

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-dirAdd additional working directories
/agentsManage custom AI subagents for specialized tasks
/bugReport bugs (sends conversation to Anthropic)
/clearClear conversation history
/compact [instructions]Compact conversation with optional focus instructions
/configView/modify configuration
/costShow token usage statistics
/doctorCheck Claude Code installation health
/helpGet usage help
/initInitialize project with CLAUDE.md guide
/loginSwitch Anthropic accounts
/logoutSign out from your Anthropic account
/mcpManage MCP server connections and OAuth authentication
/memoryEdit CLAUDE.md memory files
/modelSelect or change the AI model
/permissionsView or update permissions
/pr_commentsView pull request comments
/reviewRequest code review
/rewindRewind the conversation and/or code (Esc+Esc)
/sandboxEnable sandboxed bash tool with filesystem and network isolation
/statusView account and system statuses
/terminal-setupInstall Shift+Enter key binding (iTerm2/VSCode)
/usageShow plan usage limits and rate limit status (subscription plans only)
/vimEnter vim mode for alternating insert/command modes

🎯 Custom Slash Command Templates

Basic Project Command

Create a simple project-specific command

📁 Save as: .claude/commands/optimize.md
Analyze this code for performance issues and suggest optimizations:

Personal Command

Create a user-wide command available in all projects

📁 Save as: ~/.claude/commands/security-review.md
Review this code for security vulnerabilities:

Command with All Arguments

Use $ARGUMENTS placeholder for all arguments

📁 Save as: .claude/commands/fix-issue.md
Fix issue #$ARGUMENTS following our coding standards

Command with Positional Arguments

Use $1, $2, $3 for individual arguments

📁 Save as: .claude/commands/review-pr.md
---
argument-hint: [pr-number] [priority] [assignee]
description: Review pull request with priority and assignee
---

Review PR #$1 with priority $2 and assign to $3.
Focus on security, performance, and code style.

Git Commit Command

Advanced command with bash execution and file references

📁 Save as: .claude/commands/commit.md
---
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.

Command with Model Override

Specify model and disable automatic invocation

📁 Save as: .claude/commands/deep-analysis.md
---
description: Perform deep code analysis
model: claude-opus-4-1-20250805
disable-model-invocation: true
---

Perform a comprehensive analysis of this codebase focusing on:
- Architecture patterns
- Potential scalability issues
- Security vulnerabilities
- Performance bottlenecks

💡 Usage Tips

Project commands: Store in .claude/commands/ (shared with team)
Personal commands: Store in ~/.claude/commands/ (available across all projects)
Arguments: Use $ARGUMENTS placeholder for dynamic values
Bash execution: Use !`command` to run commands before processing
File references: Use @filename to include file contents
MCP commands: Format: /mcp__server__prompt_name

Headless Mode - Programmatic Usage

🤖 Run Claude Code Non-Interactively

Use --print (or -p) for automation, scripts, and CI/CD pipelines. Perfect for SRE bots, automated code reviews, and agent integrations.

📋 Key Headless Commands

claude -p "query"Non-interactive mode, print result and exit
claude -p --output-format json "query"Output in JSON format with metadata
claude -p --output-format stream-json "query"Stream JSON messages as they arrive
claude -c -p "query"Continue most recent conversation non-interactively
claude --resume <id> -p "query"Resume specific session non-interactively
echo "query" | claude -pProcess piped input
claude --verbose -p "query"Enable verbose logging for debugging
claude --max-turns 3 -p "query"Limit agentic turns in non-interactive mode

💼 Real-World Examples

SRE Incident Response

Automated incident investigation

claude -p "Analyze these errors" \
  --append-system-prompt "You are an SRE expert" \
  --output-format json \
  --allowedTools "Bash,Read,mcp__datadog"

Security Audit

Automated PR security review

gh pr diff 123 | claude -p \
  --append-system-prompt "You are a security engineer" \
  --output-format json \
  --allowedTools "Read,Grep" > audit.json

Multi-turn Session

Maintain context across multiple commands

session_id=$(claude -p "Start review" --output-format json | jq -r '.session_id')
claude --resume "$session_id" -p "Check compliance"
claude --resume "$session_id" -p "Generate summary"

📊 Output Formats

text (default): Plain text response
json: Structured data with metadata (cost, duration, session_id)
stream-json: Streaming messages for real-time processing
💡 Use JSON formats for programmatic parsing and automation

Agent Skills - Modular Capabilities

🧠 What are Agent Skills?

Skills are modular capabilities that extend Claude's functionality. Unlike slash commands (user-invoked), Skills are model-invoked—Claude autonomously uses them based on context.

Location: .claude/skills/ (project) or ~/.claude/skills/ (personal)
Structure: Directory with SKILL.md + optional scripts and resources
Discovery: Automatic based on description and context

📋 Skill Setup Commands

mkdir -p .claude/skills/skill-nameCreate project Skill directory
mkdir -p ~/.claude/skills/skill-nameCreate personal Skill directory
cat > .claude/skills/my-skill/SKILL.mdCreate Skill definition file

🎯 Skill Templates

Simple Skill

Basic Skill with single file

📁 .claude/skills/commit-helper/SKILL.md
---
name: generating-commit-messages
description: Generates clear commit messages from git diffs. Use when writing commit messages or reviewing staged changes.
---

# Generating Commit Messages

## Instructions

1. Run `git diff --staged` to see changes
2. I'll suggest a commit message with:
   - Summary under 50 characters
   - Detailed description
   - Affected components

## Best practices

- Use present tense
- Explain what and why, not how

Skill with Tool Permissions

Skill that limits tool access

📁 .claude/skills/code-reviewer/SKILL.md
---
name: code-reviewer
description: Review code for best practices and potential issues. Use when reviewing code, checking PRs, or analyzing code quality.
allowed-tools: Read, Grep, Glob
---

# Code Reviewer

## Review checklist

1. Code organization and structure
2. Error handling
3. Performance considerations
4. Security concerns
5. Test coverage

🔄 Skills vs Slash Commands

Slash Commands: User-invoked (you type /command), simple prompts, single file
Agent Skills: Model-invoked (automatic), complex capabilities, multiple files + scripts
💡 Use Skills for comprehensive workflows, Commands for quick prompts

Plugins - Extend Claude Code

🧩 What are Plugins?

Plugins extend Claude Code with custom commands, agents, hooks, Skills, and MCP servers. Install from marketplaces or create your own.

📋 Plugin Management Commands

/pluginOpen plugin management interface
/plugin marketplace add <url-or-path>Add a plugin marketplace
/plugin install <name>@<marketplace>Install a plugin from marketplace
/plugin enable <name>@<marketplace>Enable a disabled plugin
/plugin disable <name>@<marketplace>Disable a plugin without uninstalling
/plugin uninstall <name>@<marketplace>Completely remove a plugin

💡 Quick Start Examples

Add GitHub Marketplace

Add a plugin marketplace from GitHub

claude mcp add marketplace your-org/claude-plugins

Install Plugin

Install a specific plugin from marketplace

/plugin install formatter@your-org

Local Development Marketplace

Add local marketplace for plugin development

/plugin marketplace add ./dev-marketplace

✨ What Plugins Can Provide

Custom Commands: Add slash commands for your workflows
Specialized Agents: Deploy expert subagents for specific tasks
Agent Skills: Package capabilities Claude can discover
Automation Hooks: Run scripts on Claude Code events
MCP Servers: Connect to external tools and services

MCP 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 command
claude mcp add --transport sse <name> <url>Add SSE transport MCP server
claude mcp add --transport http <name> <url>Add HTTP transport MCP server
claude mcp listList installed MCP servers
claude mcp remove <name>Remove MCP server

⚡ Popular MCP Integrations

Airtable

Read/write records, manage bases and tables

claude mcp add --transport stdio airtable --env AIRTABLE_API_KEY=YOUR_KEY -- npx -y airtable-mcp-server

Asana

Interact with your Asana workspace

claude mcp add --transport sse asana https://mcp.asana.com/sse

Atlassian

Manage Jira tickets and Confluence docs

claude mcp add --transport sse atlassian https://mcp.atlassian.com/v1/sse

Box

Access enterprise content and automate workflows

claude mcp add --transport http box https://mcp.box.com/

Canva

Browse, summarize, autofill and generate Canva designs

claude mcp add --transport http canva https://mcp.canva.com/mcp

ClickUp

Task management, project tracking

claude mcp add --transport stdio clickup --env CLICKUP_API_KEY=YOUR_KEY --env CLICKUP_TEAM_ID=YOUR_TEAM -- npx -y @hauptsache.net/clickup-mcp

Cloudflare

Build apps, analyze traffic, manage security

claude mcp add --transport http cloudflare https://mcp.cloudflare.com/mcp

Cloudinary

Upload, manage, transform media assets

claude mcp add --transport http cloudinary https://mcp.cloudinary.com/mcp

Daloopa

High quality fundamental financial data

claude mcp add --transport http daloopa https://mcp.daloopa.com/server/mcp

Figma

Generate better code with full Figma context

claude mcp add --transport http figma https://mcp.figma.com/mcp

Fireflies

Extract insights from meeting transcripts

claude mcp add --transport http fireflies https://api.fireflies.ai/mcp

GitHub

Manage repositories, PRs, and issues

claude mcp add --transport http github https://api.githubcopilot.com/mcp/

HubSpot

Access and manage HubSpot CRM data

claude mcp add --transport http hubspot https://mcp.hubspot.com/anthropic

Hugging Face

Access Hugging Face Hub and Gradio apps

claude mcp add --transport http huggingface https://huggingface.co/mcp

Intercom

Access customer conversations and tickets

claude mcp add --transport http intercom https://mcp.intercom.com/mcp

invideo

Build video creation capabilities

claude mcp add --transport sse invideo https://mcp.invideo.io/sse

Jam

Debug with AI agents accessing Jam recordings

claude mcp add --transport http jam https://mcp.jam.dev/mcp

Linear

Issue tracking and project management

claude mcp add --transport http linear https://mcp.linear.app/mcp

Monday

Manage monday.com boards and items

claude mcp add --transport http monday https://mcp.monday.com/mcp

Netlify

Create, deploy, and manage websites

claude mcp add --transport http netlify https://netlify-mcp.netlify.app/mcp

Notion

Read docs, update pages, manage tasks

claude mcp add --transport http notion https://mcp.notion.com/mcp

PayPal

Payment processing and transaction management

claude mcp add --transport http paypal https://mcp.paypal.com/mcp

Plaid

Banking data and financial account linking

claude mcp add --transport sse plaid https://api.dashboard.plaid.com/mcp/sse

Playwright

Advanced browser automation

claude mcp add --transport stdio playwright -- npx @playwright/mcp@latest

Puppeteer

Browser automation

claude mcp add --transport stdio puppeteer -- npx -y @modelcontextprotocol/server-puppeteer

Sentry

Monitor errors, debug production issues

claude mcp add --transport http sentry https://mcp.sentry.dev/mcp

Socket

Security analysis for dependencies

claude mcp add --transport http socket https://mcp.socket.dev/

Square

Payments, inventory, orders, and more

claude mcp add --transport sse square https://mcp.squareup.com/sse

Stripe

Payment processing and subscriptions

claude mcp add --transport http stripe https://mcp.stripe.com

Stytch

Configure and manage authentication services

claude mcp add --transport http stytch http://mcp.stytch.dev/mcp

Supabase

Database operations

claude mcp add --transport stdio supabase --env SUPABASE_ACCESS_TOKEN=YOUR_TOKEN -- npx -y @supabase/mcp-server-supabase@latest

Vercel

Manage projects, deployments, and logs

claude mcp add --transport http vercel https://mcp.vercel.com/

Workato

Access applications, workflows, and data

claude mcp add --transport http workato https://mcp.workato.com/mcp

Zapier

Connect to 8,000+ apps

claude mcp add --transport http zapier https://mcp.zapier.com/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 branch
git worktree add <path> -b <branch> <start-point>Create worktree with new branch
git worktree listList all worktrees and their branches
git worktree remove <path>Remove a worktree directory
git worktree pruneClean up worktree references
git 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

Project subagents: .claude/agents/ (highest priority, team shared)
User subagents: ~/.claude/agents/ (personal, all projects)
File format: Markdown with YAML frontmatter

📋 Essential Subagent Commands

/agentsOpen subagents management interface
claude "Use the [name] subagent to..."Explicitly invoke a specific subagent
mkdir -p .claude/agentsCreate project subagents directory
mkdir -p ~/.claude/agentsCreate user subagents directory

🎯 Ready-to-Use Subagent Templates

Code Reviewer

Expert code review after writing/modifying code

📁 Save as: .claude/agents/code-reviewer.md
---
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
model: inherit
---

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

📁 Save as: .claude/agents/debugger.md
---
name: debugger
description: Debugging specialist for errors, test failures, and unexpected behavior. Use proactively when encountering any issues.
tools: Read, Edit, Bash, Grep, Glob
model: sonnet
---

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.

Data Scientist

Data analysis expert for SQL and BigQuery

📁 Save as: .claude/agents/data-scientist.md
---
name: data-scientist
description: Data analysis expert for SQL queries, BigQuery operations, and data insights. Use proactively for data analysis tasks.
tools: Bash, Read, Write
model: opus
---

You are a data scientist specializing in SQL and BigQuery analysis.

When invoked:
1. Understand the data analysis requirement
2. Write efficient SQL queries
3. Use BigQuery command line tools (bq) when appropriate
4. Analyze and summarize results
5. Present findings clearly

Key practices:
- Write optimized SQL queries with proper filters
- Use appropriate aggregations and joins
- Include comments explaining complex logic
- Format results for readability
- Provide data-driven recommendations

Always ensure queries are efficient and cost-effective.

💡 Usage Tips

Automatic invocation: Include "proactively" or "MUST BE USED" in descriptions
Explicit invocation: "Use the code-reviewer subagent to check my code"
Chaining: "Use debugger then optimizer subagents"
Tool limitation: Only grant necessary tools for security and focus
Team sharing: Check project subagents into version control

📝 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.

⚠️ MCP Tool Permissions

Wildcards NOT supported: mcp__github__* will NOT work
✅ Approve all tools from server: "allow": ["mcp__github"]
✅ Approve specific tool: "allow": ["mcp__github__get_issue"]

🏢 Enterprise Configuration

Managed settings: /etc/claude-code/managed-settings.json
Managed MCP: /etc/claude-code/managed-mcp.json
MCP allowlist/denylist: Control which MCP servers employees can use via allowedMcpServers and deniedMcpServers
💡 Denylist takes absolute precedence over allowlist

Basic Security

Block sensitive files, allow common dev commands

💡 Good starting point for most projects
{
  "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

💡 For production systems or sensitive codebases
{
  "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:*)"
    ]
  }
}

Slash Command Permissions

Control which slash commands Claude can invoke

💡 Restrict automated command execution
{
  "permissions": {
    "allow": [
      "SlashCommand:/commit",
      "SlashCommand:/review-pr:*"
    ],
    "deny": [
      "SlashCommand"
    ]
  }
}

Enterprise MCP Restrictions

Example enterprise MCP server allowlist/denylist

💡 Control which MCP servers can be used
{
  "allowedMcpServers": [
    {
      "serverName": "github"
    },
    {
      "serverName": "sentry"
    },
    {
      "serverName": "company-internal"
    }
  ],
  "deniedMcpServers": [
    {
      "serverName": "filesystem"
    }
  ]
}

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

PreToolUseRuns before tool calls (can block them)
PostToolUseRuns after tool calls complete
UserPromptSubmitRuns when user submits a prompt, before Claude processes it
NotificationRuns when Claude Code sends notifications
StopRuns when Claude Code finishes responding
SubagentStopRuns when subagent tasks complete
PreCompactRuns before compact operation
SessionStartRuns when Claude Code starts/resumes session
SessionEndRuns when Claude Code session ends

🛠️ Hook Management Commands

/hooksOpen hooks configuration interface
claude --debugRun with debug output to see hook execution
mkdir -p .claude/hooksCreate project hooks directory
chmod +x .claude/hooks/script.shMake hook script executable

🎯 Ready-to-Use Hook Examples

Auto Format Code

Run prettier on edited files

Event: PostToolUseMatcher: Edit|Write
{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [
          {
            "type": "command",
            "command": "npx prettier --write $FILE_PATH"
          }
        ]
      }
    ]
  }
}

Log Activity

Keep a log of all Claude sessions

Event: Stop
{
  "hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "echo \"$(date): $CONVERSATION_SUMMARY\" >> ~/.claude/activity.log"
          }
        ]
      }
    ]
  }
}

🏗️ Hook Structure & Tips

Settings location: ~/.claude/settings.json (user) or .claude/settings.json (project)
Matchers: Match tool names (e.g., Bash, Edit|Write, *)
Project scripts: Use $CLAUDE_PROJECT_DIR for relative paths
Exit codes: 0=success, 2=block & show to Claude, other=error
JSON input: Hooks receive session data via stdin (use jq to parse)
Debugging: Use claude --debug to see hook execution details

PDF & PNG Downloads

Claude Code Cheatsheet - Printable version with keyboard shortcuts, commands, and configurations

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.