liminfo
BeginnerAbout 15-20 minutes

Claude Code: From Install to First Command

A complete guide to installing Claude Code CLI — the tool that lets you chat with Claude directly in your terminal to read, edit, and generate code. From Node.js setup to authentication to your first command, everything is covered. Takes about 15-20 minutes if you already have Node.js.

Claude CodeClaude Code installClaude CLIClaude Code tutorialAI coding toolClaude Code getting startedanthropic claude codeclaude code quickstartAI terminalClaude Code authentication

What you will build

By the end of this guide, you will have Claude Code installed and authenticated, ready to analyze, modify, and generate code in any project folder. You will also know the essential commands (/help, /compact, etc.) to work efficiently.

Before you start

  • A computer (Windows, Mac, or Linux)
  • Internet connection
  • Basic terminal usage — cd, ls, etc.

Problem

Claude Code is a CLI tool that lets you chat with Claude directly in your terminal to read, edit, and generate code. But getting started requires several steps: verifying Node.js, running a global npm install, and setting up authentication. The official documentation is spread across multiple pages, making it hard to see the full picture of "what exactly do I need to do to send my first command?" This guide consolidates everything into a single, linear flow from download to first command. Estimated costs: - Claude Pro ($20/mo) or Max ($100/mo): required for Claude Code access - Using an API key: usage-based pricing (around $1-5/mo for light testing)

Required Tools

Node.js (v18+)

The runtime required to run Claude Code. Download the LTS version from nodejs.org.

Claude Code CLI

Anthropic's official CLI tool, installed via npm. Run it with the claude command in your terminal.

1
2
3
4
5
6

Solution Steps

1

Step 1: Verify Node.js Installation

~3 min

Claude Code runs on top of Node.js. First, check whether Node.js is already installed on your system. [Open your terminal] - Windows: Search for "PowerShell" and open it - Mac: Press Cmd+Space, type "Terminal", and open it - Linux: Press Ctrl+Alt+T or open your terminal app [Check your version] Type the command below and press Enter. If you see v18.x.x or higher, Node.js is already installed — skip to Step 2. [If you need to install Node.js] If you get "command not found" or a version below 18: 1. Go to nodejs.org in your browser 2. Click the "LTS" (Long Term Support) download button 3. Run the downloaded installer and follow the prompts 4. After installation, close and reopen your terminal, then check again with node -v

Pro Tip

After installing Node.js, you must close and reopen your terminal for the node command to be recognized.

Pro Tip

If you use nvm (Node Version Manager), run nvm install --lts to install the latest LTS version.

Warning

Claude Code may not work properly on Node.js versions below v18. Use the latest LTS version.

Success!

node -v outputs a version number v18 or higher.
Terminal
# Check Node.js version
node -v
# Expected output: v22.13.1 (or similar)

# Also verify npm is available
npm -v
# Expected output: 10.9.2 (or similar)
2

Step 2: Install Claude Code

~2 min

Use npm (Node.js package manager) to install Claude Code globally. A global install means you can run the claude command from any folder on your system. Paste the command below into your terminal and press Enter. The download and installation takes about 1-2 minutes.

Pro Tip

If Claude Code is already installed, running the same command will update it to the latest version.

Warning

On Mac/Linux, if you get "EACCES: permission denied", try sudo npm install -g @anthropic-ai/claude-code instead.

Warning

On Windows, if you get an "execution policy" error, reopen PowerShell as Administrator and try again.

Success!

claude --version outputs a version number.
Terminal
# Install Claude Code globally
npm install -g @anthropic-ai/claude-code

# Verify the installation
claude --version
3

Step 3: Set Up Authentication

~3 min

When you run Claude Code for the first time, you need to authenticate with your Anthropic account. Choose one of two authentication methods. [Option 1: Browser OAuth Login (Recommended)] Best for Claude Pro or Max subscribers. 1. Type claude in your terminal and press Enter 2. A browser window opens automatically with the Anthropic login page 3. Log in with your Claude account 4. Once authenticated, you will see a confirmation message in the terminal 5. Your session stays authenticated going forward [Option 2: API Key] For developers who want to use an API key with usage-based billing. 1. Go to console.anthropic.com → API Keys → create a new key 2. Set the environment variable in your terminal (see code below) 3. Run claude — it will use the API key automatically

Pro Tip

The browser login only needs to be done once. Your authentication persists across sessions.

Pro Tip

If using an API key, you can monitor usage and costs at console.anthropic.com.

Warning

Never share your API key or hardcode it in source files. Always use environment variables.

Success!

After running claude, the interactive prompt (>) appears without authentication errors.
Terminal
# Option 1: Browser login (just run claude)
claude
# → Browser opens automatically to login page
# → After login, you're ready to use Claude Code

