Skip to main content
The fastest way to use Claude Code is to run the pre-built cli.js that ships inside the npm package. No build step required.
1

Check your Node.js version

Claude Code requires Node.js 18 or later.
2

Navigate to the repository root

The pre-built cli.js lives at the root of the package, alongside package.json.
3

Verify the CLI works

4

Authenticate

Claude Code needs access to the Anthropic API. Use either method:Option 1 — Environment variable (recommended for scripts):
Option 2 — Interactive login:
The login command walks you through the OAuth flow and stores credentials locally.
5

Run a non-interactive query

Use -p (or --print) to send a single prompt and exit immediately. No interactive session is opened.
The response is printed to stdout and the process exits.
6

Start an interactive session

Run without any flags to open the interactive REPL:
You’ll see the Claude Code welcome screen. Type your prompt and press Enter. Use /help to list available slash commands.

Key flags

Example: non-interactive query

The agent runs, executes whatever tools are needed (glob, read, etc.), prints the final answer, and exits.

Example: resume a previous session

Install globally (optional)

If you want to call claude instead of node cli.js:
The -p flag puts Claude Code into non-interactive (headless) mode. This is equivalent to the SDK’s QueryEngine path and is well-suited for scripting and automation.