Skip to main content

Prerequisites

  • Node.js 18 or higher
  • npm
To check your Node.js version:
node --version
If you need to install or upgrade Node.js, download it from nodejs.org.

Step 1: Install Claude Code

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

Step 2: Authenticate

Run claude from any directory to start the first-time setup:
claude
On first run, Claude Code opens your browser and walks you through signing in with your Anthropic account. Once complete, your credentials are stored securely and reused for future sessions. Alternatively, set an API key directly if you prefer not to use OAuth:
export ANTHROPIC_API_KEY=sk-ant-...
API keys take priority when the ANTHROPIC_API_KEY environment variable is set. For interactive use, OAuth is recommended because it handles token refresh automatically.

Step 3: Navigate to your project

Claude Code works within your current directory. Navigate to any project you want to work on:
cd my-project

Step 4: Start an interactive session

Run claude to open an interactive session:
claude
You’ll see a prompt where you can type tasks in plain language. Claude reads your project files, runs commands, and makes changes based on what you describe. Example first tasks to try:
> explain the structure of this codebase
> add input validation to the signup form
> write tests for the UserService class
> find all places where we catch and swallow errors
Claude shows you what it plans to do before making changes that require permission. You can approve, deny, or ask for a different approach at each step.

Step 5: Initialize a CLAUDE.md file

Run /init inside your session to generate a CLAUDE.md file for your project:
/init
Claude analyzes your repository — reading manifest files, existing documentation, and code structure — and produces a CLAUDE.md with the commands and context it needs to work effectively in your codebase. You should review and edit the generated file before committing it.
CLAUDE.md is loaded at the start of every session. It’s the best place to capture things like non-standard build commands, testing quirks, and coding conventions specific to your team.

Running a non-interactive command

Use the -p flag to run a single task and print the result, without entering an interactive session. This is useful for scripting or one-off queries:
claude -p "explain this codebase"
claude -p "list all TODO comments and the files they appear in"
claude -p "check for unused exports in src/"

Key slash commands

Once you’re inside an interactive session, these slash commands are the most useful to know:
CommandDescription
/helpShow available commands and keyboard shortcuts
/initGenerate or update a CLAUDE.md for the current project
/memoryView and edit memory files (CLAUDE.md, CLAUDE.local.md)
/permissionsView or change the current permission mode
/mcpManage connected MCP servers
/clearClear the current conversation context
/exitEnd the session

Next steps

Core concepts

Understand how Claude Code thinks, plans, and acts on tasks

Permission modes

Learn how to configure how much autonomy Claude has

CLAUDE.md reference

Write effective memory files for your projects

MCP servers

Extend Claude with databases, APIs, and internal tools