Skip to content

Updated May 2026

How to use Claude Code: install, auth, and IDE setup

TL;DR

Claude Code is Anthropic's official CLI for Claude. Install it with one command (curl -fsSL https://claude.ai/install.sh | bash on Mac or Linux), then run claude in any project folder and log in with a Claude Pro, Max, or Anthropic Console account. It runs in the terminal, in VS Code, in Cursor, in JetBrains IDEs, and on the web. Use slash commands like /init, /model, and /permissions to control sessions, and add a CLAUDE.md file to give it project memory.

Verified May 2026 Independently researched Editorial standards

If you write code for a living, learning how to use Claude Code is the fastest way to add a senior-level pair programmer to your terminal. This guide covers installation, authentication, IDE setup for VS Code and Cursor, terminal workflows, slash commands, hooks, MCP servers, plan mode, and the gotchas that trip up most new users.

Quick navigation

Get tools like these delivered weekly

Subscribe free →

What Claude Code is and how it works

Claude Code is Anthropic's official CLI for Claude that runs as an agentic coding assistant in your terminal or IDE. Unlike a chat sidebar that suggests text, it operates as a full agent: it reads your files, edits them, runs shell commands, executes tests, follows the output, and iterates until the task is done. You give it a goal in plain English and it produces a working change.

The architecture is a single binary that wraps an agent loop. On every turn it decides which tools to call (read file, edit file, run bash, search, web fetch, and so on), calls them, observes the results, and continues. Tool calls that touch your codebase ask for approval the first time, then respect the permissions you set. The same engine powers the CLI, the VS Code and JetBrains extensions, the Mac and Windows desktop app, and the web client at claude.ai/code, so your CLAUDE.md, hooks, and MCP configuration follow you across surfaces.

Under the hood, Claude Code talks to Anthropic's API. By default it uses Claude Sonnet 4.6 for most work, can switch to Claude Opus 4.7 for hard reasoning, and falls back to Claude Haiku 4.5 for cheap, fast utility calls. If you have a Claude Pro or Max subscription, the CLI uses your subscription's quota; if you log in with an Anthropic Console account, it bills per token. Enterprise teams can route the same CLI through Amazon Bedrock, Google Vertex AI, or Microsoft Foundry.

Install Claude Code

Anthropic recommends the native installer over older npm-based instructions, because the native binary auto-updates in the background. The exact command depends on your operating system. Each command below was verified against the official docs at code.claude.com/docs/en/quickstart.

macOS, Linux, and WSL

Open a terminal and run:

curl -fsSL https://claude.ai/install.sh | bash

If you prefer Homebrew on Mac:

brew install --cask claude-code

Homebrew installs do not auto-update, so run brew upgrade claude-code every couple of weeks. The curl installer keeps itself current.

Windows

Open PowerShell and run:

irm https://claude.ai/install.ps1 | iex

Or for the Command Prompt:

curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

If you have WinGet, you can also run winget install Anthropic.ClaudeCode. Anthropic recommends installing Git for Windows alongside it so Claude Code can use Bash for shell tools instead of falling back to PowerShell.

Verify the install

Once the installer finishes, restart your shell and run:

claude --version

You should see a version string. If the command is not found, your PATH likely needs a restart of the terminal session, or you may be in a shell that did not pick up the new shim. Linux users on Debian, Fedora, RHEL, or Alpine can also install via the apt, dnf, or apk repositories that Anthropic maintains.

Authenticate with Pro, Max, or an API key

Claude Code requires an account on first use. Run claude in any folder and the CLI prints a login URL. Open it, sign in, and the terminal picks up the credentials automatically. There are three account types that work:

  • Claude Pro ($20/mo) — the cheapest option, includes Claude Code with daily usage limits. Suitable for most solo developers.
  • Claude Max ($100/mo or $200/mo) — 5x or 20x the Pro quota, plus higher rate limits. The right choice if you live inside Claude Code all day.
  • Claude Team ($30/user/mo) or Enterprise — adds shared workspaces, SSO, and admin controls.
  • Anthropic Console (API key) — pay-as-you-go billing per token. The CLI auto-creates a "Claude Code" workspace in the Console for cost tracking.

