Claude Code Cheat Sheet

A free, searchable field guide for claude code commands, claude code mcp, claude code config, claude code workflow, and practical claude code tips.

Claude Code commands

Start sessions, manage context, switch models, and move between tasks without leaving the terminal.

claude

01

Start an interactive Claude Code session in the current directory.

shell$ claude

claude -c

02

Continue the most recent conversation in the current directory.

shell$ claude -c

claude -r <session>

03

Resume a conversation by session ID or name, optionally with a new prompt.

shell$ claude -r "auth-refactor"

/help

04

Show the available built-in commands and usage hints. Type / to filter the command menu.

slash command/help

/model [model]

05

Switch the AI model. With no argument, open the picker; supported models can also adjust effort with the arrow keys.

slash command/model sonnet

/clear [name]

06

Start a new conversation with empty context. An optional name keeps the old session easy to find in /resume.

slash command/clear new-task

/compact [instructions]

07

Summarize the current conversation to free context while keeping the same session. Add focus instructions when needed.

slash command/compact focus on the API error

/init

08

Initialize a project guide by creating a starter CLAUDE.md for the repository.

slash command/init

/resume [session]

09

Resume a conversation by ID or name, or open the session picker. Alias: /continue.

slash command/resume auth-refactor

/status

10

Open Settings on the Status tab to inspect version, model, account, connectivity, and setting sources.

slash command/status

/quit

11

Exit the CLI. /quit is an alias of /exit; Ctrl+D also sends the exit signal.

slash command/quit

claude -p

12

Run a non-interactive prompt for scripts or CI. Pair it with an output format when a machine-readable result is needed.

shell$ claude -p "explain this function" --output-format json
No commands match this search. Try mcp, permission, or context.

Claude Code config

Use CLAUDE.md for project context and settings.json for behavior, permissions, model, and output style.

CLAUDE.md

01

Persistent project context: architecture, conventions, test commands, constraints, and instructions Claude should follow every session.

markdown# Project instructions
- Run npm test before a PR.

settings.json scopes

02

User settings apply everywhere; project settings are shared; local settings are gitignored overrides. Managed policy sits above them.

paths~/.claude/settings.json
.claude/settings.json
.claude/settings.local.json

model

03

Set the initial model in settings, use --model for a launch override, or use /model during a session.

json / shell{ "model": "claude-sonnet-4-6" }

permissions

04

Allow, ask, or deny tool calls with specific rules. Deny rules take precedence; review active sources with /status and edit via /permissions.

json{ "permissions": { "allow": ["Bash(npm test *)"] } }

outputStyle

05

Change how Claude responds. Built-in styles include Default, Explanatory, Proactive, and Learning; custom styles live in output-styles/.

json{ "outputStyle": "Explanatory" }

.claude/rules/

06

Split reusable project rules into focused Markdown files. Keep personal project notes in CLAUDE.local.md; use @path/to/file to import context.

tree.claude/rules/
  testing.md
  api-style.md

Keep responsibilities separate

CLAUDE.md tells Claude about your project. settings.json controls behavior and permissions. .mcp.json connects shared MCP servers. Output styles change response format.

No config cards match this search. Try model, permission, or CLAUDE.md.

MCP: connect external tools

Model Context Protocol lets Claude Code connect to external tools and data sources through configured MCP servers.

MCP in one line

01

MCP is an open protocol for exposing tools, resources, and prompts to an AI client. In Claude Code, each server adds a reviewed connection to an outside system.

mental modelClaude Code + MCP = connected tools

claude mcp add · HTTP

02

Add a remote HTTP server. HTTP is the recommended transport for cloud services and supports OAuth when the provider offers it.

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

claude mcp add · stdio

03

Run a local MCP process. The double dash separates Claude Code options from the server command and its arguments.

shell$ claude mcp add --transport stdio my-server -- npx -y my-mcp-server

list / get / remove

04

List configured servers, inspect one server, or remove it. Inside a Claude Code session, use /mcp for status and authentication.

