Skip to main content

Setting Up Claude Code on macOS, Windows and Linux

Install Claude Code, sign in, give it project context, and use it to build a tested TypeScript utility.

This tutorial covers the full Claude Code setup: the install command for your operating system, sign-in, project instructions, and one complete coding task. You will plan a change, review the plan, let Claude edit the files, run tests, and inspect the diff. That review loop is human-in-the-loop development in miniature.

Commands and requirements on this page come from the Claude Code setup docs and quickstart, checked in December 2026.

Before You Begin​

You need:

  • An operating system Claude Code supports: macOS 13.0 or later, Windows 10 1809 or later, Windows Server 2019 or later, Ubuntu 20.04 or later, Debian 10 or later, or Alpine Linux 3.19 or later.
  • 4 GB of RAM or more and an x64 or ARM64 processor.
  • An account with Claude Code access: a Claude Pro, Max, Ultra, Team or Enterprise plan, a Claude Console account, or access through Amazon Bedrock, Google Cloud's Agent Platform or Microsoft Foundry. The free Claude plan does not include Claude Code.
  • A local Git repo with a working TypeScript test command, for the task later in this tutorial.

Install Claude Code on macOS and Linux​

Open a terminal and run the native installer. The same command works inside WSL on Windows:

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

The installer prints no progress while it downloads. When it finishes, open a new terminal window so your shell picks up the new claude command. Native installs update themselves in the background.

On macOS you can use Homebrew instead:

brew install --cask claude-code

The claude-code cask follows the stable channel, which runs about a week behind and skips releases with major regressions. Homebrew installs do not update themselves. Run brew upgrade claude-code to get new versions.

On Linux, Anthropic also publishes signed apt, dnf and apk repositories for Debian, Ubuntu, Fedora, RHEL and Alpine. Those packages update through your normal system upgrades. The Linux package manager instructions list the repository lines and signing key fingerprint. Alpine needs bash and curl before the native installer runs, so install them first with apk add bash curl.

Install Claude Code on Windows​

Claude Code for Windows runs natively or inside WSL. Pick based on where your projects live:

OptionSandboxingUse it for
Native WindowsNot supportedWindows-native projects and tools
WSL 2SupportedLinux toolchains, or sandboxed command execution
WSL 1Not supportedMachines where WSL 2 is unavailable

For a native install, run one of these. You do not need an Administrator prompt. Your prompt starts with PS in PowerShell and without it in CMD.

# PowerShell
irm https://claude.ai/install.ps1 | iex
:: CMD
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

WinGet works too, but it does not update Claude Code for you. Run winget upgrade Anthropic.ClaudeCode when you want a new version.

winget install Anthropic.ClaudeCode

Install Git for Windows as well. It is optional, but it provides Git Bash, which Claude Code's Bash tool needs. Without it, Claude Code runs shell commands through PowerShell.

For WSL, open your Linux distribution and run the macOS and Linux installer from the previous section. You then start claude inside the WSL terminal, not from PowerShell or CMD.

Verify the Install​

Check that your shell finds the command:

claude --version

A working install prints a version number followed by (Claude Code). If the shell reports that claude is not found, the install directory is not on your PATH yet. Open a new terminal, then see Troubleshoot installation if the error remains.

For a fuller check, claude doctor prints install health, settings-file errors and the result of the last auto-update without starting a session.

Sign In​

Start Claude Code from your project directory:

cd /path/to/your/project
claude

On first use, Claude Code asks you to log in. Complete the sign-in in your browser with your Claude plan or Console account. Claude Code stores the login, so later sessions start straight away. If ANTHROPIC_API_KEY is set and you approve the key when asked, Claude Code skips the browser login.

To switch accounts later, type /login inside a running session.

Add the VS Code Extension​

The VS Code extension needs VS Code 1.94 or later. Open the Extensions view with Cmd+Shift+X on macOS or Ctrl+Shift+X on Windows and Linux, search for Claude Code, and install the extension published by Anthropic.

Open a source file and click the Spark icon in the editor toolbar. The first time the panel opens, it shows a sign-in screen that completes in your browser. If the panel does not appear, run Developer: Reload Window from the Command Palette.