If you prefer to authenticate with an API key (useful in CI), set the ANTHROPIC_API_KEY environment variable in your shell profile and Claude Code will use it instead of the browser flow. Inside an active session, type /login to switch accounts and /logout to clear credentials. Pricing on Pro, Max, Team, and Console is published at claude.com/pricing.

Your first Claude Code session

Open the project you want to work on and start the CLI:

cd ~/code/my-app
claude

You will see the welcome screen with recent sessions, the current model, and a prompt. Type a question in plain English to start a conversation. Three good first prompts to learn how the agent reads your repo:

  • "What does this project do?" — Claude will list files, infer the stack, and summarize the architecture.
  • "Where is the main entry point?" — concrete answer with line numbers, useful for unfamiliar repos.
  • "Add a /healthz endpoint that returns 200 OK" — your first edit, with diffs you approve before they land on disk.

Type /help at any time to see all built-in commands, or press ? to see keyboard shortcuts. To exit, type exit or press Ctrl+D. To resume your previous session in the same directory, run claude -c or use /resume from a fresh session. For one-shot questions without entering interactive mode, run claude -p "explain this regex".

Claude code how to use slash commands

The fastest way to control a Claude Code session is with slash commands. Type a forward slash and the CLI shows an autocomplete menu of every command available in your current configuration. The core set you should memorize:

CommandWhat it does
/initGenerates a CLAUDE.md for your repo by reading the codebase and committing baseline conventions.
/helpLists every slash command, including ones added by skills, plugins, or your own configuration.
/clearClears conversation history and starts fresh in the same project.
/compactSummarizes the current conversation to free up context window without losing key facts.
/modelSwitch between Claude Sonnet 4.6, Opus 4.7, and Haiku 4.5 mid-session.
/permissionsAllow or deny specific tools and Bash command patterns at the session, project, or user level.
/login / /logoutSwitch accounts or sign out without quitting the CLI.
/configEdit your settings.json (theme, default model, hooks, env vars) without leaving the session.
/resumePick a past conversation in the current directory to continue.
/mcpList or troubleshoot connected MCP servers.
/agentsSpawn or manage sub-agents that run subtasks in parallel.

You can also create your own slash commands by dropping markdown files into .claude/commands/ in your repo. Each file becomes a callable skill, which is perfect for repeatable workflows like /review-pr or /deploy-staging that your whole team should share.

How to use Claude Code in VS Code

If your daily editor is Visual Studio Code, the cleanest way to use Claude Code is the official extension. It uses the same agent engine as the CLI but adds inline diff review, @-mentions for files, plan-mode preview, and a sidebar chat that lives next to your editor.

Install the extension

You have two options. From inside VS Code, open the Extensions sidebar (Cmd+Shift+X on Mac, Ctrl+Shift+X on Windows or Linux), search for "Claude Code", and click Install. Or, from a terminal, run:

code --install-extension anthropic.claude-code

After install, open the Command Palette (Cmd+Shift+P / Ctrl+Shift+P), type "Claude Code", and pick Open in New Tab. The first launch prompts you to log in with the same account flow as the CLI.

Workflows that benefit most

The VS Code extension shines for tasks where seeing the diff matters. When Claude proposes a change, the inline diff opens directly in your editor with the file's syntax highlighting. You approve, modify, or reject hunks one at a time, instead of scrolling through a unified diff in a terminal pane. Three high-leverage patterns:

  • Refactors across many files — ask in the sidebar, then walk every diff with the keyboard.
  • @-mention specific files — type @ to attach the file or symbol you want Claude to focus on, instead of dumping context.
  • Plan review before execution — turn on plan mode (Shift+Tab in the chat) so Claude shows the proposed steps before touching the codebase.

If you are already running the CLI in the integrated terminal, the extension reuses your local config. CLAUDE.md, hooks, and MCP servers all carry over. Searching for how to use Claude Code in vscode is the same answer as searching for it in VS Code; the extension Marketplace listing is identical.

How to use Claude Code in Cursor

Cursor is a VS Code fork, so the official Claude Code extension installs cleanly there too. This means you can run Claude Code's agent inside Cursor while still benefiting from Cursor's autocomplete, multi-file Composer, and tab acceptance UI.

Install in Cursor

Open Cursor, click the Extensions icon in the sidebar, and search for "Claude Code". Click Install. Cursor uses the same Open VSX-compatible registry, so the package anthropic.claude-code appears with the official Anthropic publisher tag. Alternatively, run the deep link cursor:extension/anthropic.claude-code from a terminal.

