1.1 What is Claude Code CLI?
A command-line tool that lets you direct an AI to write code using natural language, right from your terminal.
It is a separate program from Claude.ai in the web browser, and is launched with the claude command after installation.
1.2 Prerequisites
| Item | Requirement |
|---|---|
| Operating System | Windows 10+, Ubuntu 20.04+, macOS 10.15+ |
| Account | Claude Pro / Max / Teams / Enterprise (free plan not supported) |
| Internet | Required for installation and use |
| RAM / Disk | 4GB+ / 500MB+ |
Installation Method Comparison
| Method | Node.js | Auto-update | Notes |
|---|---|---|---|
| ① Native | Not required | ✅ | ⭐ Officially recommended |
| ② WinGet (Windows only) | Not required | ❌ Manual | |
| ③ npm | 18+ required | ❌ Manual | ⛔ Deprecated |
1.3 Windows PowerShell
① Native Installation (Recommended)
Prerequisites — Install Git for Windows
Claude Code uses Git Bash internally, so this is required.
- Download from https://git-scm.com → install with default settings
- Verify:
git --version
Installation
irm https://claude.ai/install.ps1 | iex
irm(downloads the script from the web) →iex(executes it)
Verify — Close PowerShell, open a new window, then run
claude --version
If you see a "claude is not recognized" error
[Environment]::SetEnvironmentVariable("PATH", "$env:PATH;$env:USERPROFILE\.local\bin", [EnvironmentVariableTarget]::User)
→ Restart PowerShell and verify again
② WinGet Installation
winget install Anthropic.ClaudeCode
Auto-update is not supported. To update manually:
winget upgrade Anthropic.ClaudeCode
③ npm Installation (⛔ Deprecated)
🚨 Deprecation notice. Do not use for new installations.
# Node.js 18+ must be installed beforehand (https://nodejs.org LTS version)
npm install -g @anthropic-ai/claude-code
claude --version
Migrating from npm to Native
irm https://claude.ai/install.ps1 | iex # Install native
npm uninstall -g @anthropic-ai/claude-code # Remove npm package
Your settings (
~/.claude/) are preserved during migration.
1.4 Ubuntu Terminal
① Native Installation (Recommended)
Installation
curl -fsSL https://claude.ai/install.sh | bash
curl(downloads the script from the web) →bash(executes it)
Verify — Restart the terminal or run source ~/.bashrc, then run
claude --version
If you see a "command not found" error
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
② npm Installation (⛔ Deprecated)
🚨 Deprecation notice. Do not use for new installations.
# Install Node.js
sudo apt update && sudo apt install -y nodejs npm
# Configure global installs without sudo
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
# Install Claude Code
npm install -g @anthropic-ai/claude-code
claude --version
Migrating from npm to Native
curl -fsSL https://claude.ai/install.sh | bash # Install native
npm uninstall -g @anthropic-ai/claude-code # Remove npm package
1.5 First Launch and Authentication (All Platforms)
cd ~/my-project # Navigate to your project folder
claude # Launch
- A browser window opens automatically → sign in with your Claude.ai account
- Authentication complete → automatically reflected in the terminal (no re-authentication needed afterward)
For headless environments (servers, etc.):
export ANTHROPIC_API_KEY=sk-ant-xxxxxxxxxxxxxxxx
1.6 Diagnostics, Updates, and Uninstallation
Diagnostics
claude doctor
Updates
| Method | Command |
|---|---|
| Native | Automatic (no action needed) |
| WinGet | winget upgrade Anthropic.ClaudeCode |
| npm | npm update -g @anthropic-ai/claude-code |
Uninstallation
claude uninstall # Native
winget uninstall Anthropic.ClaudeCode # WinGet (Windows)
npm uninstall -g @anthropic-ai/claude-code # npm
rm -rf ~/.claude # Remove settings files (optional)
1.7 Quick Command Reference
Windows PowerShell
# Native (recommended)
irm https://claude.ai/install.ps1 | iex
# WinGet
winget install Anthropic.ClaudeCode
# npm (⛔ Deprecated)
npm install -g @anthropic-ai/claude-code
# Common
claude --version # Check version
claude # Launch
claude doctor # Diagnostics
claude uninstall # Uninstall
Ubuntu Terminal
# Native (recommended)
curl -fsSL https://claude.ai/install.sh | bash
# npm (⛔ Deprecated)
npm install -g @anthropic-ai/claude-code
# Common
claude --version # Check version
claude # Launch
claude doctor # Diagnostics
claude uninstall # Uninstall
1.8 Glossary
| Term | Definition |
|---|---|
| CLI | A method of controlling a computer using keyboard commands |
| Terminal | A program used to enter CLI commands (e.g., PowerShell, Terminal) |
| PATH | The list of directories the OS searches when looking for programs |
| npm | The Node.js package manager |
| WinGet | The official Windows package manager |
| Deprecated | Scheduled for removal; currently functional but may be dropped in a future release |
| OAuth | An authentication method that works through a browser |
| API Key | A credential used to authenticate with a service |
Reference: https://code.claude.com/docs/en/setup | https://github.com/anthropics/claude-code
Top comments (0)