The extension bundles its own copy of Claude Code for the chat panel. It does not put claude on your shell PATH, so install the standalone CLI as well if you want to run claude in a terminal.

Anthropic also ships a desktop app and a web UI. Claude Code GUI options compares them with third-party apps.

Add Project Instructions​

Claude Code reads CLAUDE.md files at the start of every session. A project file lives at ./CLAUDE.md or ./.claude/CLAUDE.md and goes into version control. Personal instructions for every project go in ~/.claude/CLAUDE.md.

Run /init in a session to generate a starting CLAUDE.md. Claude reads the codebase and writes the build commands, test commands and conventions it finds. If the file already exists, /init suggests improvements instead of overwriting it.

If your team also uses other coding agents, keep shared rules in AGENTS.md:

# Project instructions

## Commands
- Install dependencies: `npm install`
- Run tests: `npm test`
- Type check: `npm run typecheck`

## Code style
- Use TypeScript strict mode
- Keep utility functions small
- Add unit tests for new behavior

Then import it from CLAUDE.md and add guidance only Claude Code needs:

@AGENTS.md

## Claude Code notes
- Place utilities in `src/lib/`
- Match the test patterns in `test/`
- Ask before changing CI or deployment files

The import matters. When a CLAUDE.md exists, Claude Code reads it instead of AGENTS.md, so the @AGENTS.md line is what pulls the shared rules in. Run /context all and check the Memory files list to confirm both loaded.

How to Use Claude Code: Your First Session​

Start by asking about the code. Claude reads files as it needs them, so you do not have to paste context:

what does this project do? where are the tests?

The session's permission mode decides which actions Claude takes without asking you first. Press Shift+Tab in the terminal to cycle modes, or click the mode indicator under the prompt box in VS Code. This tutorial uses three:

ModeWhat Claude does
PlanExplores the repo and proposes a plan, but does not edit files
Accept editsEdits files in your workspace without asking for each change
ManualAsks before file edits and most shell commands

Claude Code v2.1.283 and later start terminal and VS Code sessions in auto mode, where a classifier reviews most actions instead of asking you. The permission modes reference lists every mode and when each one is available.

Plan the Change​

Switch to Plan mode and send:

Add a formatDate utility at src/lib/formatDate.ts.
It accepts an ISO date string and returns a date such as "Jan 5, 2026".
Add tests at test/formatDate.test.ts for valid and invalid input.
Inspect the existing code and plan the change before editing files.

Review the plan as a change contract. Check the target files, public behavior, invalid input case and test command. Reply with corrections if Claude made a wrong assumption, and approve the plan once it matches the task.

Implement and Refine​

Switch to Accept edits and send:

Implement the approved plan. Run the relevant tests and type checks.

Watch the edits and command output. Claude should create the utility and test files without changing unrelated code.

For follow-ups about known code, reference the file with @. In VS Code, select lines and press Option+K on macOS or Alt+K on Windows and Linux to insert the reference:

@src/lib/formatDate.ts Return null for an invalid date string.
Update the tests to define this behavior.

Verify and Review the Diff​

Run the checks yourself:

npm test
npm run typecheck

Read the new tests before you trust the green result. They should cover a valid date, an invalid string that returns null, and output that does not change with the machine's time zone. Date formatting often shifts across time zones, so the contract needs an explicit time zone or a date-only parsing rule.

Switch to Manual mode for the final pass and review every changed file. Look for unrelated edits, weak assertions, new dependencies and behavior the plan did not cover. Ask Claude to summarize each changed file if the diff is larger than you expected. The summary helps you navigate, but the diff remains the source of truth.

Essential Commands​

CommandWhat it does
claudeStart an interactive session
claude "task"Start a session with a first prompt
claude -p "query"Run one query, print the answer, and exit
claude -cContinue the most recent conversation in this directory
claude -rResume an earlier conversation
/clearStart a new conversation inside the session
/helpList available commands
/exitLeave Claude Code

Native installs update in the background. Run claude update to apply an update immediately.

Next Steps​