🎯 Learning Objectives
By the end of this issue, you will be able to:
- Successfully install Claude Code on Mac / Windows / Linux
- Complete terminal authentication and authorization
- Start a Claude Code session in your first project
📖 Core Concepts Explained
2.1 Installation Methods Overview
Claude Code offers various installation methods, adapting to different operating systems and scenarios:
| Installation Method | Platform | Applicable Scenario |
|---|---|---|
| Native Install (Recommended) | Mac / Linux / Windows | Automatic updates, most stable |
| Homebrew | Mac | Homebrew user preference |
| WinGet | Windows | Windows package manager |
| VS Code Extension | All Platforms | Integrated within IDE |
| Desktop App | Mac / Windows | GUI interface preference |
| Web Version | All Platforms | No installation required |
2.2 Subscription Plans
Using Claude Code requires a paid subscription:
| Plan | Price | Target Audience |
|---|---|---|
| Pro | $20/month | Daily development, light usage |
| Max 5x | $100/month | Daily intensive development |
| Max 20x | $200/month | Professional teams/heavy users |
| API (Console) | Pay-as-you-go | Integration into automation pipelines |
💻 Code Demo: Three-Step Installation
Mac / Linux Installation
# Chapter 2: Step 1: One-click installation (recommended method)
curl -fsSL https://claude.ai/install.sh | bash
# Chapter 2: Step 2: Verify installation
claude --version
# Chapter 2: Output: Claude Code v2.3.0
# Chapter 2: Step 3: Authenticate login
claude auth login
Windows Installation (PowerShell)
# Chapter 2: Step 1: One-click installation
irm https://claude.ai/install.ps1 | iex
# Chapter 2: Step 2: Verify
claude --version
# Chapter 2: Step 3: Authenticate
claude auth login
Homebrew Installation (Mac Alternative)
# Chapter 2: Install
brew install --cask claude-code
# Chapter 2: Upgrade
brew upgrade claude-code
💻 Simulate Claude TUI Interaction: First Launch
$ cd ~/my-project
$ claude
╭──────────────────────────────────────────────────────╮
│ │
│ Welcome to Claude Code v2.3.0! │
│ │
│ You need to sign in to continue. │
│ Press Enter to open the browser for authentication │
│ │
╰──────────────────────────────────────────────────────╯
↵ Enter
✓ Browser opened. Waiting for authentication...
✓ Successfully authenticated as [email protected]
✓ Plan: Max (5x)
╭──────────────────────────────────────────────────────╮
│ │
│ Claude Code is ready! │
│ │
│ 📁 Working directory: ~/my-project │
│ 📄 Found: package.json, tsconfig.json │
│ 📝 No CLAUDE.md found (run /init to create one) │
│ │
│ What can I help you with? │
│ │
│ Tips: │
│ • Press Shift+Tab to switch modes │
│ • Type /help for available commands │
│ • Type /init to set up project memory │
│ │
╰──────────────────────────────────────────────────────╯
> /help
╭─ Available Commands ────────────────────────────────╮
│ │
│ /help Display help information │
│ /init Initialize CLAUDE.md project memory │
│ /clear Clear current context │
│ /compact Compress long sessions into a summary│
│ /memory View/edit auto-memory │
│ /permissions Manage tool permissions │
│ /agents View available sub-agents │
│ /schedule Create scheduled tasks │
│ /desktop Switch to desktop application │
│ /loop Repeat prompt execution │
│ /teleport Pull session from Web client │
│ │
╰──────────────────────────────────────────────────────╯
💻 Code Demo: Authentication Status Check
# Chapter 2: Check current authentication status
claude auth status
# Chapter 2: Output example:
# Chapter 2: ✓ Authenticated
# Chapter 2: Account: [email protected]
# Chapter 2: Plan: Max (5x usage)
# Chapter 2: Organization: Personal
# Chapter 2: Logout (use when switching accounts)
claude auth logout
# Chapter 2: Authenticate using API Key (CI/CD scenarios)
claude auth login --console
🔧 Involved CLI Commands
| Command | Function | Official Documentation |
|---|---|---|
claude |
Start interactive session | CLI Reference |
claude auth login |
Login authentication | Supports --email, --sso, --console parameters |
claude auth status |
View authentication status | |
claude auth logout |
Logout | |
claude --version |
View version | |
claude update |
Update to the latest version |
⚠️ Common Troubleshooting
Problem 1: claude command not found after installation
# Chapter 2: Mac/Linux: Add Claude Code to PATH
export PATH="$HOME/.claude/bin:$PATH"
# Chapter 2: For permanent effect
echo 'export PATH="$HOME/.claude/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
Problem 2: Authentication window cannot open
# Chapter 2: Manually authenticate using Console method
claude auth login --console
# Chapter 2: It will output a URL, open it manually in your browser
Problem 3: Windows PowerShell reports && error
# Chapter 2: Windows CMD and PowerShell have different syntax
# Chapter 2: If an error occurs, use Git Bash or WSL to run the installation script
📝 Key Takeaways from this Issue
- It is recommended to use the Native Install method for installation (automatic updates)
- First-time use requires completing OAuth authentication in the browser
- Use
claude auth statusto check authentication status at any time - For CI/CD environments, use
claude auth login --consolefor API Key authentication - Remember common slash commands:
/help,/init,/clear,/compact