shellclaude mcp list
claude mcp get notion
claude mcp remove notion

--scope decides who gets it

05

Local is the default and stays tied to you and one project. Project scope writes shared config to .mcp.json; user scope is available across your projects.

shell$ claude mcp add --scope project ...

Useful server examples

06

These provider endpoints are documented examples. Always review the provider’s current setup and permissions before connecting.

notion → mcp.notion.com/mcpHTTP
sentry → mcp.sentry.dev/mcpOAuth
stripe → mcp.stripe.comHTTP

Authenticate after adding

For OAuth-capable HTTP servers, run /mcp in a session or use claude mcp login <name>. Keep tokens out of .mcp.json and source control.

No MCP cards match this search. Try server, scope, or oauth.

Claude Code workflow

Small context, explicit intent, and short feedback loops make the agent easier to steer and easier to trust.

01

Start each task clean

Use /clear when the goal changes. Give the previous session a name if you may need it later with /resume.

02

Ask for the plan first

For a large change, use /plan or start with --permission-mode plan. Ask for files, risks, and verification steps before edits.

03

Ship in small slices

Make one logical change, inspect git diff, run the focused test, then commit. Short checkpoints make mistakes cheap to undo.

04

Protect the context window

Use /context to see what is consuming space. Use /compact for the same task, or narrow the request instead of pasting whole logs.

05

Make verification explicit

Ask Claude to explain what changed and how it verified the result. Use /status, /doctor, tests, and a final diff review.

06

Automate repeatable checks

For CI or scripts, use claude -p with --output-format json. Keep prompts narrow and set a clear budget or failure condition.

No workflow cards match this search. Try plan, context, or commit.

Common errors & fixes

Start with the narrowest diagnostic, then change one variable at a time. Avoid bypassing safety controls just to make an error disappear.

Rate limit / API limit

01

Pause and retry with backoff. Check account usage, plan or API billing, provider status, and whether multiple sessions are sharing the same limit.

check first/status
claude auth status --text

Context window exceeded

02

Run /context to find the biggest consumers, then /compact with a focus. Start a new task with /clear and summarize only what matters.

recover/context
/compact keep the API decisions

Permission denied

03

Inspect the exact tool rule in /permissions. Check the working directory and the setting scope; a managed deny cannot be overridden by a project file.

inspect/permissions
/status

Network / MCP connection

04

Check the endpoint, transport, headers, proxy, and local network. For MCP, inspect health with claude mcp get and re-authenticate if needed.

diagnoseclaude mcp get notion
claude mcp login notion

Auth / invalid API key

05

Check whether Claude Code is authenticated, then sign in again. If you use Console billing, select the console login flow; do not commit credentials.

shellclaude auth status --text
claude auth login

Unknown command or flag

06

Command availability can vary by Claude Code version, plan, platform, and environment. Check your version and the current command menu before automating.

verifyclaude --version
/help
No error cards match this search. Try network, context, or permission.

Keyboard shortcuts

Terminal interactions vary slightly by OS and terminal. These are the common Claude Code CLI bindings.

Ctrl C

Cancel

Cancel current input or generation.

Ctrl D

Exit

Exit the Claude Code session.

Ctrl L

Redraw

Redraw the screen while keeping input and history.

Ctrl O

Transcript viewer

Toggle detailed tool usage and transcript view.

Ctrl R

History search

Search previous prompts interactively.

Ctrl B

Background

Background a running Bash command or agent.

Shift Tab

Cycle modes

Cycle permission modes such as default, acceptEdits, and plan.

Esc Esc

Rewind

Rewind code and/or conversation, or summarize from a selected point.

\ + Enter

New line

Add a newline without submitting in any terminal.

/   !   @

Quick prefixes

/ commands, ! shell mode, @ file mention.

No shortcuts match this search. Try Ctrl, mode, or history.

Frequently asked questions

Short answers for the most common Claude Code setup and workflow questions.

No FAQ answers match this search. Try config, MCP, or errors.