5 Installing Claude Code
Now for the main event: installing Claude Code.
5.1 Prerequisites Check
Before installing, let’s verify you have what you need.
5.1.1 Node.js
Claude Code requires Node.js. Check if you have it:
node --versionIf you see a version number (v18 or higher), you’re good. If you see “command not found”, install Node.js:
Mac (with Homebrew):
brew install nodeMac (without Homebrew): Download from nodejs.org (LTS version)
Windows: Download from nodejs.org (LTS version)
Linux:
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejsVerify after installation:
node --version
npm --version5.2 Install Claude Code
Claude Code is installed via npm (Node Package Manager):
npm install -g @anthropic-ai/claude-codeThe -g flag installs it globally so you can use it from any directory.
If you see permission errors, you have a few options:
Option 1: Use sudo (quick but not ideal)
sudo npm install -g @anthropic-ai/claude-codeOption 2: Fix npm permissions (better)
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
npm install -g @anthropic-ai/claude-codeVerify the installation:
claude --versionYou should see the Claude Code version number.
5.3 First Launch and Authentication
Navigate to a project folder and launch Claude Code:
cd ~/Projects
claudeOn first launch, Claude Code will ask you to authenticate with Anthropic.
5.3.1 Authentication Flow
- Claude Code will display a URL and a code
- Open the URL in your browser
- Log in to your Anthropic account if needed
- Enter the code to authorize Claude Code
- Return to your terminal—you should be connected
If the browser flow doesn’t work, you can set your API key directly:
export ANTHROPIC_API_KEY="sk-ant-api03-your-key-here"Add this line to your ~/.bashrc or ~/.zshrc to make it permanent.
5.4 Your First Conversation
Once authenticated, you’ll see something like:
╭─────────────────────────────────────────────────────────────╮
│ Claude Code │
│ Model: claude-sonnet-4 │
╰─────────────────────────────────────────────────────────────╯
You are in: /Users/yourname/Projects
>
Let’s try a simple command:
> What files are in this directory?
Claude will read your directory and respond. Try a few more:
> Create a file called hello.py that prints "Hello, World!"
Claude will show you the file it wants to create and ask for approval. Type y to accept.
> Run the Python file
Claude will execute it and show you the output.
5.5 Understanding the Interface
5.5.1 The Prompt
The > is where you type. Just describe what you want in plain English.
5.5.2 Tool Usage
Claude Code uses “tools” to interact with your computer: - Read: Look at files - Write: Create or modify files - Bash: Run terminal commands
When Claude wants to use a tool, it will show you what it plans to do and ask for approval.
5.5.3 Approval Workflow
For safety, Claude Code asks permission before: - Creating or modifying files - Running commands
You can: - Type y or press Enter to approve - Type n to reject - Type something else to give feedback
5.5.4 Exiting
To exit Claude Code: - Type exit or quit - Press Ctrl + C - Type /exit
5.6 Configuration (Optional)
Claude Code can be configured via a config file at ~/.claude/config.json:
{
"model": "claude-sonnet-4-20250514",
"theme": "dark"
}Common settings: - model: Which Claude model to use - theme: Terminal color theme
5.7 Verify Everything Works
Let’s do a complete test:
cd ~/Projects
mkdir claude-test
cd claude-test
claudeIn Claude Code:
> Initialize this as a git repository with a README that says "Testing Claude Code"
Accept the changes, then:
> Show me the git log
You should see your initial commit.
Congratulations—Claude Code is installed and working!
5.8 Next Steps
You’re ready to learn how to actually use Claude Code. Let’s understand the core workflow.
Continue to Part 2: The Basics.