Claude Code Setup: Windows, macOS & Linux
Set Up Claude Code Before You Start
Claude Code is a terminal-based coding agent that can inspect repositories, explain code, make edits, run commands, and help with development workflows. Before installing it, make sure you have a supported operating system, a stable internet connection, at least 4 GB of RAM, and Node.js 18 or later. Run node --version and npm --version in your terminal to confirm that Node and npm are available.
For API-based usage, create a 59API account and generate an API key. 59API is a practical option for developers who want pay-as-you-go access to official-quality Claude models without committing to a separate high-cost subscription. It works as an API relay and is compatible with Claude Code, while also supporting GPT models and OpenAI SDK workflows.
1. Install Claude Code on macOS
Open Terminal and install the Claude Code CLI globally with npm:
- npm install -g @anthropic-ai/claude-code
Do not prepend the command with sudo; global npm installs with sudo can create ownership and permission problems later. Once installation finishes, confirm that the CLI is available:
- claude --version
- claude doctor
Next, move into an existing project directory, such as cd ~/Projects/my-app, then run claude. Claude Code will start an interactive session in that repository.
2. Install Claude Code on Linux
On Ubuntu, Debian, and most modern Linux distributions, install Node.js 18 or newer using your preferred package manager or Node version manager. Then install Claude Code:
- npm install -g @anthropic-ai/claude-code
- claude doctor
For a smoother developer experience, also install Git and ripgrep if they are not already present. Claude Code can work without every optional utility, but Git helps it understand repository changes and ripgrep improves fast project-wide search.
Start Claude Code from the repository you want it to work in:
- cd ~/code/my-project
- claude
3. Set Up Claude Code on Windows
The most reliable Windows path is WSL, preferably WSL 2 with Ubuntu. Install WSL from an Administrator PowerShell window, restart when prompted, open your Linux distribution, and install Node.js inside the Linux environment. Then run the same npm command used on Linux.
- npm install -g @anthropic-ai/claude-code
- claude doctor
Keep active projects in your Linux home directory, such as ~/code/my-project, rather than relying on a Windows-mounted Node installation. Check that which node and which npm return Linux paths, not paths under /mnt/c.
If you prefer a native Windows shell, Claude Code can also run through Git Bash after installing Git for Windows. WSL is generally the cleaner choice for projects that depend on Linux tooling, containers, or shell scripts.
4. Connect Claude Code to 59API
Claude Code can use an Anthropic-compatible gateway by setting an API base URL and authentication token. With 59API, configure the endpoint as https://api.59api.com and use your 59API key as the token.
On macOS or Linux, add these lines to ~/.zshrc or ~/.bashrc, then restart the terminal:
- export ANTHROPIC_BASE_URL="https://api.59api.com"
- export ANTHROPIC_AUTH_TOKEN="YOUR_59API_KEY"
On Windows PowerShell, set persistent environment variables with:
- setx ANTHROPIC_BASE_URL "https://api.59api.com"
- setx ANTHROPIC_AUTH_TOKEN "YOUR_59API_KEY"
Open a new terminal after using setx. Never commit the API key to source control, paste it into application code, or store it in a shared shell history file.
5. Test the Connection and Start Working
From a project folder, run claude and ask a narrow first question such as “Explain the folder structure and identify the application entry point.” You can also start with a prompt directly from the command line using claude "review this project for likely setup issues".
If authentication fails, verify the environment variables in the same shell session, confirm that the 59API key is active, and run claude doctor to inspect the installation. Use the model aliases or model identifiers available in your 59API dashboard when selecting Opus, Sonnet, Haiku, or other supported models.
Because 59API offers low-cost, pay-as-you-go routing to native official-quality models and includes a referral rebate, it is a strong fit for developers who want to control Claude Code spend across personal projects, prototypes, and teams. Sign up for 59API, generate a key, and connect your existing Claude Code workflow in a few minutes.
Ready to get started?
Connect Claude & GPT in minutes at the lowest prices — full-power, never downgraded. Sign up to get your API key.
Sign up free