C.W.K.
Stream
Lesson 01 of 13 · published

Install & Authenticate

~14 min · install, auth, oauth, api-key

Level 0🌱 Novice
0 XP0/70 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

One npm install, three auth paths

Claude Code is a single npm package — @anthropic-ai/claude-code. Once installed it's claude on your PATH. The interesting choice is authentication, because it determines how you're billed and how your sessions get tracked.

OAuth via Claude Max / Pro. Run claude, follow the browser flow, done. Token lives in ~/.claude.json. Best for individuals — your usage rolls up under the same subscription as Claude.ai. No API key to rotate, no env var to forget.

API key. Set ANTHROPIC_API_KEY in the environment. Pay-as-you-go billing, programmatic key rotation, what every CI server uses. Treat the key like a deploy credential — never commit, always inject.

Cloud provider routing. CLAUDE_CODE_USE_BEDROCK=1 or CLAUDE_CODE_USE_VERTEX=1 route through AWS Bedrock or Google Vertex AI. Enterprises use this when their data-residency or procurement story requires the model to live behind their cloud account.

After install, claude doctor is your first stop for any "it doesn't work" question — it checks node version, PATH, auth, and connectivity in one command.

Code

Install on a fresh machine·bash
# Prereqs
node --version    # 18+
npm --version

# Install globally
npm install -g @anthropic-ai/claude-code

# First run — triggers OAuth in browser if no API key set
cd ~/myproject
claude

# Health check
claude doctor
API key path (CI / servers / fleet)·bash
# Persistent in shell
echo 'export ANTHROPIC_API_KEY="sk-ant-..."' >> ~/.zshrc
source ~/.zshrc

# Or via direnv per-project (.envrc, gitignored)
echo 'export ANTHROPIC_API_KEY="sk-ant-..."' >> .envrc
direnv allow

# CI: never echo the key, never log it
# GitHub Actions: ${{ secrets.ANTHROPIC_API_KEY }}

External links

Exercise

Install Claude Code, authenticate via the path that fits your situation (OAuth if subscriber, API key if not), and run claude doctor. Copy its output into your notes — that's your installation receipt for any future debugging.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.