![]()
Claude Code is Anthropic's AI coding agent. It lives in your terminal, reads your entire codebase, edits files, runs commands, manages git, and iterates on failures — all from natural language instructions. You describe what you want, and Claude figures out how to build it.
Unlike autocomplete tools that suggest the next line of code, Claude Code operates at the project level. It understands how your files connect, plans multi-file changes, runs your test suite, and fixes what breaks. Eight months after launch, it hit a 46% "most loved" rating among developers — overtaking GitHub Copilot's four-year lead.
This guide covers everything from installation to advanced workflows. Whether you're evaluating Claude Code for the first time or looking to go deeper, this is the reference you'll want bookmarked.
Claude Code requires a paid Claude account — Pro ($20/mo), Max ($100 or $200/mo), Team, or Enterprise. The free Claude.ai plan does not include access.
The native installer auto-updates, so you always run the latest version.
macOS / Linux / WSL:
curl -fsSL https://claude.ai/install.sh | bash
Windows PowerShell:
irm https://claude.ai/install.ps1 | iex
Windows CMD:
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
Windows native setups require Git for Windows installed first.
| Method | Command | Auto-Updates? |
|---|---|---|
| Homebrew (macOS) | brew install --cask claude-code | No |
| WinGet (Windows) | winget install Anthropic.ClaudeCode | No |
| VS Code Extension | Search "Claude Code" in Extensions (Ctrl+Shift+X) | Yes |
| JetBrains Plugin | Install from JetBrains Marketplace | Yes |
| Desktop App | Download from claude.ai | Yes |
| Web | Visit claude.ai/code — no install needed | N/A |
cd your-project
claude
Your browser opens for authentication on first run. Once signed in, you're dropped into an interactive session. Start with something exploratory:
> What does this project do? Summarize the architecture and key dependencies.
Claude reads your file structure, package files, and source code, then gives you a structured overview. From here, you can start asking it to make changes.
Understanding the execution model helps you work with Claude Code effectively instead of fighting it.
Claude Code operates through a set of discrete tools: Read (read files), Edit (modify files), Write (create files), Bash (run shell commands), Grep (search content), Glob (find files by pattern), and more. When you give Claude a task, it decides which tools to use and in what order.
Every tool call is visible to you. Claude proposes an action — "I want to edit src/auth/login.ts" — and you approve or deny it. This approval loop is the core interaction model. You stay in control while Claude does the heavy lifting.
Claude Code runs on models with up to a 200K token context window (1M in beta for Max and Enterprise plans). That context holds your conversation, the files Claude has read, tool outputs, and system instructions. When context fills up, Claude's responses degrade. Managing context is a skill you'll develop over time.
You can adjust how much autonomy Claude gets:
| Mode | Behavior |
|---|---|
default | Asks permission before file writes and shell commands |
acceptEdits | Auto-approves file edits, still asks for shell commands |
plan | Read-only analysis — Claude can explore but not change anything |
auto | A classifier model reviews commands in real-time, blocking risky ones |
Switch modes mid-session with Shift+Tab. Start in default mode until you're comfortable, then graduate to auto for faster workflows.
CLAUDE.md is a markdown file that Claude reads at the start of every session. Think of it as persistent project memory — it tells Claude your conventions, build commands, architecture decisions, and anything else it should know without being asked.
Claude loads CLAUDE.md files from multiple locations, all at once:
| Location | Scope | Share via Git? |
|---|---|---|
~/.claude/CLAUDE.md | Global (all projects) | No |
./CLAUDE.md | Project root | Yes |
./CLAUDE.local.md | Personal project notes | No (gitignore it) |
| Parent directories | Monorepo root | Depends |
The most impactful things to put in CLAUDE.md:
# Project
Next.js 14 app with App Router, TypeScript, Tailwind CSS, and Supabase.
# Commands
- `npm run dev` — start dev server on port 3000
- `npm run build` — production build
- `npm run test` — run Jest test suite
- `npm run lint` — ESLint check
# Conventions
- Use named exports, not default exports
- Components go in `src/components/{feature}/`
- API routes go in `src/app/api/{resource}/route.ts`
- Always use server actions for form submissions
- Write tests for all new utility functions
# Git
- Branch naming: `feature/description`, `fix/description`
- Commit messages: imperative mood, under 72 characters
- Always run tests before committing
If Claude starts ignoring your CLAUDE.md rules, the file is probably too long. Keep it focused.
Run /init in your project directory. Claude generates a starter CLAUDE.md based on your detected tech stack, package files, and project structure.
Slash commands are typed directly into the Claude Code prompt. Here are the ones that matter most for daily use.
When your context window fills up, Claude's quality drops. The /compact command summarizes the conversation to free up tokens.
The key trick: pass focus instructions to control what the summary retains.
/compact Focus on the database migration changes and the failing test
Without guidance, /compact makes its own choices about what matters. With a focus instruction, you keep exactly the context you need.
Toggle Plan Mode where Claude analyzes your codebase without making changes. Perfect for understanding a problem before committing to a solution.
The recommended workflow: Explore (Plan Mode) -> Plan -> Implement (Normal Mode) -> Commit.
Resets your conversation context entirely. Use this between unrelated tasks. Context pollution — leftover context from a previous task bleeding into the current one — is the number one cause of degraded Claude Code performance.
Ask a question without adding anything to the conversation history:
/btw what was the name of that config file we discussed?
The response appears in a dismissible overlay. It has full visibility into your current conversation but leaves no trace in the context window. You can even use /btw while Claude is actively working on something else.
Shows session cost, duration, and token usage. Useful for understanding how different tasks consume your quota.
Displays a colored grid showing how your context window is allocated across conversation history, tool outputs, and system instructions. The diagnostic tool for understanding why Claude starts forgetting things.
Opens an interactive viewer showing all uncommitted changes Claude has made. Useful before committing to make sure everything looks right.
Opens a checkpoint menu where you can restore previous states. Three options:
Also accessible by double-tapping Escape.
Claude Code's terminal interface is richer than it looks.
| Shortcut | Action |
|---|---|
Escape | Stop Claude's current generation |
Escape x2 | Open rewind menu |
Ctrl+S | Stash your current prompt (restores after next response) |
Ctrl+R | Search through prompt history |
Ctrl+B | Background a running task |
Ctrl+O | Toggle transcript viewer (see all tool calls) |
Ctrl+T | Toggle task list visibility |
Alt+P | Switch between models |
Alt+T | Toggle extended thinking |
Alt+O | Toggle fast mode |
Shift+Tab | Cycle permission modes |
Important: Escape stops generation. Ctrl+C exits the session entirely. Learn this distinction early.
On macOS, the Alt shortcuts require setting Option as Meta in your terminal. In iTerm2: Settings > Profiles > Keys > set Left Option to "Esc+". In VS Code terminal: set "terminal.integrated.macOptionIsMeta": true.
Prefix any input with ! to run a shell command directly:
! npm test
! git log --oneline -5
! docker ps
The output gets added to Claude's context without going through tool approval. Faster than asking Claude to run a command for you.
Type @ to trigger file path autocomplete:
Look at @src/auth/middleware.ts and fix the token validation
More precise than hoping Claude finds the right file on its own.
Press Ctrl+V to paste a screenshot from your clipboard. Claude sees the image and can reference it in its analysis. Useful for UI bugs, error screenshots, and design references.
The command-line flags available when launching Claude Code unlock workflows beyond interactive sessions.
# Resume the most recent session — no questions asked
claude --continue
# Pick from a list of previous sessions
claude --resume
--continue is for speed. --resume is for choosing a specific session. Both restore full context.
claude --name "feature-auth-redesign"
Named sessions are easy to find when using --resume. Adopt a convention like feature-, fix-, refactor- and your session list becomes scannable.
claude -p "Find all TODO comments and list them by priority"
Runs Claude non-interactively: process one prompt, print the result, exit. This turns Claude Code into a composable CLI tool for scripts and pipelines.
# Restrict tool access
claude -p "Fix lint errors" --allowedTools "Read,Edit,Bash"
# Get JSON output for parsing
claude -p "List all API endpoints" --output-format json
# Cap spending
claude -p "Refactor the auth module" --max-budget-usd 5
claude --worktree
Starts Claude in a temporary git worktree — an isolated copy of your repo. Changes happen on a separate branch without touching your working directory. Useful when you want Claude to experiment without risk.
MCP (Model Context Protocol) is an open standard that connects Claude Code to external tools and data sources. MCP servers give Claude access to databases, APIs, file systems, and third-party services.
claude mcp add github -- npx -y @modelcontextprotocol/server-github
claude mcp add postgres -- npx -y @modelcontextprotocol/server-postgres
claude mcp add slack -- npx -y @anthropic/mcp-server-slack
With MCP servers configured, Claude can:
Type @ in your prompt to see available resources from connected MCP servers. Claude discovers tools from MCP servers automatically and uses them when relevant to your task.
MCP servers are configured in .mcp.json at your project root or in ~/.claude/settings.json for global access:
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "your-token-here"
}
}
}
}
Hooks are shell commands that run automatically at specific lifecycle events. Unlike CLAUDE.md instructions (which Claude follows when it remembers to), hooks are deterministic — they always execute.
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"command": "npx prettier --write \"$TOOL_INPUT_FILE_PATH\""
}
]
}
}
This runs Prettier on every file Claude edits. No more reminding Claude to format — it happens automatically, every time.
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"command": "bash -c 'read input; cmd=$(echo \"$input\" | jq -r \".tool_input.command\"); case \"$cmd\" in *\"rm -rf /\"*|*\"DROP TABLE\"*|*\"--force\"*) echo \"Blocked\" >&2; exit 2;; *) exit 0;; esac'"
}
]
}
}
PreToolUse hooks that exit with code 2 block the action before it happens.
| Scope | File |
|---|---|
| Global | ~/.claude/settings.json |
| Project (shared) | .claude/settings.json |
| Project (personal) | .claude/settings.local.json |
For complex tasks, Claude Code can spawn additional agents that work in parallel.
Claude automatically creates subagents for independent subtasks — like researching a library's API while simultaneously writing test scaffolding. Each subagent gets its own context window and tool access. Results flow back to the main session.
Press Ctrl+B to background a running task and continue working on something else.
Agent Teams take parallel work further. Multiple Claude instances coordinate through shared task lists and work on different parts of a project simultaneously. One agent might implement a feature while another writes tests for it.
Agent Teams are useful for large-scale refactoring, multi-service changes, and projects where work can be cleanly divided.
Claude Code isn't limited to the terminal.
The VS Code extension (2M+ installs) integrates Claude Code directly into your editor:
@ mentions to reference files and symbolsInstall from the Extensions marketplace (search "Claude Code") or run code --install-extension anthropic.claude-code.
Available for IntelliJ IDEA, PyCharm, and WebStorm via the JetBrains Marketplace. Supports interactive diff viewing and selection-based context sharing.
Visit claude.ai/code for a browser-based environment. No local setup required. Supports long-running tasks, parallel sessions, and working on repos without cloning them locally.
The quality of Claude Code's output depends heavily on how you prompt it. Here are patterns that consistently produce better results.
Bad: "Fix the login bug"
Good: "The login form at @src/components/auth/LoginForm.tsx throws a 401 error when the email contains a + character. The issue is likely in the URL encoding of the email parameter sent to the /api/auth/login endpoint."
Reference files with @, mention constraints, and point to the specific behavior you expect.
For non-trivial tasks, don't jump straight to implementation:
This pattern produces dramatically better results than a single "migrate to JWT" prompt.
The single most impactful thing you can do: tell Claude how to check its own work. Add this to your CLAUDE.md:
After making changes, always run `npm test` to verify nothing is broken.
Claude then runs tests after every change and fixes failures before moving on. This one instruction measurably improves output quality.
If you were debugging a CSS issue and now want to add an API endpoint, run /clear first. Leftover context from the previous task confuses Claude's reasoning about the new one.
If you've corrected Claude three or more times and it's still not getting it right, don't keep pushing. Run /clear or start a new session. Rephrase your request with more context about what you actually want. A fresh start with a better prompt beats a long correction chain every time.
| Plan | Price | What You Get |
|---|---|---|
| Pro | $20/mo | Claude Code access with base usage limits |
| Max 5x | $100/mo | 5x Pro usage, Opus model access, priority |
| Max 20x | $200/mo | 20x Pro usage, Opus model access, priority |
| Team | $30/user/mo | Team management, shared billing |
| Enterprise | Custom | SSO, admin controls, custom limits |
| API (Console) | Pay-per-token | Sonnet 4.6: $3/$15 per MTok in/out |
The $20 Pro tier works well for moderate use — a few complex tasks per day with lighter work in between. Heavy users who run Claude Code for hours of complex debugging or multi-file refactoring regularly hit the usage ceiling and need to upgrade to Max.
A common strategy: keep Pro ($20/mo) for Claude Code and pair it with a lighter autocomplete tool like GitHub Copilot ($10/mo) for inline suggestions. Total cost of $30/month covers most workflows.
If you need Claude Code for CI/CD pipelines or automated workflows, the API pay-per-token model through the Console gives you precise cost control with flags like --max-budget-usd.
curl -fsSL https://claude.ai/install.sh | bash (macOS/Linux) and authenticate through your browser./init to generate a starter file./clear between tasks, /compact with focus instructions, and /btw for side questions that don't pollute context.default permission mode, then graduate to auto once comfortable. Use plan mode for exploring unfamiliar codebases.claude mcp add.-p flag) turns Claude Code into a scriptable CLI tool for pipelines, CI/CD, and batch processing.Production-ready CLAUDE.md templates, MCP server configs, custom hooks, and battle-tested workflows. Stop configuring, start building.