Claude Code CLI
From zero to productive. Install, configure, save tokens, and write quality code — the complete guide for test automation engineers and developers who want to vibe code with AI.
Node.js v18+ (use nvm to manage versions) and a paid Claude plan — Pro ($20/mo), Max 5x ($100/mo), Max 20x ($200/mo), or an API key.
# Install globally $ npm install -g @anthropic-ai/claude-code # Navigate to your project $ cd ~/playwright-project # Start Claude Code — browser opens for auth on first run $ claude # Or: use API key instead of subscription $ export ANTHROPIC_API_KEY="sk-ant-..." $ claude
/init to generate a starter CLAUDE.md. Then customize it with your project's stack, commands, and conventions.Claude Code ships new features weekly and the model aliases only resolve correctly on a recent build (Sonnet 5's 1M window, for example, needs v2.1.193+). The native installer and npm global install auto-update in the background on startup — updates take effect the next time you launch. Homebrew, WinGet, and Linux package managers do not auto-update, and claude update does nothing on them — you upgrade through the package manager itself (Homebrew users: brew upgrade --cask claude-code).
# See which version you're on $ claude --version # Update now — don't wait for the background check (native + npm installs) $ claude update # npm global install: upgrade explicitly. # Avoid `npm update -g` — it respects the old semver range and may not bump. $ npm install -g @anthropic-ai/claude-code@latest # Homebrew / WinGet don't auto-update — upgrade manually. # On these installs `claude update` silently does nothing; use the package manager. $ brew upgrade --cask claude-code # Claude Code is a cask — the --cask flag is required > winget upgrade Anthropic.ClaudeCode # Diagnose the install + see the result of the last auto-update attempt $ claude doctor
| Install Method | Auto-Updates? | Manual Update |
|---|---|---|
| Native installer (recommended) | ✅ background | claude update |
| npm global | ✅ background | npm install -g @anthropic-ai/claude-code@latest |
| Homebrew | manual | brew upgrade --cask claude-code |
| WinGet | manual | winget upgrade Anthropic.ClaudeCode |
| apt / dnf / apk | manual | system upgrade (e.g. apt upgrade claude-code) |
settings.json (or /config → Auto-update channel):"autoUpdatesChannel": "latest"(default) — new features as soon as they ship."stable"— a build ~1 week old that skips releases with major regressions."minimumVersion": "2.1.100"— a floor; updates never install below it, so switching to stable won't downgrade you.- Disable the background check with
"env": { "DISABLE_AUTOUPDATER": "1" }(claude updatestill works). UseDISABLE_UPDATESto block every update path, including manual.
| Plan | Price | Default Model | Best For |
|---|---|---|---|
| Free | $0 | — | Trying Claude Code · usage limits apply |
| Pro | $20/mo ($17 annual) | Sonnet 5 | Learning, daily light usage |
| Max 5x | $100/mo | Opus 4.8 | Daily development |
| Max 20x | $200/mo | Opus 4.8 | Heavy professional use · Dynamic Workflows |
| Team Standard | $20/seat/mo | Sonnet 5 | Small teams |
| Team Premium | $100/seat/mo | Opus 4.8 | Teams doing heavy agentic work |
| Enterprise | Custom · $20/seat + usage | Opus 4.8 (pay-as-you-go) | Org-wide · SSO · spend controls |
| API | Per token | You choose | CI/CD, automation |
What you actually get on each plan. Model access is controlled by aliases (opus, sonnet, haiku, fable) that resolve to a different concrete model depending on your account type — see Selecting a Model below.
| Feature | Free | Pro | Max 5x | Max 20x | Team | Enterprise | API |
|---|---|---|---|---|---|---|---|
| Claude Code (CLI / Desktop / VS Code) | ✅* | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Sonnet 5 (sonnet alias) | — | ✅ default | ✅ | ✅ | Standard: default | ✅ | ✅ |
| Opus 4.8 (opus alias) | — | ✅ | ✅ default | ✅ default | Premium: default | ✅ default | ✅ |
| Haiku 4.5 (haiku alias) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Fable 5 (fable alias, opt-in via /model fable) | — | ✅ | ✅ | ✅ | ✅ | ✅† | ✅ |
| Opus 4.8 Fast mode ($10/$50) | — | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Dynamic Workflows (/workflows, ultracode) | — | via /config | ✅ | ✅ | ✅ | ✅ | ✅ |
| 1M context — Opus | — | usage credits | included | included | included | included | full access |
| 1M context — Sonnet 5 | n/a — always 1M | n/a — always 1M | n/a — always 1M | n/a — always 1M | n/a — always 1M | n/a — always 1M | n/a — always 1M |
| SSO / admin / audit logs | — | — | — | — | basic | SCIM + HIPAA | — |
/model picker omits or disables it for those orgs.Checking usage: run
/usage inside a session for a plan-usage breakdown (skills, subagents, MCP servers), or /status for account + current model. Shared pool: Pro / Max usage is one counter across Claude chat and Claude Code. On Pro / Max you can also raise a monthly cap with /usage-credits.| Model | Input / 1M tok | Output / 1M tok | When to Use |
|---|---|---|---|
| Fable 5 (claude-fable-5) | $10.00 | $50.00 | Hardest, longest-running agentic tasks — investigates, verifies, and self-corrects with less prompting |
| Opus 4.8 (claude-opus-4-8) | $5.00 | $25.00 | Complex architecture, hard debugging — flagship for coding |
| Opus 4.8 (Fast mode) | $10.00 | $50.00 | Same Opus quality at ~2.5× speed |
| Sonnet 5 (claude-sonnet-5) | $3.00 ($2 intro¹) | $15.00 ($10 intro¹) | Daily coding — new default, best speed/intelligence balance |
| Haiku 4.5 (claude-haiku-4-5) | $1.00 | $5.00 | Quick lookups, simple edits, subagents |
¹ Sonnet 5's introductory pricing runs through Aug 31, 2026, then reverts to standard $3/$15. Previous-generation models (Opus 4.7, Opus 4.6, Sonnet 4.6, Opus 4.5, Sonnet 4.5) are still callable by full model ID if you need to pin a version, but Fable 5 / Opus 4.8 / Sonnet 5 / Haiku 4.5 are the recommended picks going forward.
Four ways to set the model, in priority order (highest wins) — per Anthropic's model configuration guide:
| # | Method | Scope |
|---|---|---|
| 1 | /model <alias|name> (in-session) | Immediate switch; with no argument opens the picker. Saves as your default for new sessions |
| 2 | claude --model <alias|name> | This launch only |
| 3 | ANTHROPIC_MODEL=<alias|name> | This launch only (env var) |
| 4 | "model" field in settings.json | Permanent, until changed |
# Aliases resolve to the current recommended model for your account — # they update automatically as new models ship. $ claude --model sonnet # Sonnet 5 on the API/Pro; Sonnet 4.6 on Bedrock/Vertex/Foundry $ claude --model opus # Opus 4.8 on the API; Opus 4.7 on Claude Platform on AWS $ claude --model haiku # Haiku 4.5 everywhere $ claude --model fable # Fable 5 — hardest, longest-running tasks (not default anywhere) # Pin an exact version instead of an alias (recommended for CI/CD): $ claude --model claude-sonnet-5 $ claude --model claude-opus-4-8 # opusplan: Opus for planning, Sonnet for execution — best of both $ claude --model opusplan # Check what's active right now $ claude > /status
default, best, opus, sonnet, haiku, fable, opusplan never hardcode a version — pin an exact model ID (e.g. claude-opus-4-8) in CI/CD or team settings so a Claude update doesn't silently change your pipeline's behavior.The context window is how much Claude can "see" at once — every CLAUDE.md, every file read, and the whole conversation counts against it. When it fills, Claude auto-compacts (summarizes) to keep going.
| Model | Context | Notes |
|---|---|---|
| Fable 5 | 1M tokens | Always 1M on the Anthropic API |
| Opus 4.8 | 1M tokens | 1M on API; on Max/Team/Enterprise auto-upgraded to 1M — on Pro needs usage credits |
| Sonnet 5 | 1M tokens | Always 1M on API — no 200K variant, no [1m] suffix, no usage credits on any plan. Auto-compacts at ~967K |
| Haiku 4.5 | 200K tokens | No 1M variant |
- Old Claude Code version — Sonnet 5 needs v2.1.193+. Run
claude update, then checkclaude --version. CLAUDE_CODE_DISABLE_1M_CONTEXT=1is set — unset it to restore the full 1M window.- Behind an LLM gateway (
ANTHROPIC_BASE_URLpoints at one) — Claude Code can't verify 1M support, so it caps at 200K. Pick "Sonnet 5 (1M context)" in the/modelpicker (aliassonnet[1m]).
/context to see exactly what's eating the window, and /clear before switching if you don't need the history.# Force the 1M window on an alias or full model name /model sonnet[1m] /model opus[1m] /model claude-opus-4-8[1m] # See what's consuming the context window right now /context # Change the auto-compact threshold for Sonnet 5's 1M window (default ~967K) $ export CLAUDE_CODE_AUTO_COMPACT_WINDOW=800000 # Cap Sonnet 5 at a 200K window on purpose (e.g. to bound cost) $ export CLAUDE_CODE_DISABLE_1M_CONTEXT=1
# Interactive session $ claude # One-shot: single prompt, get answer, exit $ claude -p "explain the page object pattern in tests/pages/" # Continue last conversation $ claude --continue # or -c # Pick from recent sessions $ claude --resume # or -r # Pipe input $ cat test-results/errors.log | claude -p "explain these test failures" # JSON output for scripting $ claude -p "list all spec files" --output-format json # Specify model — alias or full ID (see Pricing & Models → Selecting a Model) $ claude --model sonnet # Sonnet 5 — daily coding, default on Pro $ claude --model opus # Opus 4.8 — flagship for complex tasks $ claude --model fable # Fable 5 — hardest, longest-running tasks
| Flag | Action | Recommendation |
|---|---|---|
| --append-system-prompt "text" | Add to defaults | USE THIS |
| --append-system-prompt-file path | Append from file | USE THIS |
| --system-prompt "text" | Replace ALL defaults | CAREFUL |
| --system-prompt-file path | Replace from file | CAREFUL |
# Best practice: append rules for Playwright project $ claude --append-system-prompt "Always use Page Object Model. Import test from src/fixtures/base.fixture.ts, not @playwright/test." # CI/CD: run with rules from file $ claude -p "review tests/" --append-system-prompt-file .claude/ci-rules.md
# Allow specific tools $ claude --allowedTools "Read,Grep,Glob,Write,Edit" # YOLO mode — skip all prompts (containers only!) $ claude --dangerously-skip-permissions
Type these inside a running Claude Code session.
| Command | What It Does | Example / Tip |
|---|---|---|
| /clear | Wipe context — fresh start | Use between unrelated tasks! |
| /compact | Summarize & reduce tokens | /compact focus on page objects |
| /model | Switch AI model (aliases or full ID) | /model sonnet · /model claude-haiku-4-5 |
| /effort | Set reasoning depth: low/medium/high/xhigh/max/ultracode | /effort high — default on Fable 5, Sonnet 5, Opus 4.8 |
| /fast | Toggle Opus 4.8 fast mode (~2.5× speed, $10/$50 per 1M) | For quick iterations |
| /plan (Shift+Tab) | Plan mode — explore & propose before editing | For complex refactors |
| /review | Code review current changes | Before committing |
| /rewind | Undo to any checkpoint | Also: double-tap Esc |
| Command | What It Does |
|---|---|
| /rename | Name session: /rename playwright-auth-refactor |
| /export | Save conversation to file |
| /todos | List tracked TODO items |
| /add-dir | Add extra directories: /add-dir ~/api-project |
| /usage | Plan usage breakdown (skills, subagents, MCP servers) |
| /status | Current model + account info |
| /doctor | Health check installation |
| /permissions | Manage allowed tools & commands |
| /output-style | Change response formatting |
| Shortcut | Action |
|---|---|
| Enter | Send message |
| Shift + Enter | New line |
| Shift + Tab | Cycle: Normal → Auto-accept → Plan mode |
| Option/Alt + T | Toggle extended thinking for this session |
| Ctrl + O | Toggle verbose thinking output |
| Esc | Cancel current generation |
| Esc Esc | Open rewind menu |
| Ctrl + C | Exit Claude Code |
| Ctrl + L | Clear screen (not context) |
| ↑ | Recall previous message |
/keybindings → opens ~/.claude/keybindings.json. Changes apply instantly.Claude Code uses a layered system. Higher specificity wins. Understanding this is key to making Claude write code the way you want.
~/.claude/
CLAUDE.md ← Global: personal defaults for ALL projects
settings.json ← Global permissions, model preferences
keybindings.json ← Your keyboard shortcuts
./ (project root)
CLAUDE.md ← Project: team-shared (commit to git!)
CLAUDE.local.md ← Project: personal overrides (gitignored)
.claudeignore ← Files Claude should never read
./.claude/
settings.json ← Project settings (hooks, permissions)
skills/
SKILL.md ← Project-wide skill
playwright/
SKILL.md ← Domain-specific skill
./tests/
CLAUDE.md ← Directory-level: rules only for tests/This is the single most important file for code quality. It's your pair programmer's briefing. The golden rule: for each line, ask "Would removing this cause Claude to make mistakes?" If not, delete it.
~3,500 words max. Every token is re-consumed every message. Bloated CLAUDE.md = wasted money.
"Use data-testid for selectors" beats a paragraph explaining why test-ids are preferred.
Build, test, lint commands prevent Claude from guessing and wasting tokens exploring.
Found a new gotcha? Add it. Found a rule Claude already follows? Remove it.
# Playwright E2E Test Framework
## Stack
Playwright 1.50+ · TypeScript 5.6+ · Faker.js · dotenv
## Commands
npm test # run all tests
npm run test:ui # Playwright UI mode
npm run test:chrome # chromium only
npm run lint # ESLint check
npm run typecheck # TypeScript strict check
## Architecture
src/pages/ — Page Objects (extend BasePage)
src/fixtures/ — Custom Playwright fixtures (DI)
src/api/ — API client classes
src/utils/ — Env config, helpers, test data generator
src/data/ — Static test data, routes, users
tests/ — Test specs by feature
## Critical Rules
- ALWAYS import { test, expect } from `src/fixtures/base.fixture.ts`
NOT from `@playwright/test`
- Use `data-testid` for selectors, never CSS classes
- Page objects: locators as readonly props, actions as methods
- Env vars via `src/utils/env.config.ts` — never hardcode
- Auth handled by `tests/auth.setup.ts` — tests start authenticated
## Naming
Files: kebab-case · Classes: PascalCase · Test IDs: kebab-case
Tests: start with "should" — "should login with valid credentials"
## Gotchas
- page.waitForTimeout() is an anti-pattern — use expect/waitForURL
- API tests don't use storageState — they get own token in beforeAll
- Never commit page.pause() — debug onlySkills are markdown instructions that Claude loads automatically when relevant. Unlike slash commands, Claude decides when to use them based on your request.
.claude/skills/
SKILL.md ← Main project skill (auto-loaded)
playwright-tests/
SKILL.md ← Activated: "write a test", "fix spec"
api-testing/
SKILL.md ← Activated: "API test", "endpoint test"
code-review/
SKILL.md ← Activated: "review this", "check quality"--- name: playwright-tests description: > Activated when writing, fixing, or modifying Playwright tests. Triggers: test, spec, e2e, playwright, page object, fixture. --- # Playwright Test Guidelines ## Creating a New Test 1. Does it need auth? Import from the correct fixture: - Auth tests → `src/fixtures/auth.fixture.ts` - Regular tests → `src/fixtures/base.fixture.ts` - API only → `@playwright/test` directly 2. Create page object first if it doesn't exist: - Extend `BasePage` from `src/pages/base.page.ts` - Locators = readonly properties via `this.byTestId()` - Actions = methods, Assertions = `expectX()` methods 3. Register page object in `src/fixtures/base.fixture.ts` ## Locator Priority 1. getByTestId() ← most reliable 2. getByRole() ← semantic 3. getByText() ← visible text 4. getByLabel() ← form fields 5. locator() ← last resort ## Anti-Patterns ✗ page.waitForTimeout(ms) — use auto-waiting ✗ Hardcoded URLs — use ROUTES from data/routes ✗ Hardcoded creds — use USERS from data/users ✗ page.pause() in committed code
You: "Write a test for the checkout page" → Claude loads playwright-tests skill → Follows patterns from the skill
You: /playwright-tests login.spec.ts → Directly loads and applies skill → Useful for forcing specific behavior
Unlike prompts (which Claude may skip), hooks always execute. Use them for things that must happen every time — linting, type-checking, truncating output.
| Hook | When It Fires | Example Use |
|---|---|---|
| session-start | New session begins | Load context, check dependencies |
| post-edit | After Claude edits a file | Auto-lint, auto-format |
| pre-commit | Before Claude commits | Type-check, run affected tests |
{
"hooks": {
"post-edit": [
{
"command": "npx eslint --fix $FILE 2>/dev/null || true",
"description": "Auto-fix lint after every edit"
}
],
"pre-commit": [
{
"command": "npm run typecheck && npx playwright test --reporter=list 2>&1 | tail -20",
"description": "Type-check + quick test before commit"
}
]
}
}| tail -20 or | head -50 prevent massive test logs from flooding your context window and eating tokens.Graduated from research preview to a full feature. A dynamic workflow is a JavaScript script Claude writes that orchestrates subagents at scale — Claude plans the script, a runtime executes it in the background (your session stays responsive), and each agent runs in its own clean context. Designed for codebase-wide audits, large migrations, and research that needs cross-checked sources — cases where a single conversation can't hold the whole plan.
| Plan | Status | Notes |
|---|---|---|
| Pro | Opt-in | Turn on the Dynamic workflows row in /config |
| Max 5x | Available | Counts toward your plan usage like any session |
| Max 20x | Available | Recommended tier for large migrations |
| Team | Available | Admin can disable org-wide |
| Enterprise | Available | Toggle in Claude Code admin settings |
| API | Available | Via Agent SDK's Workflow tool / non-interactive mode |
| Free | — | Not available |
# 1. Ask for one directly — include the keyword "ultracode" (or say # "use a workflow" in your own words) > ultracode: migrate 240 spec files from Playwright 1.40 to 1.50 API, one subagent per directory under tests/. Each subagent should update imports, replace page.waitForTimeout() with explicit waits, run the suite for that dir, and report files touched + blockers. # 2. Let Claude decide for every substantive task this session /effort ultracode # Monitor any run: phases, agent count, tokens, elapsed time /workflows # Built-in workflow for cross-checked research /deep-research "What changed in Playwright's clock API between 1.40 and 1.50?"
/command with s in the /workflows view.Claude's context window fills up fast, and performance degrades as it fills. Managing tokens is the difference between hitting your limit in 1 hour vs. working all day.
# Don't wait for auto-compact at 95%. Do it manually at ~70%: /compact focus on the auth setup refactoring decisions # You can specify what to keep: /compact keep only the page object patterns and fixture changes
# Prevent Claude from reading these — saves thousands of tokens node_modules/ dist/ build/ playwright-report/ test-results/ blob-report/ coverage/ *.lock *.min.js *.min.css *.map *.log
| Task | Model | Cost |
|---|---|---|
| Hardest/longest-running refactors, ambiguous root-cause bugs | Fable 5 | 10× |
| Design fixture architecture, complex debugging | Opus 4.8 | 5× |
| Write page objects & tests | Sonnet 5 | 1× |
| Find a file, quick question | Haiku 4.5 | 0.2× |
# Switch in-session (aliases resolve to the current recommended model): /model haiku # for exploration /model sonnet # back to normal work /model opus # for the hard part /model fable # for the hardest, longest-running part # Reasoning depth is a separate, complementary lever: /effort low # short/scoped tasks, latency-sensitive /effort high # default on Fable 5, Sonnet 5, Opus 4.8 — balanced /effort ultracode # plans a dynamic workflow for every substantive task
# Subagent gets its own clean context — doesn't pollute yours > Use a subagent to explore the src/api/ directory and report: what endpoints exist, error handling patterns, and whether we have retry logic. # Claude spawns a focused agent, explores, reports back # Your main context stays clean
Every token is consumed every single session. A 2,000-token CLAUDE.md costs ~$0.006/session with Sonnet. At 100 sessions/day across 5 devs, that's $9/month just for reading CLAUDE.md. If it's 10K tokens → $45/month on context alone.
/rename playwright-auth-refactor /rename adding-checkout-page-object # Later, resume by name — no need to re-explain context: $ claude --resume
# Picks up exactly where you left off — zero re-explanation needed $ claude --continue # or: claude -c
# In-session breakdown (skills, subagents, MCP servers, session cost): /usage # Authoritative billing (API workspaces): https://platform.claude.com/usage # Rule: compact at 70%, /clear at task boundaries
Here is every file you need to create in a new Playwright project to make Claude Code write production-quality code from day one.
playwright-project/
CLAUDE.md ← Project brain (section above)
CLAUDE.local.md ← Your personal overrides (.gitignored)
.claudeignore ← Exclusions (section above)
.claude/
settings.json ← Hooks + permissions (hooks section)
skills/
playwright-tests/
SKILL.md ← Test writing skill (skills section)
.eslintrc.json ← Linting rules Claude follows
tsconfig.json ← TypeScript strict mode config
prettier.config.js ← Formatting rules
.editorconfig ← Editor settings
.env.example ← Template for environment vars
.gitignore ← Include .env, auth/, reports/
playwright.config.ts ← Multi-project Playwright config{
"model": "sonnet",
"permissions": {
"allow": [
"Read", "Glob", "Grep", "Write", "Edit",
"Bash(npm run *)",
"Bash(npx *)",
"Bash(git *)"
],
"deny": [
"Bash(rm -rf *)",
"Bash(sudo *)"
]
},
"hooks": {
"post-edit": [{
"command": "npx eslint --fix $FILE 2>/dev/null || true",
"description": "Auto-lint after every edit"
}],
"pre-commit": [{
"command": "npm run typecheck && npm run lint",
"description": "Quality gate before commit"
}]
}
}- 1Create config files
Copy CLAUDE.md, .claudeignore, skills, settings.json, and .env.example from this guide. Commit everything except .env and CLAUDE.local.md.
- 2Launch Claude Code
cd playwright-project && claude — Claude automatically reads CLAUDE.md, loads skills, applies hooks.
- 3Describe what you need
"Create a page object for the checkout page with add-to-cart, remove-item, and proceed-to-payment actions. Then write tests for happy path and empty cart."
- 4Claude follows your patterns
Because of your CLAUDE.md and skill file, Claude automatically uses BasePage, fixtures, test-ids, correct imports, and your naming conventions.
- 5Hooks auto-validate
post-edit runs ESLint auto-fix. pre-commit runs type-check + lint. Quality is enforced without you asking.
Most install and version weirdness comes down to which claude binary your shell actually runs. Start every diagnosis with these four commands — the real path tells you which package manager owns the install, and therefore how to update it.
# 1. Which binary runs — and are there several on your PATH? $ which -a claude # 2. Follow it to the real install (reveals Homebrew cask / npm / native) $ readlink -f "$(which claude)" # 3. Your running build vs. the latest published on npm $ claude --version $ npm view @anthropic-ai/claude-code version # 4. One-shot health check: install method, auth, last auto-update attempt $ claude doctor
| Symptom | Likely Cause | Where to Fix |
|---|---|---|
| Updated, but --version stays old | The claude on PATH isn't the one you updated — another install shadows it | ↓ Version won't update |
| npm install -g does nothing | A Homebrew cask at /opt/homebrew/bin/claude shadows the npm binary | ↓ Version won't update |
| brew upgrade says “already latest”, npm has newer | Homebrew cask trails the npm release by ~1–2 days | ↓ Version won't update |
| claude: command not found after nvm use | Global install lives inside one Node version's bin dir | ↓ nvm: claude vanished |
| On Pro/Max but usage burns API credits | ANTHROPIC_API_KEY in your env overrides the subscription | ↓ Auth & billing |
| Sonnet 5 context bar jumps to 100% | Session budgeted at 200K instead of 1M | ↑ Context Windows (§02) |
The classic trap: you run an update command, it reports success, but claude --version is unchanged — because the claude on your PATH is a different install than the one you upgraded. On macOS the usual culprit is a Homebrew cask at /opt/homebrew/bin/claude, which sits earlier on PATH than the npm global binary and quietly wins. Read the real path, then update with the manager that owns it.
| readlink -f shows… | Install Method | Correct Update Command |
|---|---|---|
| …/Caskroom/claude-code/… | Homebrew cask | brew upgrade --cask claude-code |
| …/node_modules/@anthropic-ai/claude-code/… | npm global | npm install -g @anthropic-ai/claude-code@latest |
| ~/.local/… or ~/.claude/… (single binary) | Native installer | claude update |
claude-code cask definition trails the npm release by a day or two, so a fresh version (say 2.1.201) can still be unavailable via Homebrew while brew upgrade keeps calling 2.1.193 current. That's expected — either wait for the cask to catch up, or switch to npm / the native installer to get releases the day they ship.claude --version.A global npm install lives inside a single Node version's directory. Switch Node with nvm use (or open a shell where a different version is default) and that bin/ leaves your PATH — so claude looks like it vanished.
# A global install lives inside ONE Node version: # ~/.nvm/versions/node/v24.12.0/bin/claude # After `nvm use 20` that bin dir leaves PATH and claude "disappears". # Fix A — pin a default Node so the same install stays on PATH $ nvm alias default 24 # Fix B — (re)install under whichever Node you actually run $ nvm use 24 && npm install -g @anthropic-ai/claude-code@latest
If you're on Pro or Max but your usage drains API credits, an ANTHROPIC_API_KEY in your environment is overriding the subscription. A key exported from a shell profile silently wins over /login.
# Is a key set that you didn't mean to use? $ echo $ANTHROPIC_API_KEY # Use your subscription instead — unset, then relaunch $ unset ANTHROPIC_API_KEY # Inside a session: confirm active auth + model > /status # Switch or refresh the browser login > /login
/status still shows API billing after unsetting the variable, check ~/.zshrc / ~/.bashrc for a lingering export ANTHROPIC_API_KEY.Always check official sources for the latest updates. This guide reflects the state as of July 2026: Claude Sonnet 5 is the new default balanced model on Pro / Team Standard (introductory pricing $2/$10 per MTok through Aug 31, 2026); Opus 4.8 remains the default on Max / Team Premium / Enterprise pay-as-you-go / API; Claude Fable 5 is generally available (launched June 9, 2026) as an opt-in model for the hardest, longest-running tasks — select it with /model fable.