Skip to main content

Prerequisites

  • Node.js 18 or higher. Check your version with node --version. Download Node.js if needed.
  • A Claude account at claude.ai, or an Anthropic API key.

Install and authenticate

1

Install globally via npm

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

Authenticate

Run claude from any directory. On first launch, Claude Code detects that no credentials are configured and prompts you to log in.
claude
OAuth via claude.ai (recommended): Follow the URL printed in the terminal to complete the OAuth flow in your browser. Your subscription entitles you to use Claude Code without managing API keys.API key: If you prefer to use an API key directly, set the ANTHROPIC_API_KEY environment variable before running claude:
export ANTHROPIC_API_KEY=sk-ant-...
claude
If both an OAuth session and ANTHROPIC_API_KEY are present, Claude Code uses the API key and skips the OAuth flow.
3

Navigate to your project

Claude Code works best when launched from your project root so it can read the files it needs.
cd my-project
claude
4

Ask Claude something

Once the interactive session opens, type a prompt and press Enter:
> explain what this codebase does
Claude reads relevant files and replies in the terminal. You can continue the conversation, ask for edits, run commands, and more — all in the same session.

First non-interactive call

Use the -p (or --print) flag to run a single prompt and print the result to stdout. This is useful for scripting or quick one-off queries:
claude -p "what files are in this directory?"
Output is written to stdout, making it easy to pipe into other tools:
claude -p "list all TODO comments in the codebase" > todos.txt

Tips for effective use

Start sessions from your project root. Claude Code uses your working directory as the base for all file operations.
  • Be specific about scope. Tell Claude which files or directories are relevant if the codebase is large.
  • Ask for plans before big changes. Prompt Claude to outline what it intends to do before making edits across many files.
  • Use non-interactive mode for automation. The -p flag makes it straightforward to integrate Claude into shell scripts, Makefiles, or CI workflows.
  • Resume sessions. Use claude --resume to continue a previous conversation rather than starting over.

Next steps

Installation

Full installation options including alternative package managers, Bedrock, and Vertex AI.

Interactive mode

Learn the interactive REPL in depth.

Build docs developers (and LLMs) love