Claude Code — Getting Started

Install and configure Claude Code, Anthropic's terminal-based AI coding agent. Covers installation, authentication, project configuration, and first session walkthrough.

October 20, 2026
claude-codeanthropicterminal-agentsetup

Claude Code — Getting Started

Claude Code is Anthropic's terminal-based AI coding agent. It reads your codebase, writes and edits files, runs terminal commands, and can autonomously complete multi-step engineering tasks — all through natural language prompts in your terminal.

Installation

# Via npm (recommended)
npm install -g @anthropic-ai/claude-code

# Via Homebrew
brew install --cask claude-code

# Verify installation
claude --version

Authentication

Sign in with a Claude subscription or an Anthropic Console account. If you use an API key, get one at console.anthropic.com (API Keys section).

# Optional: set an API key
export ANTHROPIC_API_KEY="sk-ant-..."

# Or let Claude Code prompt you to sign in on first run
claude

First Session

Navigate to your project directory and launch Claude Code:

cd my-project
claude
Claude Code Terminal Session

Claude Code scans your project structure automatically. On first run, you'll see:

⚡ Welcome to Claude Code!

  Directory: /Users/you/my-project
  Model: Sonnet 5.5 (default)
  Context: 1M tokens
  
  Type /help for available commands.
  
>

Type a prompt to start:

> Explain the architecture of this project and suggest improvements

Claude Code will read relevant files, analyze the structure, and respond inline in your terminal.

Essential Commands & References

CommandWhat it does
/helpShow all available commands
@<path>Reference a file inline with an @ mention
/clearClear conversation history
/compactCompress context by summarizing history
/configOpen configuration settings
/costShow current session token costs
/doctorDiagnose installation issues
/initInitialize CLAUDE.md for this project

Project Configuration: CLAUDE.md

Create a CLAUDE.md file in your project root (or .claude/CLAUDE.md). Claude Code reads this every session — it's your project's system prompt.

# CLAUDE.md

## Commands
- `npm run dev` — Start development server
- `npm run build` — Production build
- `npm run lint` — ESLint + TypeScript check
- `npm run test` — Run test suite

## Architecture
- Next.js 14 App Router
- TypeScript strict mode
- Tailwind CSS for styling
- PostgreSQL via Prisma ORM

## Conventions
- Use server components by default
- `'use client'` only for interactivity
- Path alias `@/` maps to project root
- No any types — use explicit types or unknown

See Prompt Engineering in Claude Code for advanced CLAUDE.md patterns.

Environment Variables

VariablePurpose
ANTHROPIC_API_KEYAPI authentication (optional when signed in with a subscription)
ANTHROPIC_MODELOverride default model
CLAUDE_CODE_MAX_OUTPUT_TOKENSMax output tokens per request
ANTHROPIC_BASE_URLCustom API endpoint (proxies)

Sources