Prerequisites
- Node.js 18+ — check with
node --version - npm or npx — bundled with Node.js
- Anthropic account — free to create at anthropic.com
- Terminal — macOS Terminal, iTerm2, Windows Terminal (WSL2), or Linux shell
Step-by-Step Installation
-
Install Claude Code globally
npm install -g @anthropic-ai/claude-code # Or with npx (no install required): npx @anthropic-ai/claude-code
The global install creates the
claudecommand available everywhere in your terminal.Check your version: Runclaude --versionafter install. Claude Code updates frequently — re-run the install command to upgrade. -
Navigate to your project and start Claude Code
cd ~/your-project claude
Always run
claudefrom inside your project directory. Claude Code reads your project structure and the localCLAUDE.mdfile from this directory. -
Authenticate
On first run, Claude Code offers two authentication options:
- Browser OAuth (recommended for individuals) — opens claude.ai in your browser, uses your existing subscription. No API key management needed.
- API key — set
ANTHROPIC_API_KEYin your environment. Best for teams, CI/CD, or programmatic use.
# Option B: API key authentication export ANTHROPIC_API_KEY="sk-ant-..." # Add to ~/.bashrc or ~/.zshrc for persistence
API key location: Create keys at console.anthropic.com → API Keys. Use a project-scoped key for each codebase if you want separate billing. -
Generate your CLAUDE.md
Once inside a Claude Code session, run:
/initClaude reads your codebase and generates a
CLAUDE.mdfile with project context, conventions it inferred, and suggested rules. Review and edit it — the better yourCLAUDE.md, the better every future session.What to put in CLAUDE.md: Architecture overview, naming conventions, testing requirements ("always add tests for new functions"), commands to run before committing, files/dirs Claude should avoid modifying. -
Run your first task
> Find all TODO comments in the codebase and create a GitHub issue template listing them Claude: Reading codebase structure... Claude: Found 12 TODO comments across 7 files Claude: Creating issue-template.md... Claude: Done — created ISSUE_TEMPLATE/todo-audit.md
Start with a concrete, well-scoped task. Claude will ask for permission before making changes — approve selectively to build trust with its capabilities.
Configure Tool Permissions
Claude Code asks permission for every tool call by default. You can pre-approve common safe operations in .claude/settings.json:
// .claude/settings.json
{
"permissions": {
"allow": [
"Bash(git status)",
"Bash(git diff*)",
"Bash(npm test*)",
"Bash(npm run lint*)",
"Read(**/*)"
]
}
}
Bash(*) permission — it lets Claude run any shell command without prompting.Optional: Install MCP Servers
MCP (Model Context Protocol) servers extend Claude Code with external tools. Common ones:
# GitHub MCP — read/write PRs, issues, repos claude mcp add github -- npx -y @modelcontextprotocol/server-github # Filesystem MCP — granular file access control claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem /your/path # Postgres MCP — read your database schema + run queries claude mcp add postgres -- npx -y @modelcontextprotocol/server-postgres postgresql://...
Optional: Set Up Hooks
Hooks let you run shell commands automatically when Claude takes specific actions. Add them in .claude/settings.json:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
// Run prettier on every file Claude edits
"command": "npx prettier --write \"$CLAUDE_TOOL_INPUT_FILE_PATH\" 2>/dev/null || true"
}
]
}
]
}
}
See the full hooks guide for pre/post-tool hooks, stop hooks, and notification hooks.
Verify Your Setup
# Check Claude Code version claude --version # List configured MCP servers claude mcp list # Inside a session: check your context /status
Explore Everything Claude Code Can Do
Skills, hooks, MCP servers, slash commands, comparison guides — all in one place.
Open Claude Skills Browser →