Claude Code is Anthropic's terminal-based coding agent. It reads your codebase, edits files, runs commands, and manages git directly from the command line. No IDE plugins, no browser tabs. Just your terminal and an AI that understands your project.
Requirements
Before you install, make sure you have:
- Operating system: macOS, Linux, or Windows 10+
- RAM: 4 GB minimum, 8 GB recommended
- Terminal: Bash, Zsh, PowerShell, or CMD
- Account: Claude Pro, Max, Teams, Enterprise, or Anthropic Console with API credits
The free Claude.ai plan does not include Claude Code. You need a paid account.
Which account tier?
Claude Pro ($20/month) works for most developers. It covers both Claude Code in the terminal and Claude on the web. Claude Max ($100-200/month) adds higher rate limits for heavy usage. If you only need API access, an Anthropic Console account with credits works too.
Native Installer (Recommended)
The native installer is the fastest path. No Node.js required, no dependency management. It auto-updates in the background.
macOS and Linux
Install Claude Code (macOS / Linux)
curl -fsSL https://claude.ai/install.sh | bashThis downloads the binary, installs it to your system, and adds claude to your PATH. Open a new terminal window after installation so your shell picks up the new PATH entry.
Windows
Install Claude Code (Windows PowerShell)
irm https://claude.ai/install.ps1 | iexRun this in PowerShell (not CMD). It installs the native binary and makes the claude command available globally.
Auto-updates
Native installations check for updates automatically. You don't need to re-run the installer to get new versions. This is the main advantage over Homebrew and npm, which both require manual updates.
Homebrew (macOS and Linux)
If you prefer managing tools through Homebrew:
Install via Homebrew
brew install --cask claude-codeOne caveat: Homebrew installations do not auto-update. You need to run brew upgrade claude-code manually to get new versions.
Update Claude Code via Homebrew
brew upgrade claude-codenpm Installation (Legacy)
The npm method still works but is no longer the recommended approach. Use this if you need to pin a specific version or work in an environment where npm is the standard package manager.
Install via npm
npm install -g @anthropic-ai/claude-codeThis requires Node.js 18.0+ and npm. If you see EACCES permission errors, do not use sudo. Fix your npm permissions instead:
Fix npm permissions (if needed)
# Option 1: Change npm's default directory
mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
# Add to your shell profile (~/.bashrc, ~/.zshrc, etc.):
# export PATH=~/.npm-global/bin:$PATH
# Option 2: Use nvm (recommended)
# nvm manages Node versions and avoids permission issues entirely
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
nvm install 22
nvm use 22
npm install -g @anthropic-ai/claude-codeNever use sudo with npm
Running sudo npm install -g creates files owned by root in your npm directory. This causes cascading permission problems for every future npm global install. Always fix the underlying permission issue instead.
Windows Installation Details
Windows users have two paths:
Option 1: Native PowerShell Installer
The simplest method. Open PowerShell and run:
Windows native install
irm https://claude.ai/install.ps1 | iexOption 2: WSL (Windows Subsystem for Linux)
If you prefer a Linux environment, install WSL first, then use the Linux installation method inside it:
Windows WSL setup
# Step 1: Install WSL (in PowerShell as admin)
wsl --install
# Step 2: After reboot, open your WSL terminal
# Step 3: Install Claude Code using the Linux method
curl -fsSL https://claude.ai/install.sh | bashA common mistake: having Node.js installed on Windows but not inside WSL. If you use the npm method through WSL, you need Node.js installed inside the WSL environment, not just on the Windows side.
Authentication
After installation, run claude in any directory. On first launch, it opens your browser for OAuth authentication.
First launch
# Navigate to your project
cd your-project
# Start Claude Code
claude
# Follow the browser prompt to authenticate
# A session token is stored locally after authorizationHeadless / CI Environments
For servers, containers, or CI pipelines where you can't open a browser, set the API key as an environment variable:
API key authentication
# Set your Anthropic API key
export ANTHROPIC_API_KEY=sk-ant-...
# Claude Code will use this key instead of OAuth
claudeThird-Party API Providers
Claude Code also supports connecting through Amazon Bedrock and Google Vertex AI. Configure these via environment variables:
Alternative API providers
# Amazon Bedrock
export CLAUDE_CODE_USE_BEDROCK=1
export AWS_REGION=us-east-1
# Google Vertex AI
export CLAUDE_CODE_USE_VERTEX=1
export CLOUD_ML_REGION=us-east5
export ANTHROPIC_VERTEX_PROJECT_ID=your-project-idSetting Up CLAUDE.md
CLAUDE.md is the single most impactful configuration for Claude Code. It's a markdown file in your project root that gives Claude persistent context about your codebase. Build commands, code conventions, architecture decisions, testing instructions, anything Claude can't infer from the code alone.
Generate a CLAUDE.md from your project
# Inside Claude Code, run:
/init
# This analyzes your codebase and generates a starter CLAUDE.md
# with detected build systems, test frameworks, and code patternsA good CLAUDE.md is concise. Aim for 50-100 lines in the root file. For each line, ask: "Would removing this cause Claude to make a mistake?" If not, cut it.
Example CLAUDE.md
# CLAUDE.md
## Commands
- `npm run dev` - Start dev server on port 3000
- `npm run build` - Production build
- `npm test` - Run Jest tests
- `npm run lint` - ESLint check
## Architecture
- Next.js 15 with App Router
- PostgreSQL with Drizzle ORM
- Authentication via Clerk
- All API routes in src/app/api/
## Conventions
- Server components by default; use "use client" only when needed
- Database access only through Drizzle in server components/actions
- TypeScript strict mode; no any types
- Commit messages: imperative mood, < 72 charsNested CLAUDE.md files
In monorepos or multi-package projects, add a CLAUDE.md in each subdirectory. Claude loads them hierarchically: root-level rules apply everywhere, and child-level rules apply only when working in that directory. Commit these files to version control so the whole team benefits.
Extending Claude Code with MCP Servers
MCP (Model Context Protocol) servers give Claude Code access to external tools and data sources. You can connect it to GitHub, databases, Slack, file systems, search APIs, and custom services.
Adding MCP servers
# Add an HTTP-based MCP server
claude mcp add --transport http notion https://mcp.notion.com/mcp
# Add a local stdio-based MCP server
claude mcp add github -- npx -y @modelcontextprotocol/server-github
# List configured servers
claude mcp list
# Test a specific server
claude mcp get github
# Remove a server
claude mcp remove githubUseful MCP Servers
WarpGrep (Morph)
RL-trained code search. Runs in its own context window so your main Claude session stays clean. Finds precise file and line ranges instead of dumping whole files.
GitHub MCP
Create PRs, manage issues, review code, and interact with repositories directly from Claude Code without switching to the browser.
Postgres MCP
Query your database, inspect schemas, and run migrations. Claude can read your data to inform its code edits.
MCP + Claude Code = agent capabilities
MCP servers turn Claude Code from a coding assistant into a proper agent. Instead of describing what you see in Slack or reading query results to Claude, it can access these systems directly. The fewer copy-paste steps between you and your tools, the faster you move.
Slash Commands and Hooks
Built-in Slash Commands
Slash commands are shortcuts you type directly in the Claude Code REPL:
| Command | What It Does | When to Use |
|---|---|---|
| /init | Generate CLAUDE.md from project | First time setup in a new project |
| /clear | Reset conversation context | Starting a new task, clearing accumulated noise |
| /compact | Compress conversation history | Context getting long, want to stay in same session |
| /cost | Show token usage and costs | Monitoring spend |
| /doctor | Diagnose configuration issues | Something feels broken |
| /mcp | Manage MCP server connections | Adding or debugging MCP servers |
| /config | Open settings configuration | Changing defaults, permissions, preferences |
Custom Slash Commands
Create your own commands by adding markdown files to .claude/commands/ in your project:
Custom slash command example
# .claude/commands/review.md
Review the current git diff for:
- Security vulnerabilities
- Performance issues
- Missing error handling
- Style violations per our CLAUDE.md conventions
Focus on $ARGUMENTS or the entire diff if no specific area given.Now /review auth module runs this prompt with "auth module" substituted for $ARGUMENTS.
Hooks
Hooks run your code at specific points in Claude Code's lifecycle. Configure them via /hooks or directly in .claude/settings.json.
Hook examples
// .claude/settings.json
{
"hooks": {
"postToolUse": [
{
"matcher": "edit_file|write_file",
"type": "command",
"command": "prettier --write $FILE_PATH"
}
],
"preToolUse": [
{
"matcher": "bash",
"type": "command",
"command": "echo 'Running: $TOOL_INPUT'"
}
]
}
}Common hook patterns: auto-format files after edits, block dangerous commands, log tool usage, inject environment context at session start.
Claude Code vs Other CLI Coding Tools
Four tools dominate the terminal-based coding agent space in 2026. Each has a different strength.
| Feature | Claude Code | Codex CLI | Gemini CLI | Aider |
|---|---|---|---|---|
| Model | Claude Opus 4.6 / Sonnet 4.6 | GPT-5 / o3 | Gemini 2.5 Pro/Flash | Any (Claude, GPT, local) |
| Install method | Native, Brew, npm | npm | npm | pip |
| Strength | Deep multi-file reasoning | Debugging, code analysis | Multimodal input, free tier | Model flexibility, open source |
| MCP support | Yes (built-in) | Limited | No | No |
| Auto-updates | Yes (native) | No | No | No |
| Custom commands | Slash commands + hooks | Basic prompts | Basic prompts | Commands and conventions |
| Git integration | Full (commit, PR, diff) | Sandboxed | Basic | Full (auto-commit) |
| Pricing | $20+/mo subscription | Free tier + API | Free tier + API | Free (bring your own key) |
Claude Code is the strongest choice for navigating large codebases and making complex, multi-file changes. If you mostly need quick single-file edits or want to use local models, Aider is a solid alternative. Gemini CLI is worth trying if you work with visual assets or want to experiment without paying upfront.
Troubleshooting
claude: command not found
Your shell hasn't picked up the new PATH entry. Close your terminal and open a new window. If that doesn't work, check that the install location is in your PATH:
Check PATH
# Check if claude is accessible
which claude
# If not found, the installer should have added it to your profile.
# Check ~/.bashrc, ~/.zshrc, or ~/.profile for the PATH addition.
# Then source it:
source ~/.zshrc # or ~/.bashrcEACCES Permission Errors (npm)
Never use sudo npm install -g. Either fix npm's default directory permissions or switch to nvm. See the npm installation section above for the fix.
Authentication Fails
If the browser redirect doesn't work, try these steps:
- Make sure you're logged into claude.ai in the browser that opens
- Check that your account is on a paid plan (Pro, Max, Teams, or Enterprise)
- Try
claude logoutthenclaudeagain to re-authenticate - For CI environments, use
ANTHROPIC_API_KEYinstead of browser auth
Node.js Version Too Old (npm method)
The npm package requires Node.js 18+. Check your version with node --version. Use nvm to install a newer version if needed.
Run claude doctor
When something feels off, claude doctor auto-detects most configuration issues. It checks your Node.js version, authentication state, MCP server health, and file permissions. Run it before spending time debugging manually.
Frequently Asked Questions
How do I install Claude Code?
The recommended method is the native installer. On macOS or Linux: curl -fsSL https://claude.ai/install.sh | bash. On Windows: irm https://claude.ai/install.ps1 | iex in PowerShell. You can also use Homebrew (brew install --cask claude-code) or npm (npm install -g @anthropic-ai/claude-code).
Does Claude Code require Node.js?
No. The native installer and Homebrew methods have zero dependencies. Only the legacy npm method requires Node.js 18+.
What account do I need?
Any paid Anthropic account works: Claude Pro ($20/month), Claude Max ($100-200/month), Teams, Enterprise, or an Anthropic Console account with API credits. The free Claude.ai plan does not include Claude Code.
How do I authenticate in CI/CD pipelines?
Set the ANTHROPIC_API_KEY environment variable. Claude Code detects it automatically and skips the browser OAuth flow. You can also use Amazon Bedrock or Google Vertex AI credentials.
What is CLAUDE.md?
A markdown file in your project root that gives Claude persistent context: build commands, code conventions, architecture patterns. Run /init inside Claude Code to auto-generate one. It's the most important post-install configuration step.
Can I use Claude Code on Windows without WSL?
Yes. The native PowerShell installer (irm https://claude.ai/install.ps1 | iex) works directly on Windows. WSL is an alternative if you prefer a Linux environment.
How do I add MCP servers?
Use claude mcp add with the transport type and URL. For HTTP servers: claude mcp add --transport http name url. For local servers: claude mcp add name -- command args. Run claude mcp list to see configured servers.
How does Claude Code compare to Codex CLI?
Claude Code (powered by Claude Opus 4.6) leads in deep, multi-file reasoning across large codebases. Codex CLI (GPT-5) is strong at debugging and code analysis. Claude Code has better MCP support, auto-updates, and richer customization through slash commands and hooks. Codex CLI runs in a sandboxed environment by default.
Supercharge Claude Code with Morph
Morph builds MCP servers that make Claude Code faster and more accurate. WarpGrep gives Claude RL-trained code search in its own context window, so your main session stays clean. Fast Apply speeds up file edits by 10x. Both plug directly into Claude Code as MCP tools.