# Option 2: Set API key as environment variable
# Mac/Linux:
export ANTHROPIC_API_KEY="sk-ant-xxxxx"

# Windows PowerShell:
$env:ANTHROPIC_API_KEY="sk-ant-xxxxx"

# Make it permanent (Mac/Linux — add to ~/.bashrc or ~/.zshrc)
echo 'export ANTHROPIC_API_KEY="sk-ant-xxxxx"' >> ~/.zshrc
source ~/.zshrc
4

Step 4: Start in Your Project Folder

~2 min

Claude Code can read and modify files in your current directory. So you need to navigate to your project folder before running claude. [If you have an existing project] Navigate to that folder and run claude. [If you are starting a new project] Create an empty folder, navigate into it, and run claude. You can then ask Claude to set up the project for you. When Claude Code starts, it scans the folder structure and, if a CLAUDE.md file exists, automatically loads project-specific rules and conventions.

Pro Tip

Running Claude Code inside a Git repository gives it access to git history and diffs, which leads to more accurate responses.

Pro Tip

Create a CLAUDE.md file in your project root with project rules and conventions — Claude will read it automatically.

Success!

The interactive prompt appears in your project folder.
Terminal
# Navigate to an existing project
cd ~/my-project
claude

# Or create a new project folder
mkdir my-new-app
cd my-new-app
claude
5

Step 5: Send Your First Command

~5 min

Now let's send an actual command to Claude Code. Just type in natural language — English or any language Claude supports. Claude Code can read files, edit files, create new files, and run terminal commands. Before modifying files or running commands, it will ask for your approval. Here are three prompt examples for different scenarios. Pick the one that matches your situation and type it in.

Pro Tip

Start with read-only requests like "explain this project" to get comfortable before requesting changes.

Pro Tip

Be specific in your requests. "Fix the code" is vague — "Add password validation to the login API handler" is much better.

Pro Tip

Review Claude Code's proposed changes carefully. If the approach isn't what you want, say "try a different approach" to get alternatives.

Success!

Claude Code analyzes your project files and produces a meaningful response.
Claude Code
# Example 1: Understand an existing project
> Explain the overall structure and key files in this project

# Example 2: Modify existing code
> Add a function to src/utils/format.ts that formats dates as "January 1, 2025"

# Example 3: Start a new project from scratch
> Set up a Next.js + TypeScript + Tailwind CSS project in this folder

# When Claude Code wants to modify a file or run a command,
# it shows an "Allow?" prompt.
# Type y to approve, n to deny.
6

Step 6: Essential Commands to Know

~3 min

Besides natural language chat, Claude Code has built-in slash commands that help you work more efficiently. These are typed directly into the Claude Code prompt.

Pro Tip

/compact is extremely useful for saving tokens while preserving context in long conversations.

Pro Tip

Non-interactive mode (-p) is great for automation in scripts or CI/CD pipelines.

Pro Tip

Ctrl+C only stops the current response. To exit Claude Code entirely, use Ctrl+D or /exit.

Success!

Type /help and see the full list of available commands — setup is complete!
Claude Code
# Help — list all available commands
/help

# Clear conversation — start fresh on a new topic
/clear

# Check session cost
/cost

# Compact context — compress long conversations to save tokens
/compact

# Stop current response — if Claude is going on too long
Ctrl+C

...

Core Code

Follow these 6 steps to go from zero to your first Claude Code command. After this, you can freely ask Claude to analyze, edit, and generate code using natural language.

# === Claude Code Quickstart — Full Flow Summary ===

# 1. Verify Node.js
node -v                  # Must be v18 or higher

# 2. Install Claude Code
npm install -g @anthropic-ai/claude-code

# 3. Authenticate (choose one)
claude                   # Browser OAuth login
# OR
export ANTHROPIC_API_KEY="sk-ant-xxxxx"

# 4. Start in your project folder
cd my-project
...

Common Mistakes

Running npm install without Node.js installed

Claude Code runs on Node.js. Install the LTS version from nodejs.org first. After installation, restart your terminal and verify with node -v.

Getting "permission denied" on Mac/Linux and not knowing how to fix it

Run sudo npm install -g @anthropic-ai/claude-code to install with admin privileges. Alternatively, use nvm to manage Node.js — it allows global installs without sudo.

Running claude without authentication and getting auth errors

Claude Code requires authentication. Complete either the browser login (Pro/Max subscription) or set the ANTHROPIC_API_KEY environment variable before running claude.

Running claude in the home directory (~) instead of a project folder

Claude Code operates on files in the current directory. Always cd into your project folder first. Running from the home directory may cause Claude to scan irrelevant files.

Read Next

Related liminfo Services