Skip to main content
This guide walks you through installing Claude Code, authenticating, and running your first task.

Prerequisites

  • Node.js 18+ and npm — or Bun if you prefer running from source
  • An Anthropic account — sign up at anthropic.com if you don’t have one
1

Install Claude Code

Install the package globally with npm:
npm install -g @anthropic-ai/claude-code
Verify the installation:
claude --version
2

Start the REPL

Navigate to your project directory and launch Claude Code:
cd /your/project
claude
This opens the interactive REPL. Claude Code reads your current directory and uses it as context for all requests.
3

Sign in

On first run, type the /login command inside the REPL:
/login
This starts the OAuth flow. Your browser will open to complete authentication with your Anthropic account. Credentials are stored securely — on macOS they are saved to the system Keychain.
If you are already authenticated (for example, via an ANTHROPIC_API_KEY environment variable), /login lets you switch accounts instead.
4

Ask Claude to explain the codebase

Once authenticated, type a natural language request at the prompt:
Explain the overall structure of this codebase. What are the main modules and how do they interact?
Claude Code will read relevant files, summarize the architecture, and point you to key entry points — without you specifying which files to look at.
5

Make your first code change

Try asking for a concrete edit:
Add a JSDoc comment to the main export in src/index.ts describing what it does.
Claude Code will locate the file, read it, propose the edit, and ask for your confirmation before writing. You can approve, reject, or ask for a revision.

Interactive vs. non-interactive usage

Claude Code has two modes. Interactive REPL — Run claude with no arguments to open the persistent session. You can have a back-and-forth conversation, use slash commands, and approve tool calls interactively. Non-interactive (headless) — Pass a prompt directly on the command line. Claude Code runs the task and exits. Useful for scripting and CI pipelines.
claude "Write a one-line summary of every exported function in src/ and save it to EXPORTS.md"
Use the --print / -p flag to suppress the interactive UI and print the final response to stdout:
claude -p "What does the function parseConfig do in src/config.ts?"
This makes it easy to pipe Claude Code output into other tools:
claude -p "List all TODO comments in this repo" | grep -i "urgent"

Troubleshooting setup

If something is not working as expected, run /doctor inside the REPL:
/doctor
The doctor command runs a suite of environment diagnostics — checking authentication status, Node.js and Bun versions, network connectivity to the Anthropic API, and configuration validity. It will surface specific errors with suggested fixes.
For persistent issues, see the troubleshooting guide or check the installation page for platform-specific notes.

Next steps

Installation

Platform-specific setup, upgrading, and uninstalling.

Headless mode

Run Claude Code in CI pipelines and scripts without a terminal UI.

MCP servers

Connect external tools and data sources to Claude Code.

Agent swarms

Parallelize large tasks across multiple coordinated sub-agents.

Build docs developers (and LLMs) love