ailiteracynepal 🇳🇵
Text size

Chapter 01 · Section I · 10 min read

1.1 Setup: install, authenticate, update

Every install path for Claude Code in one place: the recommended npm route, the platform-specific alternatives, first-time authentication, and how to keep the CLI current without breaking a workflow.

Claude Code ships as a Node package with a single binary called claude. This section is the fastest path from a fresh machine to a working session, plus the two follow-ups you actually need — authentication and updates.

Installation methods

Recommended: npm global install. Works on macOS, Linux, and Windows/WSL.

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

Alternative: package managers. Homebrew, apt, and similar have community-maintained recipes. They lag the npm channel by days to weeks; fine for stability, not for the newest features.

Local project install. For a project that pins its Claude Code version:

npm install --save-dev @anthropic-ai/claude-code
npx claude

Handy for CI, or for a monorepo whose contributors should all be on the same CLI version.

Authentication

Two options, pick one:

  • Console login (recommended). Run claude once; it opens a browser tab, you sign in with your Anthropic account, and a token is written to ~/.claude/config.
  • API key env var. For remote / headless environments where a browser is not available:
export ANTHROPIC_API_KEY=sk-ant-api03-...
claude

Update management

npm update -g @anthropic-ai/claude-code
claude --version

For pinned CI installs, bump the version in package.json and let your existing dep-update PR flow carry it. Do not auto-update in the middle of a long-running loop or scheduled job — a version bump can change tool schemas.

Check your understanding

Quick check

Which install path is best for a CI job that must run the same Claude Code version every time?