When to use which

Cursor's built-in Composer is excellent for inline edits and small features that fit in your head. Claude Code is the better choice when the task spans many files, requires running tests in a loop, or benefits from a CLAUDE.md you already maintain. Many developers run both side by side: Composer for autocompletion-style work, Claude Code for "go off and do this for ten minutes" jobs.

If you are weighing the two products, our deep dive at Claude Code vs Cursor covers pricing, UX, and benchmark differences. If you also use GitHub Copilot, the three-way comparison at Cursor vs Copilot vs Claude Code breaks down which is best for which use case.

How to use Claude Code in terminal (power-user workflow)

If you spend most of your day in tmux, alacritty, or kitty, the terminal-only workflow is faster than any GUI. The terminal is also where Claude Code's piping and scripting features pay off, because you can compose it with the rest of your Unix toolchain.

Interactive mode

Run claude from any project root. The TUI gives you a chat box, a status bar (model, mode, branch), and a diff preview when Claude proposes edits. Press Tab to autocomplete file paths, Up to scroll command history, and Shift+Tab to toggle plan mode. The CLI persists conversations in .claude/sessions/ so you can resume them later with claude -c in the same directory.

One-shot mode for scripts

Use claude -p "your query" for a single non-interactive call that prints a result and exits. This is the building block for piping Claude Code into other tools:

# Summarize today's git activity in Slack
git log --since=yesterday --oneline | claude -p "summarize for a standup"

# Review only the files changed in this PR
git diff main --name-only | claude -p "spot security issues in these files"

# Translate new strings in CI
claude -p "translate the new keys in locales/en.json into French and open a PR"

Combine these one-shot calls with cron, GitHub Actions, or the built-in Routines feature to schedule recurring jobs. How to use Claude Code in terminal ultimately comes down to two patterns: long interactive sessions for development work, and short -p calls glued together with shell pipes for automation.

Useful CLI flags

  • claude -c — continue the most recent session in the current directory.
  • claude -r — pick a past session from a list and resume.
  • claude -p "..." — run one-shot, print result, exit.
  • claude --model opus — start with Opus 4.7 instead of the default Sonnet.
  • claude --dangerously-skip-permissions — skip permission prompts for fully trusted environments. Reserve this for sandboxes; it lets the agent run any tool without asking.

CLAUDE.md and project memory

The single biggest lever for getting better output is a well-written CLAUDE.md at your repo root. This is a markdown file that Claude Code reads at the start of every session in that project. Treat it as a permanent system prompt that captures your conventions, architectural decisions, and house rules.

Generate a starter file by running /init inside Claude Code. It will scan the repo and write a baseline. Then refine it. Good CLAUDE.md files include:

  • Stack and conventions — language version, framework, formatter, lint rules, test runner.
  • Build and test commands — exact commands so Claude can verify its own changes.
  • Hard rules — security boundaries, files to never touch, secrets paths, deployment guards.
  • Pointers — links to the architecture doc, runbook, or schema reference.
  • Recent decisions — short notes on tradeoffs the team agreed on but might forget.

You can also nest CLAUDE.md files inside subdirectories, and they apply only when Claude is working in that subtree. Auto memory is a complementary feature: as Claude works, it writes learnings (like the build command it discovered) to a separate memory store, so the next session starts smarter without you typing anything.

Hooks: enforce policy before and after tool calls

Hooks are shell commands that fire on specific Claude Code events. The harness, not the model, executes them, which means they enforce policy reliably even if the model "decides" to skip something. The events worth knowing:

  • PreToolUse — runs before a tool call. Return a non-zero exit code to block the call.
  • PostToolUse — runs after a tool call. Useful for auto-format, lint, or running tests on every edit.
  • UserPromptSubmit — runs when you submit a prompt. Inject context, redact secrets, or enforce style.
  • Stop — runs when Claude finishes a turn. Useful to ping a dashboard or post a Slack notification.
  • Notification — runs when Claude is waiting for you. Trigger a desktop notification on long sessions.

Configure hooks in .claude/settings.json at your repo root (shared with the team), or in ~/.claude/settings.json for personal global hooks. A typical PostToolUse hook runs npx prettier --write on the file Claude just edited, so the codebase stays formatted without anyone thinking about it.

