How to Install Claude Code in 5 Minutes

Get Claude Code up and running in 5 minutes. Step-by-step installation guide for Windows, macOS, and Linux, plus API key setup and first-run tips.

·5 min read

What Is Claude Code?

Claude Code is Anthropic's agentic coding CLI that runs directly in your terminal. It reads your entire codebase, writes and edits files, runs tests, and executes commands — all within a conversation.

What You Can Do with Claude Code

- Generate code from natural language descriptions - Debug and fix bugs across your entire project - Refactor code with full awareness of the codebase - Write tests that actually pass - Review PRs and suggest improvements - Run shell commands and interpret the results

Installation

Prerequisites

Before you start, make sure you have:

- Node.js 18+ installed (node --version to check) - npm (comes with Node.js) - An Anthropic API key — sign up at console.anthropic.com

Step 1: Install Claude Code

npm install -g @anthropic-ai/claude-code

This installs the claude command globally.

Step 2: Verify the Installation

claude --version

You should see the current version number printed.

Step 3: Set Your API Key

# Temporary (current session only)
export ANTHROPIC_API_KEY="sk-ant-xxxxxxxx"

# Permanent — add to your shell profile echo 'export ANTHROPIC_API_KEY="sk-ant-xxxxxxxx"' >> ~/.zshrc source ~/.zshrc

Windows users (PowerShell):

[Environment]::SetEnvironmentVariable(
  "ANTHROPIC_API_KEY",
  "sk-ant-xxxxxxxx",
  "User"
)

Step 4: First Run

Navigate to any project directory and run:

cd your-project
claude

Claude Code will start in interactive mode. Try a simple prompt:

> Summarize this project for me.

Claude Code reads your project files and responds with a summary.

Configuration Tips

Set Your Preferred Model

Claude Code defaults to Claude Opus (most capable). To switch models:

# Use Claude Sonnet for faster, cheaper responses
claude config set model claude-sonnet-4-6

# Default paths for tools and settings # ~/.claude.json — global configuration # .claude/ — project-level configuration

Control Costs

API usage costs money. Set spending limits:

# Set a $15 maximum cost per session
claude config set maxCost 15

# Get a warning at $10 claude config set costThreshold 10

Permission Modes

Claude Code needs permission to run commands and edit files:

# Allow all operations without prompting (use cautiously)
claude --permission-mode bypassPermissions

# Prompt before each action (default, safest) claude --permission-mode default

# Accept all permissions for this session only claude --dangerously-skip-permissions

Essential Commands

| Command | What It Does | |---------|-------------| | claude | Start interactive session | | claude "fix the login bug" | One-shot task, prints output | | claude --project my-project | Launch in a specific project | | Ctrl+C | Exit current session | | /help | Show available commands | | /clear | Start a fresh conversation |

Real Example: Your First 5 Minutes

Here's what a real first session looks like:

$ cd my-nextjs-app
$ claude

> Explain how the authentication flow works in this project.

Claude Code reads auth pages, middleware, and API routes...

"The auth flow uses NextAuth.js with GitHub OAuth. There's a middleware at src/middleware.ts that protects routes under /dashboard. The session is managed through JWT tokens stored in an httpOnly cookie..."

> Add a "Sign in with Google" button to the login page.

Claude Code modifies login.tsx, adds the OAuth provider config, and tests the change...

"Done. I added a Google sign-in button to src/app/login/page.tsx and registered the Google provider in src/app/api/auth/[...nextauth]/route.ts. The button appears next to the existing GitHub button."

Troubleshooting

Command Not Found

# Make sure npm global bin is in your PATH
npm list -g --depth=0

# Check where global packages are installed npm root -g

# Add to PATH if needed (macOS/Linux) export PATH="$(npm root -g)/bin:$PATH"

API Key Not Recognized

# Verify the environment variable is set
echo $ANTHROPIC_API_KEY

# Make sure you're using an API key (not a Console login) # Get your key at https://console.anthropic.com/keys

Permission Errors on Windows

Run PowerShell as Administrator or use:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Next Steps

Now that Claude Code is installed:

- Set up OpenClaw for multi-agent workflows — Run Claude Code as a persistent coding agent - Master effective prompts — Get the most out of Claude Code - Add MCP servers — Extend Claude Code with custom tools

---

Looking for more? Check out our complete Claude Code guide collection.

Ad Unit Placeholder

Related Articles