
TL;DR
The Short Answer
If you only memorize ten things in Claude Code, make it these:
claudestarts a session in the current folder.claude -ccontinues the last one./initwrites a starter CLAUDE.md, the file Claude reads at the start of every session.@mentions a file,!runs a shell command,/opens commands and skills.Shift+Tabcycles permission modes, including plan mode (Claude proposes, but doesn't edit).Escstops Claude mid-action.Esctwice on an empty prompt opens rewind./clearbetween unrelated tasks./compactto shrink a long one.claude -p "..."runs once and exits, for scripts and CI.claude mcp addconnects external tools through MCP.- Rules that must never be broken go in hooks or deny rules, not CLAUDE.md.
- Give Claude a check to run (tests, a build, a linter) and ask for the output.
Everything here was checked against Anthropic's docs on November 5, 2026. Claude Code updates often; type / to see what your version has.
Install Claude Code and Run Your First Session
This is the 5-minute Claude Code tutorial. You need a terminal, a project folder, and a Claude subscription (Pro, Max, Ultra, Team, or Enterprise) or a Claude Console account with API credits.
The native installer is recommended because it updates itself. Homebrew and WinGet installs don't, so upgrade those now and then. npm also works (npm install -g @anthropic-ai/claude-code, Node.js 22+), but don't use sudo.
On first launch, Claude Code opens your browser to log in. Then ask plain-English questions like "what does this project do?" or "explain the folder structure".
Not a terminal person? Claude Code also runs as a desktop app, in VS Code and JetBrains, and at claude.ai/code. This cheat sheet covers the terminal version.
# macOS, Linux, WSL (recommended, auto-updates)
curl -fsSL https://claude.ai/install.sh | bash
# Windows PowerShell
irm https://claude.ai/install.ps1 | iex
# Or with a package manager (no auto-update)
brew install --cask claude-code
winget install Anthropic.ClaudeCode
# Check it worked, then start in your project
claude --version
cd /path/to/your/project
claude
# Something wrong? Diagnose without starting a session
claude doctorSlash Commands You'll Actually Use
Slash commands are typed inside a running session. Type / to open the menu and keep typing to filter it. Some are built-in commands. Others, like /code-review, /loop, and /doctor, are bundled skills: prompt-based playbooks that ship with Claude Code. The full list of 100+ is in the commands reference.
| What it does | Example | |
|---|---|---|
| /help | Show help and available commands | /help |
| /init | Generate a starter CLAUDE.md from your codebase, or suggest improvements to an existing one | /init |
| /clear | Start a new conversation with empty context. A name labels the old one for /resume | /clear oauth-migration |
| /compact | Summarize the conversation to free up context, with optional focus instructions | /compact keep the API changes and the test commands |
| /context | Show what fills the context window, including which CLAUDE.md files loaded | /context all |
| /plan | Enter plan mode, optionally with a task | /plan fix the auth bug |
| /model | Switch model and save it as your default | /model sonnet |
| /effort | Set how hard Claude thinks: low to xhigh, max, or auto | /effort high |
| /rewind | Roll code, conversation, or both back to an earlier prompt (aliases /checkpoint, /undo) | /rewind |
| /resume | Resume a past conversation by ID or name, or open the picker | /resume auth-refactor |
| /diff | Review changes in your working tree, including Claude's edits | /diff |
| /code-review | Review the current diff in a fresh subagent that never saw your conversation | /code-review |
| /security-review | Check your branch's changes for security vulnerabilities | /security-review |
| /btw | Ask a side question without adding it to the conversation | /btw what does this regex match? |
| /goal | Keep Claude working across turns until a condition is met | /goal all tests in tests/auth pass and lint is clean |
| /loop | Repeat a prompt on an interval while the session is open | /loop 15m check CI on this branch |
| /memory | Edit CLAUDE.md files and toggle auto memory | /memory |
| /permissions | Manage allow, ask, and deny rules for tools | /permissions |
| /mcp | Manage MCP server connections and sign-ins | /mcp |
| /skills | List available skills | /skills |
| /agents | Reminds you to ask Claude for a subagent or edit .claude/agents/ (v2.1.197 and earlier opened a wizard) | /agents |
| /usage | Session cost, plan limits, and activity stats (alias /cost) | /usage |
| /doctor | Diagnose installation, settings, and CLAUDE.md problems and propose fixes | /doctor |
CLI Commands and Flags
These run from your shell, before a session starts.
claude "fix the build error": start a session with a first prompt.claude -c(--continue): load the most recent conversation in this folder.claude -r "auth-refactor"(--resume): resume by ID or name. No argument opens a picker.claude -n "auth-refactor"(--name): name a new session.claude -w feature-auth(--worktree): start in an isolated git worktree so parallel sessions don't collide.--model sonnet: pick a model by alias (sonnet,opus,haiku,fable) or full name.--permission-mode plan: start in a given permission mode (see below).--add-dir ../lib: let Claude read and edit another folder too.--allowedTools "Bash(git diff *)" "Read": pre-approve tools.--disallowedToolsblocks them.claude update,claude -v,claude auth status: update, check the version, check your login.
--dangerously-skip-permissions turns off every permission check. Anthropic says to use it only in isolated containers or VMs, not on your laptop.
# Start a named session in plan mode
claude -n "auth-refactor" --permission-mode plan
# Pick it up tomorrow
claude --resume auth-refactor
# Parallel work in its own worktree (<repo>/.claude/worktrees/feature-auth)
claude -w feature-auth
# Specific model, plus access to a sibling folder
claude --model opus --add-dir ../shared-libKeyboard Shortcuts
Press ? on an empty prompt to see the shortcuts for your terminal. The ones that matter:
Esc: stop Claude mid-turn. Work so far is kept, so you can redirect.EscEscon an empty prompt: open the rewind menu.Shift+Tab: cycle permission modes.Ctrl+C: interrupt or clear input.Ctrl+Dtwice exits.Ctrl+B: send a running command or agent to the background.@: file autocomplete, which puts the file into your message.!at the start: shell mode. Runs the command and shows Claude the output.Ctrl+V(Cmd+Vin iTerm2,Alt+Von Windows): paste an image, like a screenshot of an error.Ctrl+G: open your prompt, or a proposed plan, in your text editor.Ctrl+R: search prompt history.Ctrl+O: transcript with full tool calls.Option+P/Alt+P: switch model without clearing your prompt.- New line without sending:
\thenEnter, orCtrl+Janywhere.Shift+Enterworks natively in iTerm2, WezTerm, Ghostty, Kitty, Warp, Apple Terminal, and Windows Terminal. In VS Code, Cursor, Alacritty, or Zed, run/terminal-setuponce.
On macOS, Alt shortcuts need "Option as Meta" turned on in your terminal.
Permission Modes and Plan Mode
A permission mode decides what Claude can do without asking. Shift+Tab cycles them, and the status bar shows the current one.
default(shown as Manual): reads run freely, everything else asks.acceptEdits: file edits and common file commands (mkdir,mv,cp) run without asking.plan: Claude researches and writes a plan but can't edit your source until you approve.auto: actions run without prompts, but a separate classifier model reviews each one and blocks risky ones. Since v2.1.283 this is the built-in starting mode in the terminal and VS Code.dontAsk: only pre-approved tools run; anything else is denied. Built for CI.bypassPermissions: no checks. Containers and VMs only.
Plan mode is the best habit for anything bigger than a one-line fix. Enter it with Shift+Tab or /plan. When the plan is ready, approve it (with auto mode or manual edit review) or choose "No, keep planning" and give feedback. Ctrl+G lets you edit the plan first.
Note that claude -p runs start in Manual mode, so anything you didn't pre-approve gets denied instead of prompting.
# Start a session in plan mode
claude --permission-mode plan
# CI run with an exact allowlist: anything else is refused
claude -p "run the test suite" --permission-mode dontAsk --allowedTools "Bash(npm test)" "Read"CLAUDE.md Template and Memory
CLAUDE.md is a Markdown file Claude loads into every session. It's guidance, not enforced configuration, so keep it short and specific. Anthropic recommends under 200 lines.
~/.claude/CLAUDE.md: your preferences for all projects../CLAUDE.mdor./.claude/CLAUDE.md: the project file. Commit it../CLAUDE.local.md: your personal notes for this project. Add it to.gitignore..claude/rules/*.md: rules with apaths:filter that load only for matching files.@path/to/fileinside CLAUDE.md imports another file.- If the repo has an
AGENTS.md(the file Codex and other agents use) and no CLAUDE.md, Claude Code reads AGENTS.md. - Auto memory is separate: Claude keeps its own notes in
~/.claude/projects/<project>/memory/. Manage it with/memory.
Put in: exact test, typecheck, and lint commands; places where the code is misleading; decisions that live outside the repo; anything you've corrected twice. Leave out your folder layout, because Claude reads the repo itself. This template follows Anthropic's own example:
# Commands
- Install: pnpm install
- Run one test file: pnpm vitest run path/to/file.test.ts
- Typecheck: pnpm tsc --noEmit
# Conventions
- Use the error helpers in src/lib/errors.ts, never throw raw strings
- src/legacy/ is still live but don't copy its patterns into new code
# Gotchas
- Integration tests need DATABASE_URL set, see .env.exampleSettings Files: Where Everything Lives
Settings are strict JSON (no comments, no trailing commas). Highest priority first:
- Managed (
managed-settings.json): set by your organization. - Command line:
--settings <file-or-json>for one session. - Project local:
.claude/settings.local.json, just you, kept out of git. - Shared project:
.claude/settings.json, committed for the team. - User:
~/.claude/settings.json, you, every project.
Other locations: subagents in ~/.claude/agents/ and .claude/agents/; skills in ~/.claude/skills/<name>/SKILL.md and .claude/skills/<name>/SKILL.md; MCP servers in ~/.claude.json and .mcp.json at the project root. Run /status to confirm a file loaded. This example lets lint and tests run without asking and blocks reading .env files:
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"permissions": {
"allow": [
"Bash(npm run lint)",
"Bash(npm run test *)"
],
"deny": [
"Read(./.env)",
"Read(./.env.*)"
]
}
}Subagent Template
A subagent is a helper with its own context window, instructions, and tool list. Claude hands it a task and gets a summary back. That's useful for parallel research, for keeping noisy output out of your chat, and for review by fresh eyes. Built-in ones include Explore (fast, read-only search) and Plan.
To make one, ask Claude ("create a read-only code-reviewer subagent in .claude/agents/ that uses Sonnet") or write the file yourself. To use it, name it in your prompt, or @-mention it to guarantee it runs. Anthropic's own caveat: delegating doesn't make an answer better by itself, and each subagent costs extra tokens.
---
name: code-reviewer
description: Reviews code for quality and best practices
tools: Read, Glob, Grep
model: sonnet
---
You are a code reviewer. When invoked, analyze the code and provide
specific, actionable feedback on quality, security, and best practices.Skills Template (Custom Slash Commands)
A skill is a saved procedure: a folder with a SKILL.md file. The folder name becomes a slash command, and Claude can also load it on its own when your request matches its description. Until then only the description sits in context, so long playbooks cost almost nothing. Custom commands were merged into skills: .claude/commands/deploy.md still works and creates /deploy, just like .claude/skills/deploy/SKILL.md.
Set disable-model-invocation: true for anything with side effects, like deploys, so only you can start it. Set user-invocable: false for background knowledge only Claude should load. Skills follow the open Agent Skills standard. This one is adapted from Anthropic's best-practices page:
---
name: release
description: Cut a new release. Bumps the version, writes the changelog entry, tags it and pushes the tag so CI can publish.
disable-model-invocation: true
---
1. Make sure you're on main with a clean tree. If not, stop and ask.
2. Run `pnpm changeset version` and commit the result.
3. Summarize the PRs merged since the last tag into CHANGELOG.md, one line each, user-facing changes only.
4. Tag `v<new version>` and push the tag. CI publishes from there, never publish from your machine.Hooks Template
A hook is a shell command that Claude Code (the program, not the model) runs automatically at a fixed point, so it fires every time. Anthropic's rule of thumb: if you keep adding emphasis to a CLAUDE.md line and Claude still misses it, that line belongs in a hook.
The events you'll use most: PreToolUse (before a tool runs, can block it), PostToolUse (after a tool succeeds, good for formatting), Stop (when Claude tries to finish; exit code 2 sends it back to work), and Notification (when Claude needs your input). There are more than 25 others. Hooks go in a hooks block in any settings file; check them with /hooks. This example from the docs runs Prettier on every file Claude edits:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "jq -r '.tool_input.file_path' | xargs npx prettier --write"
}
]
}
]
}
}MCP: Connect Claude Code to Other Tools
MCP (Model Context Protocol) is an open standard for plugging tools into AI apps: a browser, Notion, Sentry, your database. If a system already has a CLI (like gh for GitHub), Claude can usually just use that instead.
- Remote servers use
--transport httpand a URL. For local servers, everything after--is the command that starts them. - The default scope is
local(you, this project).--scope usercovers all your projects;--scope projectwrites.mcp.jsonfor the team. - If a server needs a login, finish it from
/mcpinside a session. - Every connected server adds tool descriptions to your context, so turn off the ones you don't use.
Want to write your own? See how to build an MCP server.
# Remote (HTTP) server
claude mcp add --transport http notion https://mcp.notion.com/mcp
# Local server: everything after -- starts it
claude mcp add playwright -- npx -y @playwright/mcp@latest
# Available in all your projects
claude mcp add --scope user --transport http sentry https://mcp.sentry.dev/mcp
# Check, inspect, remove
claude mcp list
claude mcp get sentry
claude mcp remove sentryHeadless Mode: claude -p in Scripts and CI
claude -p "prompt" (--print) runs one task and exits. That's how Claude Code runs in CI jobs, git hooks, and shell loops. Useful flags:
--output-format jsonreturns one result object;stream-jsonwith--verbosestreams events.--allowedToolspre-approves tools, and--permission-mode dontAskrefuses everything else.--max-turnsand--max-budget-usdcap how far a run can go.--bareskips hooks, skills, plugins, MCP servers, and CLAUDE.md so runs behave the same everywhere. It needsANTHROPIC_API_KEYor cloud credentials, not your claude.ai login.--continueor--resume <id>carries a conversation across several-pcalls.
Anthropic's advice: try a loop like this on three files first, fix the prompt, then run the rest.
# One-off question, piped input
cat error.log | claude -p "what's going on here"
# Structured output for scripts
claude -p "Summarize this project" --output-format json
# Batch migration with a tight allowlist and a turn cap
for file in $(cat files.txt); do
claude --bare -p "Migrate $file to the new logger API and commit. Reply OK or FAIL." \
--allowedTools "Read,Edit,Bash(git add *),Bash(git commit *)" \
--permission-mode dontAsk \
--max-turns 20
doneClaude Code Prompting Tips That Actually Work
These come from Anthropic's own best-practices page. Most bad sessions come down to one of four things: Claude was missing information, had no way to check its work, broke a rule nothing enforced, or spent more than the task was worth.
- Tell Claude what it can't see. Name the file, describe the symptom, say what "fixed" looks like. Not "fix the login bug", but "users report login fails after the session times out. look at token refresh in src/auth/, write a failing test that reproduces it, then fix it."
- Hand over the evidence.
@the file, paste the screenshot, pipe in the log. - Say "be ambitious" when you want the full version. Claude reads requests conservatively and builds the smallest thing that works. Only you know the scope you want.
- Not sure what you want? Ask to be interviewed. Let Claude ask questions until it can write
SPEC.md, then build from it in a fresh session. - Give it a check that passes or fails, like tests or a build, and ask for the command and its output. "All tests pass" on its own tells you little.
- Review with fresh eyes. Use
/code-review, or a subagent that checks against your spec. Add "skip style", or the reviewer will always find something. - Steer early. Watch the first minute and press
Escwhen Claude drifts. After two failed corrections,/clearand write one better prompt. /clearbetween unrelated tasks. Every turn re-sends the whole conversation, so old tasks keep costing you.
What you can stop doing: ALL CAPS and "IMPORTANT" (use a hook instead), "think harder" (that's what /effort is for, though ultrathink still asks for deeper reasoning on one turn), and "don't be lazy" (give it a check to pass).
I want to add rate limiting to the public API but haven't thought it through yet. Interview me until you could write the spec, then write it to SPEC.md.
build the settings page from the mockup. be ambitious: empty and error states, the save flow wired up, keyboard navigation, not just the layout
run the auth tests after, and keep going until they pass
use a subagent to review the rate limiter diff against SPEC.md, check every requirement is implemented and the listed edge cases have tests, report gaps that affect correctness and skip styleWhere to Go Next
- New to Claude Code? Follow the Claude Code tutorial and build a small app end to end, then pick a project from 10 Claude Code projects with prompts.
- Weighing other tools? See Claude Code alternatives compared.
- Want structured learning? See the best Claude Code courses and the best vibe coding courses.
- Want to build agents, not just use one? Claude Code is a model in a loop with tools, memory, and permissions. Our free AI Agents with PydanticAI course teaches you to build those pieces in Python, starting with your first agent and tools.
FAQ
- Is Claude Code free?
- No. Claude Code needs a paid Claude subscription (Pro, Max, Ultra, Team, or Enterprise), a Claude Console account with pre-paid API credits, or access through Amazon Bedrock, Google Cloud, or Microsoft Foundry. Run /usage in a session to see your cost and plan limits.
- How do I see all Claude Code commands?
- Type / in a session to open the command menu and keep typing to filter it, or run /help. From the shell, claude --help lists the CLI flags. The full lists are on code.claude.com under Commands and CLI reference.
- What is the difference between CLAUDE.md, skills, and hooks?
- CLAUDE.md is short guidance loaded into every session. A skill is a longer procedure that loads only when it is needed or when you type its slash command. A hook is a shell command Claude Code runs automatically at a fixed point, so it is enforced every time instead of being up to the model.
- How do I stop Claude Code from asking permission all the time?
- Use auto mode, the default starting mode in recent versions, where a classifier reviews risky actions instead of asking you. Or add allow rules for commands you trust with /permissions or in settings.json. Keep --dangerously-skip-permissions for isolated containers and VMs.
- How do I undo what Claude Code changed?
- Press Esc twice on an empty prompt or run /rewind to roll the code, the conversation, or both back to an earlier prompt. Checkpoints only cover files Claude edited with its own file tools, not changes made by shell commands, so keep using git too.