MCP servers: connect Claude Code to your tools

The Model Context Protocol (MCP) is an open standard for letting AI tools talk to external data sources and APIs in a structured way. Claude Code is an MCP client, which means it can connect to any MCP server and call its tools as if they were built in. The community has shipped servers for GitHub, Linear, Sentry, Notion, Postgres, Slack, Stripe, and dozens of others.

Add a server with the CLI:

claude mcp add github "npx -y @modelcontextprotocol/server-github"

Or commit a .mcp.json at repo root so every teammate gets the same servers. Use /mcp inside a session to see which servers are connected, restart them, or check logs. The big win is that MCP turns Claude Code into a single chat surface for your whole stack: ask it to triage a Sentry alert, find the related Linear ticket, and open a PR with the fix, all in one prompt.

If you want to build your own server, the SDKs in TypeScript and Python make it a few hundred lines. Anything you can wrap in a function call (a database query, an internal API, a file format) becomes a Claude Code tool.

Plan mode and the Agent SDK

Plan mode is a safety feature that asks Claude to lay out the steps it intends to take before executing them. You toggle it with Shift+Tab in the chat input. In plan mode, the agent can read the codebase but cannot edit files or run commands; instead it returns a numbered plan, you approve or revise it, and only then does Claude leave plan mode and execute. This is the right default for production codebases or any time the change set is large enough that you want a second look before tools start firing.

The Agent SDK is the next step up. It is a TypeScript and Python library that exposes the same agent loop, tools, and permissions model that Claude Code uses internally, so you can build your own agents on top of it. Common uses are custom CLI assistants, automated PR reviewers in CI, code-review bots in Slack, and one-off research agents that scrape data and summarize. Documentation lives at code.claude.com/docs/en/agent-sdk/overview.

Claude code interpreter how to use

If you searched for "claude code interpreter how to use", a quick clarification: Claude Code is the interpreter. There is no separate "Code Interpreter" product the way ChatGPT has a sandboxed Python tool. Claude Code interprets your instructions, plans the approach, and executes shell commands, code edits, and tools in your local environment. Anything Python or Node could do as a sandboxed interpreter, Claude Code does directly against your filesystem.

To use it as a quick interpreter for ad-hoc work, run claude in an empty directory and ask things like:

claude "load sales.csv, compute monthly totals by region, save to a markdown table in summary.md"

Claude will write a Python script (or use shell utilities), run it, validate the output, and produce summary.md. You get the result and the script, so you can audit or rerun it later. For longer document analysis without code, see our companion piece on using Claude with long documents.

Best practices and common gotchas

The patterns that separate productive Claude Code users from frustrated ones are mostly about constraint and feedback. A few that pay off in week one:

Be specific about scope

"Fix the bug" gives the model permission to wander the codebase. "The login form returns a blank screen on wrong credentials. Reproduce it locally, find the cause in src/auth/, and fix it without changing the API contract" is concrete enough that Claude can stay on rails. Pair this with plan mode for anything non-trivial.

Use /clear between unrelated tasks

Long sessions accumulate context that biases later answers. When you switch to a new task, run /clear or /compact to reset. /compact keeps a summary of what was learned, which is useful when you want to keep the CLAUDE.md updates but drop the noisy diff history.

Calibrate permissions early

The first time Claude wants to run npm test, you get a prompt asking whether to allow it once, always, or never. Use this to build a permission profile that matches your trust level. Allow common, idempotent commands (lint, format, test), but require approval for anything that mutates state outside the repo (deploy, push, drop database). The /permissions command edits this profile inside a session.

Watch for context window exhaustion

Claude Code automatically compacts long conversations, but a single prompt that pastes a multi-megabyte log will burn the window. Use /compact proactively, paste only the relevant slice of a log, and let the agent grep the rest. For multi-hour refactors, prefer multiple smaller sessions over one giant one.

Skip --dangerously-skip-permissions on real machines

The flag exists for sandboxes (Docker, ephemeral VMs, GitHub Actions runners) where the blast radius is contained. Running it on your daily-driver laptop trades safety for a small amount of friction, and most experienced users regret that trade the first time the agent rewrites a file they did not expect.

Treat CLAUDE.md as a living doc

The most common mistake is writing CLAUDE.md once and forgetting it. Update it whenever you discover a convention the agent should know, or correct a mistake it made. Five minutes of CLAUDE.md curation saves hours of nudging the model toward the right answer.

