Claude Code Cheatsheet

A quick reference for starting Claude Code, managing context, and configuring skills, plugins, MCP servers, worktrees, subagents, and hooks.

Start by opening a session in the project directory. Use the reference below when you need to choose a settings file, check a shortcut, or add a new capability to that project.

Examples come from a reference captured on 3 December 2026. Check the official docs for options available in your client. Claude Code documentation

Getting Started

Choose the installer supported by your platform and confirm the installed client with claude --version. Start in the intended repository, or use the resume and continue options when you need an existing conversation rather than a new one.

Example 1
claude update
claude --version
Example 2
claude
claude "explain this codebase"
claude --continue
claude --resume <session-id>

Install Claude Code

Keyboard Shortcuts

Start with a slash to find a command, mention a file with @, or start with ! for direct shell input. Escape can interrupt a response and a second press can open checkpoint actions. Shift+Tab rotates permission modes, which vary by plan and platform. Check on-screen help when a terminal remaps the default keys.

Keyboard Shortcuts
ItemDetails
defaultShown as Manual. Asks before tool calls that need permission
acceptEditsAccepts file edits without asking
planExplores and proposes a plan without editing files
autoA classifier approves or blocks actions, when available on your plan

Configuration

Use repository settings for rules that belong in version control and project-local settings for choices specific to your machine. User settings supply defaults across projects. The configuration panel is a convenient way to check the active theme or model before editing a file directly.

Configuration
ItemDetails
.claude/settings.local.jsonProject-local overrides (gitignored)
.claude/settings.jsonProject-level (committed to repo)
~/.claude/settings.jsonUser-level global defaults
Example 1
/config                 # open the settings screen
/config model=sonnet    # set a value directly
/config theme=dark
/config --help          # list the keys you can set
Example 2
{
  "model": "sonnet",
  "permissions": {
    "allow": ["Bash(npm test *)", "Bash(git diff *)"]
  }
}

Checkpointing

Open /rewind or press Escape twice with an empty prompt to select a checkpoint from the current conversation. Depending on the selection, you can restore the conversation, tracked code edits or both. Files changed only through shell commands, remote changes, installs, database migrations and Git commits need their own recovery procedure. A checkpoint cannot take you before the session began.

Slash Commands

Type a slash at the prompt to see commands your installed client and account support. Use the full command reference to distinguish a command from a shell flag. Repository command files can package a repeated request with access rules, while skills are the current option when the workflow also needs supporting files.

Slash Commands
ItemDetails
/helpShow all available slash commands
/clearStart a new conversation with empty context
/rewindRoll code and conversation back to a checkpoint (alias: /undo)
/compactCompress conversation history to save tokens
/memoryEdit CLAUDE.md files and auto memory
/permissionsShow and edit current tool permissions
/modelSwitch model and save it as your default
/usageShow session cost and plan limits (alias: /cost)
/exportExport conversation to a file
/doctorCheck your setup and fix common problems
/bugReport a bug to Anthropic
/code-reviewReview your changes or a PR for bugs (alias: /review)
/contextSee what is filling the context window
/initCreate a starter CLAUDE.md for the project
Example 1
---
description: "Run all linters and fix auto-fixable issues"
allowed-tools: Bash
---

1. `npm run lint -- --fix`
2. `npm run type-check`
3. Summarise what was fixed.

Headless Mode

Use print mode to run a single request and capture its output from a shell or CI. Select text for a human-readable report or a documented JSON format for programmatic handling. For automated checks, verify the actual process or test result independently of a model-written summary.

Headless Mode
ItemDetails
--output-format textPlain text (default)
--output-format jsonFull JSON response object
--output-format stream-jsonStreaming NDJSON tokens
Example 1
claude -p "summarise the last commit"
cat README.md | claude -p "check for spelling errors"
claude -p "list all TODO comments" --output-format json
claude -p "explain main.go" --output-format stream-json
Example 2
claude -p "run tests and exit 1 if any fail" --allowedTools Bash

git log --since=yesterday --oneline | \
  claude -p "plain-English summary of today's commits" > summary.txt

gh pr diff | claude -p "review for bugs and security issues"

Agent Skills

The captured cheatsheet uses Markdown command files for its reusable examples. In current Claude Code, put a reusable skill in a named folder with SKILL.md and optional references, examples or scripts. Write an activation description, state which tools belong in the workflow and check the rendered output against one normal and one edge case.

Agent Skills
ItemDetails
descriptionShown in /help and skill picker
allowed-toolsComma-separated tools this skill may use
argument-hintPlaceholder shown after the slash command
Example 1
---
description: "Review current branch diff for bugs and style issues"
allowed-tools: Bash, Read
---

1. Run `git diff main...HEAD`.
2. Check for: bugs, security, missing error handling, style.
3. Output grouped by severity.

Create a Claude Code skill

Plugins

Install and update packages through their marketplace or use the documented local-development option while testing changes. A package can supply commands, agents, skills, hooks and MCP servers. Check the component inventory and its required permissions before using it with your normal project.

Example 1
claude plugins list
claude plugins install <plugin-name>
claude plugins install ./my-plugin
claude plugins remove <plugin-name>
claude plugins update
Example 2
my-plugin/
├── plugin.json
├── commands/
│   └── my-skill.md
└── mcp/
    └── my-server.json
Example 3
{
  "name": "my-plugin",
  "version": "1.0.0",
  "description": "My custom plugin",
  "commands": ["commands/my-skill.md"],
  "mcpServers": ["mcp/my-server.json"]
}

MCP Servers

