Getting Started with Claude Code

Installing Claude Code and First-Run Setup

Step-by-step installation for Windows PowerShell, macOS, and Linux — plus API key configuration, first invocation, and the settings that matter most.

Prerequisites

Claude Code requires:

  • Node.js 18 or higher
  • An Anthropic API key (from console.anthropic.com)
  • npm (included with Node.js)

Verify your Node.js version before installing:

bash
node --version
# Should output v18.x.x or higher

Installation

Install Claude Code globally via npm:

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

This makes the claude command available system-wide in any terminal.

Windows PowerShell Notes

On Windows, if npm global installs aren't in your PATH, you may need to add the npm global directory to your PowerShell profile. Check where npm installs global packages:

powershell
npm config get prefix
# Typically: C:\Users\[Username]\AppData\Roaming\npm

If the claude command isn't found after install, add that directory to your PATH via System Properties → Environment Variables → Path.

You may also need to allow script execution in PowerShell:

powershell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

API Key Configuration

Claude Code needs your Anthropic API key. Set it as an environment variable:

macOS / Linux (bash/zsh)

bash
export ANTHROPIC_API_KEY=sk-ant-...
# To persist across sessions, add to ~/.zshrc or ~/.bashrc:
echo 'export ANTHROPIC_API_KEY=sk-ant-...' >> ~/.zshrc

Windows PowerShell

powershell
# For current session:
$env:ANTHROPIC_API_KEY = "sk-ant-..."

# To persist across sessions, add to your PowerShell profile:
notepad $PROFILE
# Add: $env:ANTHROPIC_API_KEY = "sk-ant-..."

Windows Environment Variables (GUI)

Search "Environment Variables" in the Start menu → Edit the system environment variables → Environment Variables → New (under User variables) → Name: ANTHROPIC_API_KEY, Value: your key.

Verifying the Installation

bash
claude --version
claude --help

If both commands succeed, installation is complete.

First Invocation

Navigate to a project directory and start an interactive session:

bash
cd /path/to/your/project
claude

Claude Code opens an interactive REPL (read-eval-print loop). You'll see a prompt where you can type natural language instructions.

For a one-off command without entering interactive mode:

bash
claude -p "What files are in this project and what does each one do?"

Key Settings and Flags

`--model` — Specify which Claude model to use:

bash
claude --model claude-opus-4-5

`--add-dir` — Add additional directories to the context (useful when working across multiple repos):

bash
claude --add-dir ../shared-utils

`--dangerously-skip-permissions` — Auto-approve all tool uses without prompting (use only in trusted environments or CI/CD pipelines):

bash
claude --dangerously-skip-permissions -p "Run the full test suite and fix any failures"

`--output-format` — Control how output is formatted (useful for scripting):

bash
claude --output-format json -p "List all TypeScript files" > files.json

CLAUDE.md: Project-Level Instructions

Claude Code reads a CLAUDE.md file in your project root automatically at the start of every session. This is where you put project-specific instructions:

markdown
# Project Instructions

## Tech Stack
- React 18 + TypeScript (strict)
- Tailwind CSS only — no custom CSS files
- Supabase for database and auth
- Vitest for testing

## Conventions
- All components in src/components/[category]/
- Tests colocated with source: [Component].test.tsx
- Never use any or unknown TypeScript types
- All API calls in src/services/, never in components

## Before Making Changes
Always run: npm run typecheck && npm test
Report failures before proceeding.

The CLAUDE.md file is your primary tool for giving Claude Code persistent context without repeating instructions in every session.

Key Takeaways

  • Install with npm install -g @anthropic-ai/claude-code
  • Windows PowerShell setup requires PATH and execution policy configuration
  • Set ANTHROPIC_API_KEY as a persistent environment variable
  • CLAUDE.md in your project root gives Claude Code permanent project instructions
  • Use claude for interactive sessions, `claude -p "..." for one-off commands

---

Try It Yourself: After installing, create a CLAUDE.md in a project you work on. Add your tech stack, 3–5 coding conventions, and a note about which test command to run. Start a Claude Code session and ask: "Read CLAUDE.md and tell me what you now know about this project." Verify it captured your conventions accurately.