Setup Guide · 2026

How to Set Up Claude Code

Install, authenticate, configure CLAUDE.md, and run your first agentic coding session in under 10 minutes

Prerequisites

Windows users: Claude Code works best on Windows via WSL2 (Windows Subsystem for Linux). Native Windows support is available but WSL2 gives the full Linux terminal experience.

Step-by-Step Installation

  1. Install Claude Code globally
    npm install -g @anthropic-ai/claude-code
    # Or with npx (no install required):
    npx @anthropic-ai/claude-code

    The global install creates the claude command available everywhere in your terminal.

    Check your version: Run claude --version after install. Claude Code updates frequently — re-run the install command to upgrade.
  2. Navigate to your project and start Claude Code
    cd ~/your-project
    claude

    Always run claude from inside your project directory. Claude Code reads your project structure and the local CLAUDE.md file from this directory.

  3. Authenticate

    On first run, Claude Code offers two authentication options:

    • Browser OAuth (recommended for individuals) — opens claude.ai in your browser, uses your existing subscription. No API key management needed.
    • API key — set ANTHROPIC_API_KEY in your environment. Best for teams, CI/CD, or programmatic use.
    # Option B: API key authentication
    export ANTHROPIC_API_KEY="sk-ant-..."
    # Add to ~/.bashrc or ~/.zshrc for persistence
    API key location: Create keys at console.anthropic.com → API Keys. Use a project-scoped key for each codebase if you want separate billing.
  4. Generate your CLAUDE.md

    Once inside a Claude Code session, run:

    /init

    Claude reads your codebase and generates a CLAUDE.md file with project context, conventions it inferred, and suggested rules. Review and edit it — the better your CLAUDE.md, the better every future session.

    What to put in CLAUDE.md: Architecture overview, naming conventions, testing requirements ("always add tests for new functions"), commands to run before committing, files/dirs Claude should avoid modifying.
  5. Run your first task
    > Find all TODO comments in the codebase and create a GitHub issue template listing them
    
    Claude: Reading codebase structure...
    Claude: Found 12 TODO comments across 7 files
    Claude: Creating issue-template.md...
    Claude: Done — created ISSUE_TEMPLATE/todo-audit.md
    

    Start with a concrete, well-scoped task. Claude will ask for permission before making changes — approve selectively to build trust with its capabilities.

Configure Tool Permissions

Claude Code asks permission for every tool call by default. You can pre-approve common safe operations in .claude/settings.json:

// .claude/settings.json
{
  "permissions": {
    "allow": [
      "Bash(git status)",
      "Bash(git diff*)",
      "Bash(npm test*)",
      "Bash(npm run lint*)",
      "Read(**/*)"
    ]
  }
}
Be careful with Bash permissions. Only pre-allow commands you'd run manually. Avoid blanket Bash(*) permission — it lets Claude run any shell command without prompting.

Optional: Install MCP Servers

MCP (Model Context Protocol) servers extend Claude Code with external tools. Common ones:

# GitHub MCP — read/write PRs, issues, repos
claude mcp add github -- npx -y @modelcontextprotocol/server-github

# Filesystem MCP — granular file access control
claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem /your/path

# Postgres MCP — read your database schema + run queries
claude mcp add postgres -- npx -y @modelcontextprotocol/server-postgres postgresql://...

Optional: Set Up Hooks

Hooks let you run shell commands automatically when Claude takes specific actions. Add them in .claude/settings.json:

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [
          {
            "type": "command",
            // Run prettier on every file Claude edits
            "command": "npx prettier --write \"$CLAUDE_TOOL_INPUT_FILE_PATH\" 2>/dev/null || true"
          }
        ]
      }
    ]
  }
}

See the full hooks guide for pre/post-tool hooks, stop hooks, and notification hooks.

Verify Your Setup

# Check Claude Code version
claude --version
# List configured MCP servers
claude mcp list
# Inside a session: check your context
/status

Explore Everything Claude Code Can Do

Skills, hooks, MCP servers, slash commands, comparison guides — all in one place.

Open Claude Skills Browser →

Related Guides

⚡ Using Claude Code? 30 power prompts that 2× your output · £5 £3 first 10Get PDF £3 →