Skip to content

Cheatsheet


I want to…Do this
Start Claude Codeclaude
Ask about a specific fileclaude "explain src/app.py"
Fix a bugDescribe the error + paste the traceback
Create a new projectDescribe what you want in plain English
Ask a one-off question without starting a sessionclaude -p "what does this regex do: ^[a-z]+$"
Resume where I left offclaude --continue
Commit my changes/commit
Review code before committing/review
Compress the context to save tokens/compact
See how much I’ve spent this session/cost
Clear the conversation and start fresh/clear
Get help with available commands/help
Run Claude without any interactive promptsclaude --print -p "your task"
Use a specific modelclaude --model claude-opus-4-5
Limit how many steps Claude can takeclaude --max-turns 10

Terminal window
claude # Start interactive session
claude -p "prompt" # One-shot, non-interactive (alias: --print)
claude --continue # Resume last conversation
claude --model <model> # Specify model (haiku/sonnet/opus or full name)
claude --max-turns <n> # Limit agentic turns
claude --output-format json # Machine-readable JSON output
claude --output-format text # Plain text output (default)
claude --verbose # Show full tool call detail
claude --allowedTools "Bash,Read,Write" # Restrict which tools Claude can use
claude --no-tools # Disable all tools (text only)
claude --add-dir /path/to/dir # Add a directory to Claude's context

ShortcutAction
Ctrl+CCancel current generation
Ctrl+DExit session
Up arrowNavigate previous messages
Shift+EnterNew line in your message (without sending)
TabAutocomplete file paths
EscapeCancel current input

CommandWhat It Does
/helpShow available commands and current settings
/statusSession status, model in use, token count
/costToken usage and cost for this session
/compactSummarize conversation to free up context window
/clearClear conversation history
/memoryView and edit CLAUDE.md memory files
/commitStage and commit changes with AI-written message
/reviewReview current changes before committing
/doctorCheck Claude Code setup for common issues
/model <name>Switch model mid-session

One-liners for common tasks — copy, fill in the blanks, send.

Summarize the key points from [document/article] in bullet points.
Review this code for bugs, security issues, and readability. List issues by priority.
You are [role]. [Context]. Task: [what you need]. Format: [how you want it].
Explain [concept] like I understand [adjacent thing] but am new to this area.
I have [problem]. Here's what I've already tried: [attempts]. What should I try next?
Look at [file/folder] and tell me how it works before we make any changes.
Before writing any code, tell me your implementation plan. I'll approve before you start.
This is the output I got: [output]. This is what I expected: [expectation]. What's wrong?

ModelSpeedCostToken LimitWhen to Use
Claude Haiku 4.5FastestLowest (~$0.80/$4 per M)200KClassification, routing, high-volume simple tasks
Claude Sonnet 4.6FastMid (~$3/$15 per M)200KMost tasks — daily driver
Claude Opus 4.6SlowerHighest (~$15/$75 per M)200KComplex reasoning, analysis, when quality is worth the cost

Input/output cost per million tokens. Check anthropic.com/pricing for current rates.

Rule of thumb: Default to Sonnet. Switch to Haiku when running many calls that don’t need high quality. Switch to Opus when you have a hard problem and you can tell Sonnet is struggling.


ConceptWhat It Means
Token~4 characters of text (~0.75 words)
1,000 tokens~750 words, or ~1.5 pages
Context windowHow much text Claude can “see” at once (200K tokens = ~150K words)
Input tokensEverything you send (system prompt + conversation history + your message)
Output tokensClaude’s response — usually billed at a higher rate
Prompt cachingReusing a long system prompt across calls — up to 90% savings on cached input

Rough cost estimates at Sonnet pricing:

  • Short Q&A (500 in / 300 out): ~$0.006
  • Summarize a long article (2K in / 500 out): ~$0.013
  • Analyze a 50-page document (40K in / 2K out): ~$0.15
  • Full codebase review (100K in / 5K out): ~$0.38

MCP (Model Context Protocol) servers give Claude access to external tools and data sources.

Terminal window
# List installed MCP servers
claude mcp list
# Add an MCP server
claude mcp add <name> <command>
# Remove an MCP server
claude mcp remove <name>
# Check MCP server status
claude mcp get <name>

Common MCP servers and what they do:

ServerWhat It Adds
filesystemRead/write files anywhere on your system
githubRead PRs, issues, repos; post comments
notionRead/write Notion pages and databases
google-calendarRead/create calendar events
gmailRead emails, create drafts
firecrawlScrape and read web pages as clean text
sqliteQuery a local SQLite database
puppeteerBrowser automation

import anthropic
client = anthropic.Anthropic() # Uses ANTHROPIC_API_KEY env var
# Basic call
response = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=1024,
system="You are a helpful assistant.", # optional
messages=[{"role": "user", "content": "Hello"}]
)
print(response.content[0].text)
# Streaming
with client.messages.stream(
model="claude-sonnet-4-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Write a story..."}]
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
# Multi-turn conversation
messages = []
messages.append({"role": "user", "content": "What is machine learning?"})
response = client.messages.create(model="claude-sonnet-4-5", max_tokens=512, messages=messages)
messages.append({"role": "assistant", "content": response.content[0].text})
messages.append({"role": "user", "content": "Give me a concrete example."})
# Continue...
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic(); // Uses ANTHROPIC_API_KEY env var
const response = await client.messages.create({
model: "claude-sonnet-4-5",
max_tokens: 1024,
system: "You are a helpful assistant.",
messages: [{ role: "user", content: "Hello" }],
});
console.log(response.content[0].text);