How to Install and Set Up Claude Code CLI — Complete Guide 2026
Step-by-step guide to installing Claude Code CLI on Windows, Mac, and Linux. From first install to your first automated project.
Last month I installed Claude Code CLI on a fresh Windows machine. Three weeks later, it had written 6 books, generated 40 YouTube scripts, and built the website you’re reading right now.
But the installation? That took me 45 minutes of Googling because the documentation assumes you already know what you’re doing.
This guide is the one I wish I’d found. Every step, every gotcha, every “why isn’t this working” moment — solved.
What Is Claude Code CLI?
Claude Code is Anthropic’s command-line interface for Claude. Think of it as having Claude inside your terminal — not through a browser chat, but as an actual development tool that can read your files, run commands, and build things alongside you.
The key difference from the web chat:
- It sees your project files — no more copy-pasting code into a chat window
- It can run commands — execute Python scripts, git operations, npm installs
- It remembers context — CLAUDE.md files tell it about your project permanently
- It works with your IDE — VS Code extension available
Prerequisites
Before we start, you need:
- Node.js 18+ — Claude Code runs on Node. Check with
node --version - An Anthropic API key — Get one at console.anthropic.com
- A terminal — PowerShell on Windows, Terminal on Mac, any shell on Linux
Don’t have Node.js? Here’s the fastest path:
# Windows (via winget)
winget install OpenJS.NodeJS.LTS
# Mac (via Homebrew)
brew install node
# Linux (via nvm — recommended)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
nvm install --lts
Installation
The actual installation is one command:
npm install -g @anthropic-ai/claude-code
That’s it. Seriously. If you have Node.js, this takes about 30 seconds.
Verify it worked:
claude --version
You should see something like Claude Code v1.x.x.
Windows-Specific Gotcha
On Windows, you might get a permissions error. Two fixes:
Option A — Run PowerShell as Administrator:
# Right-click PowerShell → Run as Administrator
npm install -g @anthropic-ai/claude-code
Option B — Use the --prefix flag:
npm install -g @anthropic-ai/claude-code --prefix "$env:USERPROFILE\.npm-global"
Then add %USERPROFILE%\.npm-global to your PATH environment variable.
First-Time Setup
When you run claude for the first time, it’ll ask for your API key:
cd your-project-folder
claude
It stores the key securely — you only enter it once.
Pro tip: Set it as an environment variable
Instead of entering it interactively, set it in your shell profile:
# Bash/Zsh (~/.bashrc or ~/.zshrc)
export ANTHROPIC_API_KEY="sk-ant-your-key-here"
# PowerShell ($PROFILE)
$env:ANTHROPIC_API_KEY = "sk-ant-your-key-here"
The CLAUDE.md File — Your Secret Weapon
This is where Claude Code goes from “useful” to “insanely powerful.”
Create a file called CLAUDE.md in your project root. This file tells Claude everything about your project — and it reads it automatically every time you start a session.
Here’s a minimal example:
# CLAUDE.md
## Project Overview
This is a Python automation project for generating ebooks.
## Rules
- Always use Python 3.11+
- All scripts go in the Content/ directory
- Use .env files for API keys, never hardcode them
- When I say "skill", I mean a Python script
## File Structure
Content/ - Production scripts
Research/ - Analytics scripts
Outlines/ - Book outlines (JSON)
With this file in place, Claude already knows:
- What your project does
- Where files should go
- What conventions to follow
- What terminology you use
Advanced CLAUDE.md Patterns
After months of using Claude Code daily, here’s what I’ve learned about effective CLAUDE.md files:
Be specific about what NOT to do:
## Rules
- NEVER modify files in Finished Books/ — those are published
- NEVER hardcode API keys — always use os.environ
- Don't ask permission, just execute the task
Include your tech stack:
## Tech Stack
- Python 3.11 with pathlib for all file operations
- OpenAI client library for Grok API (base_url: https://api.x.ai/v1)
- python-docx for document assembly
- Playwright for web scraping
Define your workflow:
## Production Pipeline
1. book_planner.py → generates outline.json
2. grok_writer.py → writes all chapters
3. claude_reviewer.py → quality review
4. book_assembler.py → creates .docx
5. kdp_packager.py → generates KDP metadata
Your First Project with Claude Code
Let’s build something real. We’ll create a simple Python script that summarizes a text file using Claude.
mkdir my-first-project
cd my-first-project
claude
Now just tell Claude what to build:
Create a Python script called summarize.py that:
1. Reads a text file from the command line argument
2. Sends it to Claude API for summarization
3. Prints the summary
4. Saves it to summary.txt
Claude will:
- Create the file
- Write working Python code
- Handle edge cases (missing file, API errors)
- Add proper argument parsing
This is the fundamental shift. You’re not writing code anymore — you’re describing what you want, and Claude writes it. Then you iterate: “Make the summary shorter” or “Add a —length flag.”
Tips From 3 Months of Daily Use
1. Start sessions by reading context
When you open a new session, Claude doesn’t remember your last conversation. But it always reads CLAUDE.md. So put everything important there.
I also use a session_handoff.md file that tracks what I did last session:
# Session Handoff
## Last session: 2026-03-18
### What was done
- Wrote chapters 1-6 of "AI Builder's Guide"
- Fixed keyword research pipeline
### Next steps
- Review chapters with claude_reviewer.py
- Generate KDP package
2. Let Claude read before it writes
Never ask Claude to modify code it hasn’t read. Always say “Read file X and then change Y” — not just “Change Y in file X.” The results are dramatically better when Claude understands the full context.
3. Use Claude for the boring stuff
Claude Code isn’t just for writing code. I use it to:
- Rename 200 files in a specific pattern
- Generate JSON configs from templates
- Search my codebase for patterns
- Write git commit messages
- Review my own code for bugs
4. The CLAUDE.md stack
You can have multiple CLAUDE.md files:
- Project root: General rules for the whole workspace
- Subdirectory: Specific rules for that brand/module
- User-level: Rules that apply to ALL your projects
Claude reads all of them, with the most specific one taking priority.
What Claude Code Costs
Let’s talk money, because nobody else does.
Claude Code uses the Anthropic API, which charges per token:
- Claude Sonnet: ~$3 per million input tokens, ~$15 per million output tokens
- Claude Opus: ~$15 per million input tokens, ~$75 per million output tokens
In practice, a typical day of heavy Claude Code usage (writing scripts, reviewing code, generating content) costs me $5-15/day. Some days less, some days more.
Monthly: $100-300 for daily, intensive use.
Is it worth it? My AI automation generates significantly more than that in revenue. So yes — but only because I use it to build things that make money, not just to chat.
What’s Next
You’ve got Claude Code installed, configured, and running. Now what?
- Build a CLAUDE.md for your project — start simple, add rules as you learn
- Automate one thing — pick the most boring, repetitive task you do and ask Claude to script it
- Iterate — the first version won’t be perfect. Tell Claude what to fix and let it improve
If you want a deeper dive into what you can build with Claude Code, check out my book Claude Code: The Developer’s Handbook — it covers the full pipeline from setup to production automation.
And if you want to see me build things live, subscribe to my YouTube channel where I document the entire process.
Have questions about Claude Code? Drop them in the comments or find me on LinkedIn. I read everything.
Get the free AI Toolkit Cheatsheet
Plus weekly insights on building with AI. No spam, unsubscribe anytime.