Skip to main content

Requirements

  • Node.js 18 or higher — Claude Code checks the Node.js version at startup and exits with an error if the requirement is not met.
  • npm — used to install the package. Yarn and pnpm also work.
Claude Code uses Bun as its internal runtime and bundler. Bun is bundled into the distributed npm package — you do not need to install Bun separately.

Install

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

Platform notes

Claude Code integrates with the macOS Keychain to store OAuth tokens and API keys securely. On first authentication, macOS will prompt you to allow Keychain access.The startup sequence prefetches Keychain reads in parallel to minimize latency (keychainPrefetch.ts). If you use an MDM-managed device, Claude Code also reads MDM policy settings at startup via plutil.Apple Terminal backup/restore is supported — Claude Code saves and restores terminal state on session start and end.

Environment variables

These environment variables configure Claude Code’s behavior. Set them in your shell profile or pass them inline before the claude command.
VariableDescription
ANTHROPIC_API_KEYPrimary authentication method. Set this to your Anthropic API key to bypass the OAuth flow.
ANTHROPIC_BASE_URLOverride the default Anthropic API endpoint. Use this to point at a proxy, a custom gateway, or a compatible alternative API.
CLAUDE_CODE_MAX_OUTPUT_TOKENSOverride the maximum output tokens per model response. Useful for tasks that require longer completions than the default limit.
DISABLE_INTERLEAVED_THINKINGSet to 1 to disable extended (interleaved) thinking. Extended thinking allows Claude to reason through complex problems before responding.
To persist environment variables across sessions, add them to your shell profile (e.g., ~/.zshrc, ~/.bashrc, or ~/.profile).

Verify installation

Confirm the binary is available and check the installed version:
claude --version
Run the built-in diagnostics to verify authentication, connectivity, and configuration:
claude /doctor
The /doctor command checks your Node.js version, authentication status, API connectivity, and reports any configuration issues.

Upgrade

To upgrade to the latest version:
npm update -g @anthropic-ai/claude-code
Claude Code also supports an auto-updater that can be controlled via the isAutoUpdaterDisabled configuration setting.

Uninstall

To remove Claude Code:
npm uninstall -g @anthropic-ai/claude-code
This removes the claude binary from your PATH. Configuration files and session history stored in your home directory are not removed automatically.

Build docs developers (and LLMs) love