Skip to main content

Get up and running

1

Install Claude Code

Install the official Anthropic package globally via npm:
npm install -g @anthropic-ai/claude-code
Claude Code requires Node.js 18 or higher. The package uses Bun internally but is distributed as a standard npm package.
2

Authenticate

Run claude to start the setup flow. On first launch you will be prompted to authenticate:
claude
You have two options:
  • OAuth (recommended): Follow the browser-based OAuth flow to connect your claude.ai subscription account.
  • API key: Set the ANTHROPIC_API_KEY environment variable before running claude:
export ANTHROPIC_API_KEY=sk-ant-...
claude
On macOS, Claude Code stores credentials securely in the system Keychain. You will see a permission dialog on first use.
3

Navigate to your project

Claude Code uses your working directory to understand project context. Change to your project root before starting a session:
cd /path/to/your/project
claude
4

Run your first task

Type a natural language request at the prompt. Claude Code will read your codebase, propose a plan, and ask for permission before making changes:
> Review this codebase and find potential bugs
Claude Code will use its built-in tools — file reading, grep search, glob matching — to explore your project and return a detailed report.

Interactive REPL

When you run claude without arguments, you enter the interactive REPL. The session looks like this:
Claude Code v1.0.x
✓ Authenticated as [email protected]

Working directory: /path/to/your/project

> |
Type your request and press Enter. Claude Code will display its reasoning, tool calls, and results inline. Use arrow keys to navigate history, or /help to see available commands. To exit the REPL, press Ctrl+C or type /exit.

Headless mode

For scripting, CI pipelines, or programmatic use, pass a task with -p and get structured output:
claude -p "Find all TODO comments in the codebase" --output-format json
The --output-format json flag returns machine-readable output including the assistant’s response and any tool calls made during the task.

First commands to try

Once you are in the REPL, these commands help you orient yourself:
CommandDescription
/initInitialize Claude Code for your project — generates a CLAUDE.md with project context
/helpList all available slash commands
/doctorRun diagnostics and verify your installation and authentication
/modelSwitch between available Claude models
/compactManually compact the conversation context when it grows large
Run /init in a new project to let Claude Code read your codebase and generate a CLAUDE.md file. This file is included in every future session as project-specific context.

Permission dialogs

On first use, Claude Code will present a workspace trust dialog asking you to confirm it can operate in the current directory. Subsequent tool calls (file writes, shell commands) will prompt for approval unless you configure an auto permission mode.
Claude Code can execute shell commands and modify files. Review each permission request carefully, especially when running tasks in unfamiliar codebases.

Build docs developers (and LLMs) love