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
Authenticate
Run 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
claude from any directory. On first launch, Claude Code detects that no credentials are configured and prompts you to log in.ANTHROPIC_API_KEY environment variable before running claude:If both an OAuth session and
ANTHROPIC_API_KEY are present, Claude Code uses the API key and skips the OAuth flow.Navigate to your project
Claude Code works best when launched from your project root so it can read the files it needs.
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:
Tips for effective use
- 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
-pflag makes it straightforward to integrate Claude into shell scripts, Makefiles, or CI workflows. - Resume sessions. Use
claude --resumeto 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.