Claude Code (CLI)
The terminal version of Claude Code — install, CLAUDE.md context files, slash commands, and power-user tips.
What it is
Claude Code is Anthropic’s agentic coding tool. The CLI is the terminal version: you cd into a repo, run claude, and Claude reads files, edits them, runs commands, and commits — on demand and with your approval. It’s the same engine behind Claude Code Desktop and the web app, and the CLI is where every knob is exposed.
Where to find it
Install with one of the following, then run claude:
| Your setup | Command |
|---|---|
| macOS / Linux / WSL | curl -fsSL https://claude.ai/install.sh | bash |
| Windows (PowerShell) | irm https://claude.ai/install.ps1 | iex |
| Homebrew | brew install --cask claude-code |
| npm (Node 18+) | npm install -g @anthropic-ai/claude-code |
Anthropic also publishes a Windows CMD installer, a WinGet package (winget install Anthropic.ClaudeCode), and apt / dnf / apk packages for Debian, Fedora, RHEL, and Alpine.
Don’t use sudo with the npm install — it causes permission problems later. Verify with claude --version.
Native installs update themselves in the background. Homebrew and WinGet installs don’t: run brew upgrade claude-code or winget upgrade Anthropic.ClaudeCode yourself. Homebrew offers two casks — claude-code tracks the stable channel, roughly a week behind, and claude-code@latest ships new versions as soon as they land.
How to use it
First-day flow
cd path/to/your/projectand runclaude.- On first launch,
/loginauthenticates through the browser (SSO included). Alternatively exportANTHROPIC_API_KEY, or setCLAUDE_CODE_USE_BEDROCK=1orCLAUDE_CODE_USE_VERTEX=1with the matching cloud credentials. - Ask a question. Claude reads files on demand — there’s nothing to upload.
- When Claude proposes an edit you’ll see a diff. Choose Yes, Yes, and don’t ask again for edits, or No.
- Run
/initonce per project to generate a starterCLAUDE.md.
Permission modes
Press Shift+Tab at any time to cycle the permission mode: auto → manual → acceptEdits → plan. Plan mode is read-only — use it to let Claude outline a big change before it touches anything. /plan drops you straight into it, optionally with a task description.
CLAUDE.md — project memory
Claude reads CLAUDE.md files automatically at the start of every session, from broad to specific: ~/.claude/CLAUDE.md for every project, <repo-root>/CLAUDE.md for the current one, and <subdir>/CLAUDE.md for a specific directory. Subdirectory files load on demand.
Keep it under roughly 200 lines. Include build, test, lint, and run commands, naming conventions and “we use X, not Y” decisions, a three-sentence architecture summary, hard constraints, and the pitfalls that catch new joiners. Leave out full API docs, changelogs, anything obvious from the directory tree, and rules the team doesn’t actually follow.
The file is loaded as a user message, not baked into the system prompt. Nothing is summarised or truncated, and it isn’t re-read from disk on every turn — so restart the session after you edit it.
Slash commands worth knowing
/clear— wipe the conversation and start fresh; project memory stays./compact— summarise the conversation so far to free up context./btw— ask a quick side question without adding it to the main conversation./rewind— roll the conversation and/or your code back to an earlier checkpoint (or press Esc, Esc)./model— view or switch the active model./contextvisualises what’s loaded;/memoryopens theCLAUDE.mdfiles in scope./cost— token usage and spend for this session./usage— your plan’s limits and current rate-limit status./diff— an interactive viewer for uncommitted changes and per-turn diffs./simplify— review files for reuse, quality, and efficiency issues, then apply the fixes./permissions,/add-dir— control which tools need approval and which directories Claude can reach./agents,/hooks,/skills,/mcp— subagents, lifecycle hooks, packaged workflows, and MCP servers./doctor— diagnose install and environment issues./statusshows account, model, working directory, and version.
Press ? inside a session for the shortcuts your terminal or IDE supports.
Good to know
- Models. Sonnet is the default and the right choice for most coding work. Opus offers deeper reasoning for large cross-cutting refactors, hard debugging, and architectural decisions. Haiku is fastest and cheapest for quick lookups, simple edits, and high-volume scripted runs.
/modelis always the source of truth for what your account can reach. - The usage meter depends on how you signed in. An Enterprise seat draws on a pool included in your organisation’s plan that resets on a rolling window. API-key auth is pay-as-you-go, billed per token, with no hard stop.
- Verification is the number-one tip. Give Claude a way to check its own work: the Chrome extension for front-end changes, the Desktop app’s built-in browser for a running web server.
- Worktrees and parallel sessions.
claude --worktreelaunches an isolated git worktree session; Anthropic suggests running three to five in parallel./batchspreads a large migration across many isolated agents. - Scheduling.
/looprepeats a prompt inside a CLI session for quick polling;/schedulecreates a cloud routine that keeps running when your machine is off. - Moving between surfaces.
claude --cloudstarts a web session from the terminal andclaude --teleportpulls one back down;/desktopcontinues the current session in the Desktop app. Remote control — steering a local session from your phone or a browser — is available on Pro, Max, Team, and Enterprise plans on CLI v2.1.51 or later. - Troubleshooting quick hits:
command not found→ open a new terminal orsource ~/.zshrc.EACCESon npm install → use the native installer or fix npm’s prefix; neversudo. Installer hangs on a corporate network → setHTTPS_PROXY. TLS orSELF_SIGNED_CERT_IN_CHAINerrors → point Node at your CA bundle withNODE_EXTRA_CA_CERTS./logincallback blocked → copy the URL, sign in elsewhere, and paste the code back. 403 on a model → your seat or region doesn’t have access to it. Last resort:claude doctor.
What’s changed recently
- 2026-09-13 — Re-read against the seven current Claude Code articles. The permission-mode cycle is now four modes — Shift+Tab moves through
auto → manual → acceptEdits → plan, so auto mode no longer needs a launch flag. New commands documented:/btw,/rewind,/diff,/simplify,/plan,/context,/memory,/add-dir,/status.CLAUDE.mdfile locations, loading behaviour and length guidance are spelled out for the first time. Install picks up WinGet, a Windows CMD installer, Linux package managers, and two Homebrew casks, with auto-update only on native installs. We’ve removed the “1M context on Opus 4.6 or 4.7” line and/model opusplan, neither of which any current article supports, and--remotehas been replaced by--cloud.
Related
Related
Sources
- Claude Code overview · fetched 2026-09-13
- Your first day in Claude Code · fetched 2026-09-13
- Models, usage, and limits in Claude Code · fetched 2026-10-07
- Claude Code cheatsheet · fetched 2026-09-13
- Give Claude context: CLAUDE.md and better prompts · fetched 2026-09-13
- Troubleshoot Claude Code installation and authentication · fetched 2026-09-13
- Claude Code power user tips · fetched 2026-09-13