ASK KNOX
beta
LESSON 41

Installing Claude Code

One installer, one login, and you're running. Install with a one-line native installer (no Node.js required), log in with your Claude subscription or an API key, and start your first session — every step with the exact commands and what to expect.

8 min read·Getting Started with Claude Code

Installation is the smallest possible barrier between you and your first Claude Code session. One command to install, one login, and you are running — usually in under five minutes. This lesson walks each step with the exact commands and what to expect when things go right.

Step 1: Install Claude Code

The fastest way to install Claude Code is the native installer. It downloads a self-contained app — no Node.js, no extra dependencies — and keeps itself up to date.

macOS, Linux, or WSL:

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

Windows (PowerShell):

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

Prefer a package manager? Homebrew (brew install --cask claude-code) and WinGet (winget install Anthropic.ClaudeCode) both work.

The npm path (optional). If you already live in the Node.js ecosystem, you can install through npm instead. This is the one path that requires Node.js v18 or higher:

npm install -g @anthropic-ai/claude-code

Check your Node version first with node --version. If it reads below v18 — or node is not found — install the current LTS from nodejs.org, or run brew install node on macOS.

However you installed, confirm it worked:

claude --version

A version number means you are ready. To verify the auto-updater is configured correctly, run claude doctor — it checks the updater mechanism and reports any issues there. For general install troubleshooting (PATH, permissions, missing dependencies), use claude --help for the full CLI reference or work through the troubleshooting steps in the section below.

Step 2: Log In

Run Claude Code for the first time from any folder:

claude

On first launch, Claude Code opens your browser to log in. You have two choices:

  1. Log in with your Claude account (recommended). If you have a Claude Pro ($20/mo) or Max plan, sign in and your subscription covers Claude Code — no per-token billing, no key to manage. This is the simplest path for most people.

  2. Use an Anthropic API key. For metered, pay-as-you-go billing, create a key at console.anthropic.com → API Keys → Create Key. Your key starts with sk-ant-api.... Claude Code reads it from the ANTHROPIC_API_KEY environment variable, or you can paste it when prompted.

Once you authenticate the first time, Claude Code saves your login and will not ask again on this machine.

Setting an API key permanently (API-key users only)

If you go the API-key route and want it available in every terminal, add it to your shell profile.

zsh (macOS default):

echo 'export ANTHROPIC_API_KEY=sk-ant-api...your-key-here' >> ~/.zshrc
source ~/.zshrc

bash:

echo 'export ANTHROPIC_API_KEY=sk-ant-api...your-key-here' >> ~/.bashrc
source ~/.bashrc

Subscription users can skip this entirely — there is no key to export.

Costs at a glance

On a subscription, your cost is the flat monthly plan — nothing else to track. On an API key, you pay per token: a typical beginner session runs $0.05–$0.50 for simple tasks and $1–5 for complex multi-file work. Set a spend limit in the Console (your Workspace → Limits) so a long session never surprises you.

Step 3: Run Your First Session

Navigate to a project directory — or create a new one:

mkdir my-first-project
cd my-first-project
claude

Type your first message:

> What files are in this directory?

Claude uses the Bash tool to run ls and reports back. That is your first agentic interaction.

Troubleshooting Common Issues

"claude: command not found" — Reopen your terminal so the installer's PATH change takes effect. If you installed via npm, the global bin directory may not be on your PATH; run npm prefix -g to find your global install prefix — the executables live in its bin subfolder — and add that to your PATH (on macOS with Homebrew Node, the prefix is typically /opt/homebrew, so the bin is /opt/homebrew/bin).

"Invalid API key" — Check that your key starts with sk-ant-api and has no extra spaces. Re-export it in your current terminal even if it is in your profile, then try again. Or skip the key entirely and log in with your Claude subscription.

The login browser does not open — On a remote or headless machine, Claude Code prints a URL to paste into a browser, then a code to paste back into the terminal. Follow the on-screen prompts.

Slow first launch — Claude Code fetches some assets on first run. Later launches are faster.

The Configuration Directory

Claude Code stores its configuration in ~/.claude/. This includes:

  • Login credentials — your saved subscription token or API key (on macOS these live in the system Keychain rather than a file)
  • Global settings — default model, permission mode, and UI preferences in settings.json
  • Session history — recent sessions for reference

Edit ~/.claude/settings.json directly to change defaults, or open the in-session /config menu. The “Commands, Shortcuts, and Slash Commands” lesson covers configuration in depth.

Lesson Drill

Confirm you are fully set up:

claude --version      # should show the installed version

Then create a test directory and start a session:

mkdir ~/claude-test && cd ~/claude-test
claude

Log in if prompted, then type: Create a file called hello.txt with the text "Claude Code is running." — Claude should create the file. Run cat hello.txt to verify.

Bottom Line

Installation is short: one installer (the native one-liner, or npm if you prefer Node.js), one login (your Claude subscription or an API key), and claude in your terminal. There is no IDE plugin, no browser extension, and no account on a third-party platform. Once you are logged in, run it from any project directory and start working immediately.

The next lesson covers your first real session — how to give Claude tasks, read its tool calls, and understand what is happening as it works.