Register the provider's documented endpoint or command and choose where the connection should load. Current Claude Code documentation uses a project-root .mcp.json to share project definitions with a team. Keep reusable configuration separate from credentials and inspect a server's permissions and status before asking it to work with real data.

Featured MCP servers
ServiceUseSource package
githubUse repository files, issues, pull requests and GitHub search in a connected workflow.@modelcontextprotocol/server-github
filesystemWork with local files inside explicitly allowed directories.@modelcontextprotocol/server-filesystem <path>
postgresRead data from a PostgreSQL database through the connector's query interface.@modelcontextprotocol/server-postgres <conn>
slackUse Slack channels, message search and permitted posting actions.@modelcontextprotocol/server-slack
brave-searchSearch the public web or local listings with a configured Brave Search account.@modelcontextprotocol/server-brave-search
notionLook up pages and databases and use authorized updates to the Notion workspace.@notionhq/notion-mcp-server
linearFind and organize Linear work across issues, projects and cycles.@linear/linear-mcp-server
figmaInspect design documents, component definitions and relevant tokens.@figma/mcp-server
playwrightDrive and inspect a browser during approved test workflows.@executeautomation/playwright-mcp-server
Example 1
claude mcp add --transport stdio filesystem -- npx -y @modelcontextprotocol/server-filesystem "/path/to/allowed-folder"
claude mcp list
claude mcp remove filesystem
Example 2
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path"],
      "env": {}
    }
  }
}

Official MCP setup

Git Worktrees

Create separate checked-out paths when two independent branches need work at the same time. Start each session at its own worktree and inspect the branch and clean status before removing it. Claude Code also documents a shell worktree flag for starting a session in an isolated checkout.

Example 1
git worktree list
git worktree add ../feature-branch feature-branch
git worktree add -b my-feature ../my-feature main
git worktree remove ../feature-branch
git worktree prune
Example 2
git worktree add -b feat/auth ../project-auth main
cd ../project-auth && claude

git worktree add -b fix/perf ../project-perf main
cd ../project-perf && claude
Example 3
/worktree my-feature-name

Subagents

Give a subagent one responsibility with its own inputs, expected result and permitted tools. A review worker can report evidence without needing write access, while a data worker can get a read-only input directory. Use separate workers where you can combine useful results without parallel edits to the same file.

Example 1
---
description: "Deep code review: bugs, security, style"
allowed-tools: Read, Glob, Grep
---

Review the provided diff for:
- Logic bugs and edge cases
- Security vulnerabilities (OWASP Top 10)
- Performance issues

Output a markdown report with severity labels.
Example 2
---
description: "Root-cause analysis for failing tests or errors"
allowed-tools: Read, Bash, Grep, Glob
---

1. Reproduce the error.
2. Identify the root cause.
3. Propose the minimal fix.
4. Verify the fix doesn't break other tests.
Example 3
---
description: "Analyse data files and produce statistical summaries"
allowed-tools: Bash, Read
---

1. Load and describe the schema.
2. Identify missing values and outliers.
3. Compute summary statistics.
4. Suggest visualisations and next steps.

Permissions

Scope allow and deny rules to the action and environment that need them. Read-only inspection and approved test commands can use different rules from edits or deployment. Confirm which settings are recognized by the installed version and use managed configuration when an organization needs an enforceable policy.

Permissions
ItemDetails
ReadAll file reads
BashAll shell commands
Bash(git *)Only git sub-commands
Bash(npm run *)Only npm run scripts
Bash(rm *)Any rm command
Example 1
{
  "permissions": {
    "allow": ["Read", "Write", "Edit", "Bash(git *)"],
    "deny": ["Bash(rm -rf *)", "Bash(curl *)", "Bash(wget *)"]
  }
}
Example 2
{
  "permissions": {
    "allow": ["Read", "Glob", "Grep"],
    "deny": ["Write", "Edit", "Bash", "WebFetch", "WebSearch"]
  },
  "autoApprove": false
}
Example 3
{
  "permissions": {
    "allow": ["Read","Write","Edit","Glob","Grep",
      "Bash(npm *)","Bash(git *)","Bash(docker *)"],
    "deny": ["Bash(curl *)","Bash(wget *)","Bash(ssh *)","WebFetch"]
  },
  "autoApprove": false,
  "requireApprovalForNewFiles": true
}

Hooks

Hooks run at defined lifecycle events such as before a tool action, after a tool result or when a subagent finishes. Choose the event and matcher for the behavior you want, then test on a fixture. Current command hooks read their input as JSON on standard input. For PreToolUse blocking, use the documented blocking response or exit code 2. A generic nonzero exit alone does not reliably block an action.

The two examples go in the project hook settings and .claude/check-demo-command.py respectively. This example blocks a single demonstration command.

Hooks
ItemDetails
PreToolUseBefore any tool call: block by exiting non-zero
PostToolUseAfter any tool call completes
StopWhen Claude finishes its final response
NotificationWhen Claude emits a system notification
SubagentStopWhen a subagent finishes
Hooks
ItemDetails
CLAUDE_TOOL_NAMEName of the tool being called
CLAUDE_TOOL_INPUTJSON-encoded tool input arguments
CLAUDE_TOOL_OUTPUTTool result (PostToolUse only)
CLAUDE_SESSION_IDUnique ID for the current session
CLAUDE_PROJECT_DIRAbsolute path to the project directory
Example 1
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "python .claude/check-demo-command.py"
          }
        ]
      }
    ]
  }
}
Example 2
import json
import sys

command = json.load(sys.stdin).get("tool_input", {}).get("command", "")
if "delete-demo-output" in command:
    print("The example rule blocks demo output deletion.", file=sys.stderr)
    sys.exit(2)

Official hooks reference