Combine Claude Code with another tool when it helps

Claude Code is excellent at agentic, multi-file work. For the very tightest loop (typing a function and accepting a tab), Cursor or GitHub Copilot are still hard to beat. The mature workflow is to layer them: keystroke-level autocomplete in your IDE, Claude Code for tasks measured in minutes, and an occasional dive into Claude on the web for long-form analysis. Our broader survey of AI coding assistants in 2026 covers the trade-offs in detail.

Frequently asked questions

Is Claude Code free?

Claude Code itself is free to download and install, but you need a Claude account to use it. The most affordable path is a Claude Pro subscription at $20 per month, which includes Claude Code usage with daily limits. Claude Max ($100 or $200 per month) gives you 5x or 20x the usage. You can also pay-as-you-go via the Anthropic Console with API credits, billed per token.

How do I install Claude Code on Mac, Windows, or Linux?

On macOS, Linux, or WSL, run curl -fsSL https://claude.ai/install.sh | bash. On Windows PowerShell, run irm https://claude.ai/install.ps1 | iex. You can also use Homebrew (brew install --cask claude-code) on Mac, or WinGet (winget install Anthropic.ClaudeCode) on Windows. Native installs auto-update in the background.

Can I use Claude Code in VS Code?

Yes. Install the official Claude Code extension from the VS Code Marketplace by searching for "Claude Code" in the Extensions view, or run code --install-extension anthropic.claude-code from your terminal. The extension adds inline diff review, @-mentions for files, plan-mode preview, and a sidebar chat that runs the same Claude Code engine as the CLI.

Does Claude Code work in Cursor?

Yes. Cursor is a VS Code fork, so the Claude Code extension installs the same way. Open Cursor's extensions panel, search for "Claude Code", and install. You can run Claude Code alongside Cursor's built-in Composer, which is useful when you want Anthropic's agentic CLI behavior next to Cursor's IDE-native autocomplete.

How do I authenticate Claude Code?

Run claude in your terminal and you will be prompted to log in on first use. You can sign in with a Claude Pro, Max, Team, or Enterprise subscription, or with an Anthropic Console account that uses pre-paid API credits. Inside an active session, type /login to switch accounts and /logout to sign out. For CI, set the ANTHROPIC_API_KEY environment variable.

What models does Claude Code support?

Claude Code routes requests to Anthropic's latest models. As of May 2026 these are Claude Sonnet 4.6 (the default), Claude Opus 4.7 for the hardest reasoning tasks, and Claude Haiku 4.5 for fast lightweight calls. Switch models inside a session with /model. Enterprise users can also run Claude Code through Amazon Bedrock, Google Vertex AI, and Microsoft Foundry.

How is Claude Code different from Cursor?

Cursor is an IDE built on a VS Code fork with deep editor integration, autocomplete, and a Composer panel. Claude Code is an agentic CLI that runs in your terminal or as an extension inside VS Code, Cursor, or JetBrains. Claude Code is editor-agnostic and stronger for multi-step, long-running tasks, while Cursor is stronger for keystroke-level coding. See our full Claude Code vs Cursor comparison for details.

What are MCP servers in Claude Code?

MCP (Model Context Protocol) servers are external tool providers that Claude Code can connect to, exposing custom commands, file access, and APIs. Add one with claude mcp add <name> <command> from the CLI, or configure it in .mcp.json or settings.json. Common MCP servers include GitHub, Sentry, Linear, Notion, Postgres, and any custom server you build.

Where to go next

You now have the full picture: install in one line, log in with a Pro or Max subscription, run it in your editor or your terminal, and steer it with slash commands, CLAUDE.md, hooks, and MCP. The fastest way to get fluent is to use it for a real ticket today and build the muscle memory; the second fastest is to read Anthropic's best practices guide and steal the patterns that work.

If you have not picked a Claude plan yet, our full Claude review walks through Pro vs Max vs Team. To see how Claude Code stacks up against the alternatives, the Claude Code vs Cursor deep dive is the natural next read, and the best AI coding assistants for 2026 roundup gives you the full landscape.

Full Claude review → Claude Code vs Cursor Cursor vs Copilot vs Claude Code Best AI coding assistants 2026 More articles

See something outdated? Report an issue · Suggest a tool