How to Install Claude Code on Linux, macOS & WSL
What is Claude Code?
Claude Code is Anthropicâs CLI tool for AI-powered coding directly in your terminal. It reads your codebase, edits files, runs commands, and handles multi-step tasks autonomously.
Iâve been using it daily for a month. The biggest difference from other AI tools: it understands project-wide context. You say ârefactor the auth moduleâ and it reads every related file before making changes.
Installation Demo
Full installation recorded on a fresh Ubuntu machine. Scrub the timeline or adjust playback speed:
How to Install Claude Code
Prerequisites
- Node.js 18+ (for npm method) or any Linux/macOS system (for native installer)
- A terminal (bash, zsh, fish all work)
- An Anthropic account
Step 1: Run the Installer
# Recommended: native installer (auto-updates)
curl -fsSL https://claude.ai/install.sh | bash
# Alternative: macOS via Homebrew
brew install --cask claude-code
# Alternative: npm (won't auto-update)
npm install -g @anthropic-ai/claude-code
The native installer is preferred â it handles updates silently in the background.
Done when: claude --version prints a version number.
Step 2: Authenticate
claude
First run opens your browser for OAuth. Authorize, and youâre in.
Done when: You see the Claude Code prompt > in your terminal.
Step 3: Verify It Works
claude "What directory am I in? List the files."
If it responds with your current directory listing, everything is working.
How to Configure a Custom API Endpoint
If youâre using a third-party API service or self-hosted proxy, edit ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "sk-your-key-here",
"ANTHROPIC_BASE_URL": "https://your-proxy.example.com"
}
}
This routes all requests through your endpoint. Useful for teams with centralized API management or regional compliance requirements.
What Can Claude Code Actually Do?
| Task | Example Command | What Happens |
|---|---|---|
| Explain code | claude "Explain the auth flow in this project" | Reads relevant files, outputs explanation |
| Build features | claude "Add pagination to the /users endpoint" | Edits multiple files, runs tests |
| Fix bugs | claude "Tests are failing, fix them" | Reads error output, patches code |
| Refactor | claude "Split this 500-line file into modules" | Creates new files, updates imports |
| Code review | claude "Review my last commit" | Reads git diff, gives feedback |
How Does Claude Code Compare to Other Tools?
| Claude Code | GitHub Copilot | Cursor | Codex CLI | |
|---|---|---|---|---|
| Interface | Terminal CLI | Editor plugin | Full IDE | Terminal CLI |
| Autonomy | Full (reads/writes/executes) | Suggestions only | Semi-autonomous | Full |
| Context | 200K tokens (whole repo) | Single file | Project-wide | 200K tokens |
| Open source | No | No | No | Yes (Apache-2.0) |
| Best for | Complex refactoring, automation | Line completions | Interactive editing | Quick tasks, open ecosystem |
Tips From Daily Use
- Always start from your project root. Claude Code reads the directory tree to understand context. Starting from
~gives it nothing to work with. - Use multi-turn conversations. Donât restart for follow-ups. Say ânow add tests for thatâ after a feature implementation.
- Pair with tmux for long tasks. Claude Code can run for minutes on complex refactors. Tmux keeps the session alive if your connection drops.
- Check the
/costcommand. It shows token usage for the current session. Useful for budgeting.
Troubleshooting
âAuthentication failedâ on first run
Your browser might have blocked the OAuth popup. Try:
claude --login
This prints a URL you can manually paste into your browser.
Slow responses or timeouts
Usually a network issue. Test your connection to the API:
curl -I https://api.anthropic.com/v1/messages
If this times out, check your firewall or proxy settings.
âModel not availableâ error
Your subscription tier may not include the model youâre requesting. Claude Pro gets Sonnet; Claude Max gets Opus. Check your plan at console.anthropic.com.
Links
- Claude Code Official Docs
- Anthropic Console (API keys & billing)
- Claude Code Changelog