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.
01Installation & First Launch
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 & Launch
# 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.Updating & Staying Current
Claude Code ships new features weekly and the model aliases only resolve correctly on a recent build (Opus 5.5 needs v2.1.280+, Sonnet 5.5 v2.1.284+ and Haiku 5.5 v2.1.293+). 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.
02Pricing & Models
Plans
| Plan | Price | Default Model | Best For |
|---|---|---|---|
| Free | $0 | - | Trying Claude Code · usage limits apply |
| Pro | $20/mo ($17 annual) | Opus 5.5 | Learning, daily light usage |
| Max 5x | $100/mo | Opus 5.5 | Daily development |
| Max 20x | $200/mo | Opus 5.5 | Heavy professional use · Dynamic Workflows |
| Team Standard | $20/seat/mo | Opus 5.5 | Small teams |
| Team Premium | $100/seat/mo | Opus 5.5 | Teams doing heavy agentic work |
| Enterprise | Custom · $20/seat + usage | Opus 5.5 | Org-wide · SSO · spend controls |
| API | Per token | You choose | CI/CD, automation |
claude update if /model doesn't list it.Plan ↔ Feature Matrix
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) | ✅* | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Opus 5.5 (opus alias) | - | ✅ default | ✅ default | ✅ default | ✅ default | ✅ default | ✅ default |
| Sonnet 5.5 (sonnet alias) | - | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Haiku 5.5 (haiku alias) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Fable 5.1 (fable alias, opt-in via /model fable) | - | ✅ | ✅ | ✅ | ✅ | ✅† | ✅ |
| Opus fast mode (Opus 5.5: $8/$40) | - | usage credits | usage credits | usage credits | Owner enables · credits | Owner enables · credits | access provisioned |
| Dynamic Workflows (/workflows, ultracode) | - | via /config | ✅ | ✅ | ✅ | ✅ | ✅ |
| 1M context: Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable | native 1M | native 1M | native 1M | native 1M | native 1M | native 1M | native 1M |
| 1M context: Opus 4.6 [1m] (legacy) | - | usage credits | included | included | included | included | full access |
| SSO / admin / audit logs | - | - | - | - | basic | SCIM + HIPAA | - |
/model picker omits or disables them and the server rejects the request regardless of client config; the best alias falls back to Opus there.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 Costs (API)
| Model | Input / 1M tok | Output / 1M tok | When to Use |
|---|---|---|---|
| Fable 5.1 (claude-fable-5-1) | $10.00 | $50.00 | Current Fable: hardest, longest-running agentic tasks; same base price as Fable 5 with cache reads at a quarter of the cost |
| Fable 5 (claude-fable-5) | $10.00 | $50.00 | Previous Fable: still callable by full model ID |
| Opus 5.5 (claude-opus-5-5) | $4.00 | $20.00 | Default model in Claude Code: coding and long-horizon agentic work, cheaper per token than Opus 5 |
| Opus 5.5 (Fast mode) | $8.00 | $40.00 | Same Opus 5.5 quality at up to 2.5× output speed; billed to usage credits on subscriptions |
| Opus 5 (claude-opus-5) | $5.00 | $25.00 | Previous Opus: still callable; pin it if you validated a pipeline against it |
| Sonnet 5.5 (claude-sonnet-5-5) | $2.00 | $10.00 | Daily coding: same price as Sonnet 5, 30%+ faster |
| Haiku 5.5 (claude-haiku-5-5) | $0.10 | $0.50 | Quick lookups, simple edits, subagents. $0.50 / $2.50 when the prompt is over 100K tokens |
The Claude 5.5 family shipped in three steps: Opus 5.5 on Sep 22, 2026 ($4/$20, cache reads $0.20 per MTok, needs v2.1.280+), Sonnet 5.5 on Sep 28 (same $2/$10 as Sonnet 5, needs v2.1.284+) and Haiku 5.5 on Oct 7 ($0.10/$0.50 up to a 100K-token prompt, $0.50/$2.50 above it, 1M context, needs v2.1.293+). All three default to medium effort in Claude Code, one step below the high default of earlier models: raise it with /effort when a task needs more depth. Fable 5.1 (Sep 1, 2026) keeps Fable 5's $10/$50 base rate but cuts cache reads from $1.00 to $0.25 per MTok and needs v2.1.257+. Previous-generation models (Opus 5, Sonnet 5, Haiku 4.5, Fable 5, Opus 4.8 and older) are still callable by full model ID if you need to pin a version.
Selecting a Model
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 opus # Opus 5.5 on the API, Claude Platform on AWS, Bedrock, Google Cloud (v2.1.280+)$ claude --model sonnet # Sonnet 5.5 on the Anthropic API (v2.1.284+); third-party providers can lag$ claude --model haiku # Haiku 5.5 on the Anthropic API (v2.1.293+)$ claude --model fable # Fable 5.1 on v2.1.257+ (Fable 5 before that), not default anywhere # Pin an exact version instead of an alias (recommended for CI/CD):$ claude --model claude-opus-5-5$ claude --model claude-sonnet-5-5$ claude --model claude-opus-5 # previous Opus, still callable # opusplan: Opus for planning, Sonnet for execution, best of both$ claude --model opusplan # Check what's active right now$ claude> /statusdefault, best, opus, sonnet, haiku, fable, opusplan never hardcode a version, and the concrete model behind one moves as the CLI updates: fable resolves to Fable 5.1 from v2.1.257 onward and to Fable 5 before it, and opus moved from Opus 5 to Opus 5.5 in v2.1.280. Pin an exact model ID (e.g. claude-opus-5-5) in CI/CD or team settings so a Claude update doesn't silently change your pipeline's behavior.Context Windows
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.1 / Fable 5 | 1M tokens | Always 1M on the Anthropic API. 128K max output |
| Opus 5.5 / Opus 5 | 1M tokens | Native 1M (Opus 4.7 and later): no [1m] suffix, no usage credits on any plan. 128K max output |
| Sonnet 5.5 / Sonnet 5 | 1M tokens | Native 1M on every provider: no 200K variant, no [1m] suffix, no usage credits |
| Haiku 5.5 | 1M tokens | Native 1M on every plan; prompts over 100K tokens bill at the higher rate. 128K max output |
| Opus 4.6 / Sonnet 4.6 | 200K or 1M | 1M only through the [1m] variant; Sonnet 4.6 [1m] needs usage credits on every plan |
- Old Claude Code version: Sonnet 5.5 needs v2.1.284+. 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 the "(1M context)" Sonnet row 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 behind a gateway, or on a model that needs the suffix# (no effect on models with a native 1M window, e.g. Opus 5.5 / Sonnet 5.5)/model sonnet[1m]/model opus[1m]/model claude-opus-4-6[1m] # See what's consuming the context window right now/context # Change the auto-compact threshold for a 1M window$ export CLAUDE_CODE_AUTO_COMPACT_WINDOW=800000 # Cap 1M models at a 200K window on purpose (e.g. to bound cost)$ export CLAUDE_CODE_DISABLE_1M_CONTEXT=103CLI Commands & Flags
Launch Modes
# 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 opus # Opus 5.5: the default, complex tasks$ claude --model sonnet # Sonnet 5.5: fast daily coding$ claude --model fable # Fable 5.1: hardest, longest-running tasksSystem Prompt Flags
| 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.mdPermission & Safety
# Allow specific tools$ claude --allowedTools "Read,Grep,Glob,Write,Edit" # YOLO mode: skip all prompts (containers only!)$ claude --dangerously-skip-permissions04Slash Commands
Type these inside a running Claude Code session.
Essential (daily use)
| 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 | medium: default on Opus 5.5, Sonnet 5.5, Haiku 5.5 · high: Fable 5.1 |
| /fast | Toggle Opus fast mode (up to 2.5× speed; Opus 5.5: $8/$40 per 1M, usage credits) | 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 |
Session Management
| 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 |
05Keyboard Shortcuts
| 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.06Configuration Hierarchy
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/07CLAUDE.md: Project Context
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.
Rules for an Effective CLAUDE.md
~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.
Example: Playwright + TypeScript Project
# Playwright E2E Test Framework ## StackPlaywright 1.50+ · TypeScript 5.6+ · Faker.js · dotenv ## Commandsnpm test # run all testsnpm run test:ui # Playwright UI modenpm run test:chrome # chromium onlynpm run lint # ESLint checknpm run typecheck # TypeScript strict check ## Architecturesrc/pages/ # Page Objects (extend BasePage)src/fixtures/ # Custom Playwright fixtures (DI)src/api/ # API client classessrc/utils/ # Env config, helpers, test data generatorsrc/data/ # Static test data, routes, userstests/ # 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 ## NamingFiles: kebab-case · Classes: PascalCase · Test IDs: kebab-caseTests: 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 only08Skills: Teach Claude Domain Knowledge
Skills are markdown instructions that Claude loads automatically when relevant. Unlike slash commands, Claude decides when to use them based on your request.
File Structure
.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"Skill Example: Playwright Test Writing
---name: playwright-testsdescription: > Activated when writing, fixing, or modifying Playwright tests. Triggers: test, spec, e2e, playwright, page object, fixture.--- # Playwright Test Guidelines ## Creating a New Test1. 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 Priority1. getByTestId() ← most reliable2. getByRole() ← semantic3. getByText() ← visible text4. getByLabel() ← form fields5. 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 codeHow Invocation Works
You: "Write a test for the checkout page"→ Claude loads playwright-tests skill→ Follows patterns from the skillYou: /playwright-tests login.spec.ts→ Directly loads and applies skill→ Useful for forcing specific behavior09Hooks: Run on Every Event
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 |
Setup for Playwright Project
{ "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.10Dynamic Workflows GA · all paid plans
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.
Eligibility
| 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 |
Two Ways to Trigger a Workflow
# 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.11Saving Tokens: 12 Commandments
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.
1. /clear Between Unrelated Tasks
2. /compact Proactively at 70%
# 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 changes3. Create a .claudeignore
# Prevent Claude from reading these: saves thousands of tokensnode_modules/dist/build/playwright-report/test-results/blob-report/coverage/*.lock*.min.js*.min.css*.map*.log4. Use the Right Model for the Task
| Task | Model | Cost |
|---|---|---|
| Hardest/longest-running refactors, ambiguous root-cause bugs | Fable 5.1 | 5× |
| Design fixture architecture, complex debugging | Opus 5.5 | 2× |
| Write page objects & tests | Sonnet 5.5 | 1× |
| Find a file, quick question | Haiku 5.5 | 0.05× |
# 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 medium # default on Opus 5.5, Sonnet 5.5, Haiku 5.5/effort high # default on Fable 5.1; raise 5.5 models here for harder work/effort xhigh # long agentic coding runs/effort ultracode # plans a dynamic workflow for every substantive task5. Be Specific in Prompts
6. Give Direct File Paths
7. Use Subagents for Exploration
# 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 clean8. Keep CLAUDE.md Under 5K Tokens
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.
9. Truncate Command Output
10. Name Sessions with /rename
/rename playwright-auth-refactor/rename adding-checkout-page-object # Later, resume by name: no need to re-explain context:$ claude --resume11. Use --continue When Resuming
# Picks up exactly where you left off: zero re-explanation needed$ claude --continue # or: claude -c12. Monitor Token Usage
# 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 boundaries12All Config Files for Quality Code
Here is every file you need to create in a new Playwright project to make Claude Code write production-quality code from day one.
Complete File Checklist
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.claude/settings.json: Complete
{ "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" }] }}The Quality Workflow
- 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.
13Troubleshooting & Common Problems
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 context bar jumps to 100% | Session budgeted at 200K instead of 1M | ↑ Context Windows (§02) |
Updated, but still on the old version
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.nvm: "claude: command not found" after switching Node
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@latestAuth & billing: subscription vs. API key
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.14References & Official Docs
Always check official sources for the latest updates. This guide reflects the state as of early October 2026: the Claude 5.5 family is current. Claude Opus 5.5 (launched September 22, 2026, $4 / $20 per MTok, Claude Code v2.1.280+) is the default model on every plan and on the API; Claude Sonnet 5.5 (September 28, $2 / $10, v2.1.284+) and Claude Haiku 5.5 (October 7, $0.10 / $0.50, v2.1.293+) sit behind the sonnet and haiku aliases, and all three default to medium effort. Claude Fable 5.1 (claude-fable-5-1, launched September 1, 2026, requires Claude Code v2.1.257+) remains the opt-in model for the hardest, longest-running tasks: $10 / $50 per MTok, cache reads $0.25 per MTok. Select it with /model fable.