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.
claude update
claude --versionclaude
claude "explain this codebase"
claude --continue
claude --resume <session-id>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.
| Item | Details |
|---|---|
| default | Shown as Manual. Asks before tool calls that need permission |
| acceptEdits | Accepts file edits without asking |
| plan | Explores and proposes a plan without editing files |
| auto | A 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.
| Item | Details |
|---|---|
| .claude/settings.local.json | Project-local overrides (gitignored) |
| .claude/settings.json | Project-level (committed to repo) |
| ~/.claude/settings.json | User-level global defaults |
/config # open the settings screen
/config model=sonnet # set a value directly
/config theme=dark
/config --help # list the keys you can set{
"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.
| Item | Details |
|---|---|
| /help | Show all available slash commands |
| /clear | Start a new conversation with empty context |
| /rewind | Roll code and conversation back to a checkpoint (alias: /undo) |
| /compact | Compress conversation history to save tokens |
| /memory | Edit CLAUDE.md files and auto memory |
| /permissions | Show and edit current tool permissions |
| /model | Switch model and save it as your default |
| /usage | Show session cost and plan limits (alias: /cost) |
| /export | Export conversation to a file |
| /doctor | Check your setup and fix common problems |
| /bug | Report a bug to Anthropic |
| /code-review | Review your changes or a PR for bugs (alias: /review) |
| /context | See what is filling the context window |
| /init | Create a starter CLAUDE.md for the project |
---
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.
| Item | Details |
|---|---|
| --output-format text | Plain text (default) |
| --output-format json | Full JSON response object |
| --output-format stream-json | Streaming NDJSON tokens |
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-jsonclaude -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.
| Item | Details |
|---|---|
| description | Shown in /help and skill picker |
| allowed-tools | Comma-separated tools this skill may use |
| argument-hint | Placeholder shown after the slash command |
---
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.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.
claude plugins list
claude plugins install <plugin-name>
claude plugins install ./my-plugin
claude plugins remove <plugin-name>
claude plugins updatemy-plugin/
├── plugin.json
├── commands/
│ └── my-skill.md
└── mcp/
└── my-server.json{
"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.
| Service | Use | Source package |
|---|---|---|
| github | Use repository files, issues, pull requests and GitHub search in a connected workflow. | @modelcontextprotocol/server-github |
| filesystem | Work with local files inside explicitly allowed directories. | @modelcontextprotocol/server-filesystem <path> |
| postgres | Read data from a PostgreSQL database through the connector's query interface. | @modelcontextprotocol/server-postgres <conn> |
| slack | Use Slack channels, message search and permitted posting actions. | @modelcontextprotocol/server-slack |
| brave-search | Search the public web or local listings with a configured Brave Search account. | @modelcontextprotocol/server-brave-search |
| notion | Look up pages and databases and use authorized updates to the Notion workspace. | @notionhq/notion-mcp-server |
| linear | Find and organize Linear work across issues, projects and cycles. | @linear/linear-mcp-server |
| figma | Inspect design documents, component definitions and relevant tokens. | @figma/mcp-server |
| playwright | Drive and inspect a browser during approved test workflows. | @executeautomation/playwright-mcp-server |
claude mcp add --transport stdio filesystem -- npx -y @modelcontextprotocol/server-filesystem "/path/to/allowed-folder"
claude mcp list
claude mcp remove filesystem{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path"],
"env": {}
}
}
}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.
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 prunegit 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/worktree my-feature-nameSubagents
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.
---
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.---
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.---
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.
| Item | Details |
|---|---|
| Read | All file reads |
| Bash | All shell commands |
| Bash(git *) | Only git sub-commands |
| Bash(npm run *) | Only npm run scripts |
| Bash(rm *) | Any rm command |
{
"permissions": {
"allow": ["Read", "Write", "Edit", "Bash(git *)"],
"deny": ["Bash(rm -rf *)", "Bash(curl *)", "Bash(wget *)"]
}
}{
"permissions": {
"allow": ["Read", "Glob", "Grep"],
"deny": ["Write", "Edit", "Bash", "WebFetch", "WebSearch"]
},
"autoApprove": false
}{
"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.
| Item | Details |
|---|---|
| PreToolUse | Before any tool call: block by exiting non-zero |
| PostToolUse | After any tool call completes |
| Stop | When Claude finishes its final response |
| Notification | When Claude emits a system notification |
| SubagentStop | When a subagent finishes |
| Item | Details |
|---|---|
| CLAUDE_TOOL_NAME | Name of the tool being called |
| CLAUDE_TOOL_INPUT | JSON-encoded tool input arguments |
| CLAUDE_TOOL_OUTPUT | Tool result (PostToolUse only) |
| CLAUDE_SESSION_ID | Unique ID for the current session |
| CLAUDE_PROJECT_DIR | Absolute path to the project directory |
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "python .claude/check-demo-command.py"
}
]
}
]
}
}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)