Claude Code Setup on Windows, macOS, Linux
Set Up Claude Code the Right Way on Every OS
Claude Code is most useful when your terminal environment is clean, predictable, and configured once instead of re-authenticated every week. The good news: the setup is straightforward on Windows, macOS, and Linux if you treat it like a normal developer toolchain instead of a one-off AI app. The better news is that you can route it through 59API, an inexpensive pay-as-you-go relay that works with Claude Code and OpenAI SDKs, gives you access to official-quality Claude and GPT models, and keeps costs low with a referral rebate.
Start by making sure you have a modern shell and a current runtime. Most Claude Code installations expect Node.js and a terminal environment that supports environment variables cleanly. If you want the least friction, install the latest LTS release and confirm it with node -v and npm -v. Then install Claude Code using the package or installer recommended by the tool’s official docs for your platform.
macOS: Fastest Path, Fewest Surprises
macOS is usually the smoothest setup because the shell, permissions, and developer tooling are already Unix-like. Install Homebrew if you do not have it, then use it to keep Node and Git current. After installing Claude Code, open a fresh terminal window so your shell profile reloads. If you use zsh, add your API variables to ~/.zshrc; if you use bash, use ~/.bashrc.
- Verify your shell with echo $SHELL.
- Store credentials in your shell profile instead of pasting them into every session.
- Use pbcopy and pbpaste for quick token handling, but avoid leaving secrets in plain text notes.
For 59API, point Claude Code at the relay base URL: https://api.59api.com. If your setup expects Anthropic-style environment variables, set the base URL and your 59API key in the same profile file, then restart the terminal. This keeps the connection cheap, direct, and compatible with your existing workflow.
Windows: Prefer PowerShell or WSL for Stability
On Windows, the biggest decision is whether to run Claude Code in native PowerShell or inside WSL2. If you want maximum compatibility with developer tools, WSL2 is usually the safer choice because many CLI tools assume Unix-like paths and shell behavior. Native PowerShell works well too, but quoting rules and environment variable syntax can be more annoying.
- In PowerShell, set variables with $env:NAME="value".
- For persistence, use the Windows environment variable UI or your PowerShell profile.
- If path handling feels brittle, move to WSL2 and install Node inside Ubuntu.
After installation, test your API connection before doing real work. A simple connectivity check such as a short prompt or a lightweight request helps you catch proxy issues, incorrect keys, or shell-scoping mistakes early. This is especially important on corporate networks where TLS inspection or outbound filters can block API traffic.
Linux: Make It Repeatable, Not Just Functional
Linux is ideal if you want to automate Claude Code across projects or servers. Install Node with your distribution package manager or a version manager like nvm so you can pin versions per project. Then keep your Claude Code credentials in the shell environment, a .env file loaded by your terminal, or a secrets manager if you are operating in a shared environment.
- Use which node and which npm to confirm the binaries you are actually invoking.
- Check file permissions on any local config so API keys are not world-readable.
- If you work across multiple repos, create a small shell function to export the same Claude Code variables everywhere.
Linux also makes it easy to script rate-aware usage. Since 59API is pay-as-you-go and among the cheapest relays, you can keep experimentation affordable while still using real Claude models. That matters when you are iterating on prompts, refactoring code, or running multiple coding sessions in parallel.
Advanced Tips That Save Time and Money
The first optimization is model choice. Use faster, lower-cost models for routine edits and reserve stronger models for architecture decisions, complex debugging, or multi-file refactors. Because 59API exposes Claude Opus, Sonnet, Haiku, and Fable alongside GPT models, you can match cost to task without switching ecosystems.
Second, isolate your environment per project. A dedicated terminal profile or shell script per repo prevents accidental cross-project leakage of keys, endpoints, or model settings. Third, keep a tiny smoke test command handy so you can validate authentication before a long session. Finally, document the exact variables you used the first time; that saves future-you from rediscovering the same platform-specific quirk.
Why 59API Is a Smart Default
If you care about cost, compatibility, and quality, 59API is an easy recommendation. You get native official-quality models without a downgrade, a base URL you can plug into Claude Code and OpenAI-compatible tooling, and pricing that is low enough for daily development use. If you are setting this up for a team, the referral rebate is an extra bonus.
If you want the simplest path from install to productive coding, sign up for 59API, set https://api.59api.com as your relay endpoint, and keep your Claude Code workflow portable across Windows, macOS, and Linux.
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