A complete guide for installing Claude Code and configuring it for AI-assisted development workflows.
Click to expand Quick Start Guide
- Main docs: https://docs.anthropic.com/en/docs/claude-code
- Setup Guide: https://docs.anthropic.com/en/docs/claude-code/setup
- Windows Guide: https://docs.anthropic.com/en/docs/claude-code/setup/windows
- macOS Guide: https://docs.anthropic.com/en/docs/claude-code/setup/macos
- Linux Guide: https://docs.anthropic.com/en/docs/claude-code/setup/linux
- Getting Started: https://docs.anthropic.com/en/docs/claude-code/getting-started
# 1. Install via PowerShell (recommended)
irm https://claude.ai/install.ps1 | iex
# OR install via npm
npm install -g @anthropic-ai/claude-code
# 2. Verify installation
claude --version
# 3. Set up API key
claude auth login
# Follow browser authentication flow
# 4. Test basic command
claude "Hello, can you help me code?"
# 5. Set up editor integration
$env:EDITOR = "code --wait" # for VS Code
# Make persistent:
[Environment]::SetEnvironmentVariable("EDITOR", "code --wait", "User")
# 6. Test Ctrl+G (long prompt editing)
# Press Ctrl+G in Claude Code session# 1. Install via curl (recommended)
curl -fsSL https://claude.ai/install.sh | sh
# OR install via npm
npm install -g @anthropic-ai/claude-code
# 2. Verify installation
claude --version
# 3. Set up API key
claude auth login
# Follow browser authentication flow
# 4. Test basic command
claude "Hello, can you help me code?"
# 5. Set up editor integration
export EDITOR="code --wait" # for VS Code
echo 'export EDITOR="code --wait"' >> ~/.zshrc # persist
source ~/.zshrc
# 6. Test Ctrl+G (long prompt editing)
# Press Ctrl+G in Claude Code session# Test project context awareness
cd your-project
claude "analyze this codebase structure"
# Test multi-file editing
claude "refactor the authentication logic across all files"
# Test Ctrl+G for long prompts
# Press Ctrl+G β write detailed prompt in editor β save & closeNot working? Check official troubleshooting or jump to the detailed guide below.
Welcome! This guide will help you install Claude Code, Anthropic's AI-powered coding assistant, and set it up for seamless development workflows. Don't worry if you've never used an AI coding tool beforeβwe'll walk through every step together.
By the end of this guide, you'll be able to:
- Install Claude Code on your computer (Windows 11, macOS, or Linux)
- Authenticate with your Anthropic API key
- Use Claude Code for AI-assisted coding
- Set up editor integration for long prompts (Ctrl+G feature)
- Understand Claude Code's unique features
- Troubleshoot common installation issues
- Experienced users: 5-10 minutes (use Quick Start above)
- First-time installation: 20-30 minutes (follow detailed guide below)
- No computer restarts required
Click to expand Table of Contents
Quick Navigation:
Installation Instructions:
Authentication & Setup:
Getting Started:
Help & Support:
Additional Information:
Click to expand Glossary
Before we begin, let's clarify some terms you'll encounter:
| Term | What It Means |
|---|---|
| Claude Code | Anthropic's AI coding assistant that runs in your terminal |
| API Key | A secret password that lets you access Anthropic's AI services (like a digital key to unlock Claude Code) |
| Terminal | A text-based interface for giving commands to your computer (also called "Command Prompt" on Windows or "Terminal" on Mac/Linux) |
| Shell | The program that runs inside a terminal and interprets your commands (like PowerShell, zsh, or bash) |
| Command Line | Another name for the terminalβanywhere you type text commands |
| PATH | A list of folders your computer checks when you type a command, so it knows where to find programs |
| Environment Variable | A setting that tells programs on your computer how to behave (like EDITOR telling programs which text editor to use) |
| npm | Node Package Manager, a tool for installing JavaScript/Node.js programs (alternative installation method) |
| Ctrl+G | Keyboard shortcut in Claude Code that opens your text editor for writing long, complex prompts |
π Note: Don't worry if these terms are confusing nowβyou'll understand them better as we go through the installation!
Click to expand Environment Variables Guide (IMPORTANT for Beginners)
This section explains critical concepts you'll need to understand before installing Claude Code. These concepts are essential for Python, Data Science, and any command-line development work.
Simple Explanation: Environment variables are like sticky notes for your computer programs. They're named settings that tell programs where to find things and how to behave.
Real-World Analogy: Think of a cookie recipe that says "use SUGAR_TYPE" instead of specifying "white sugar." The SUGAR_TYPE is an environment variableβyou can change it to brown sugar or honey without rewriting the recipe.
Example: Instead of hardcoding in your Python script:
api_key = "sk-ant-api03-xyz123abc456..." # BAD - exposed in codeYou use an environment variable:
import os
api_key = os.getenv("ANTHROPIC_API_KEY") # GOOD - secureAs a Python coder or Data Science student, environment variables help you:
- Keep Secrets Safe: Store API keys outside your code (never commit keys to GitHub!)
- Work Anywhere: Same code works on your laptop, desktop, and cloud servers
- Collaborate Safely: Share code without sharing your personal API keys
- Switch Easily: Use different settings for development vs production
Common Variables You'll Use:
| Variable Name | What It Does | Example Value |
|---|---|---|
ANTHROPIC_API_KEY |
Your Claude API key | sk-ant-api03-... |
OPENAI_API_KEY |
OpenAI API key for GPT | sk-proj-... |
PATH |
Where to find programs | C:\Python311;C:\Users\you\.local\bin |
PYTHONPATH |
Where Python finds modules | C:\MyPythonLibs |
HOME |
Your user home directory | C:\Users\yourname |
Windows has two types of environment variables:
- Who sees them: Only YOUR user account
- Permissions needed: None (you can set these yourself)
- Safety: Can't break system-wide programs
- Best for: Installing tools just for yourself, API keys, personal settings
- Who sees them: ALL users on the computer
- Permissions needed: Administrator rights
- Safety: Could affect other users or system programs
- Best for: System-wide applications (avoid as a beginner)
Important: The PATH variable combines bothβSystem PATH is searched first, then your User PATH is appended.
Step-by-step:
- Press
Windows key + Rto open Run dialog - Type
sysdm.cpland press Enter - Click the Advanced tab
- Click Environment Variables button
- You'll see two sections:
- Top: User variables for your account β Start here
- Bottom: System variables (for all users)
![Environment Variables Window]
Alternative way:
- Press Windows key
- Type "environment"
- Click "Edit the system environment variables"
- Click Environment Variables button
# View ALL environment variables
Get-ChildItem Env:
# View a specific variable
$env:PATH
$env:ANTHROPIC_API_KEY
# View PATH entries one per line (easier to read)
$env:PATH -split ";"
# Check if something is in your PATH
$env:PATH -split ";" | Select-String "Python"# View all environment variables
env
# View specific variable
echo $PATH
echo $ANTHROPIC_API_KEY
# View PATH entries one per line
echo $PATH | tr ';' '\n'To create a new User environment variable (like for API keys):
- Open Environment Variables window (see "How to View" above)
- In the User variables section (top half), click New...
- Variable name: Type the name (e.g.,
ANTHROPIC_API_KEY) - Variable value: Paste your value (e.g., your API key)
- Click OK on all windows
- CRITICAL: Close and reopen ALL terminal windows
To add a directory to your PATH:
- Open Environment Variables window
- In User variables, select the Path variable
- Click Edit...
- Click New
- Type or paste the directory path (e.g.,
C:\Users\yourname\.local\bin) - Click OK on all windows
- CRITICAL: Close and reopen ALL terminals
# Set a new user environment variable
[Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", "your-api-key-here", [EnvironmentVariableTarget]::User)
# Add a directory to your user PATH
[Environment]::SetEnvironmentVariable("PATH", "$env:PATH;C:\Users\yourname\.local\bin", [EnvironmentVariableTarget]::User)
# β οΈ Remember to close and reopen terminals after this!# Set for this PowerShell window only (lost when you close it)
$env:ANTHROPIC_API_KEY = "your-api-key-here"
$env:PATH = "$env:PATH;C:\new\directory"When to use temporary: Testing, one-time tasks, or when you don't want permanent changes.
What is PATH? The most important environment variable you'll use.
Simple Explanation: PATH is a list of folders where Windows looks for executable programs when you type a command.
Analogy: Imagine PATH as a list of rooms where you keep tools. When you ask for a "hammer," Windows checks each room on the PATH list until it finds one.
When you type a command like python or claude:
- Check Current Folder: Windows first looks in your current directory
- Check PATH Folders: If not found, Windows checks each directory in PATH (left to right)
- Run First Match: When found, Windows runs that program
- Error if Not Found: If not in any PATH folder, you get "command not recognized"
Example:
Your PATH is:
C:\Windows\System32;C:\Python311;C:\Users\you\.local\bin
You type python:
- Check current folder β not found
- Check
C:\Windows\System32β not found - Check
C:\Python311β FOUNDpython.exeβ - Run it!
PowerShell (shows all directories in PATH):
# Hard to read (one long line)
$env:PATH
# Easy to read (one directory per line)
$env:PATH -split ";"Git Bash:
# Easy to read
echo $PATH | tr ';' '\n'After installing Claude Code, the installer adds its location to your PATH so you can type claude from anywhere:
Before PATH is updated:
PS C:\Users\you\Documents> claude --version
# Error: 'claude' is not recognized as a commandAfter PATH is updated:
PS C:\Users\you\Documents> claude --version
# claude version 1.2.3 β# DON'T DO THIS - Anyone who sees this code gets your API key!
api_key = "sk-ant-api03-xyz123abc456..."
client = anthropic.Client(api_key=api_key)β DO THIS (Environment Variable - GOOD):
# DO THIS - API key stored safely outside your code
import os
api_key = os.getenv("ANTHROPIC_API_KEY")
client = anthropic.Client(api_key=api_key)If you hardcode API keys:
- β Push to GitHub β Your key is public forever (even if you delete it later)
- β Share code β Everyone gets your key
- β Screenshot β Key is visible
- β Someone uses your key β You get charged for their usage
If you use environment variables:
- β Code can be shared safely
- β Different keys on different computers
- β Easy to rotate/change keys
- β Keys not in version control
- Never hardcode API keys in source code
- Use environment variables (Windows) or
.envfiles (projects) - Add
.envto.gitignore(never commit it to Git) - Rotate keys regularly (change them periodically)
- Limit permissions when creating API keys
- Monitor usage to detect unauthorized access
For project-specific API keys, use .env files:
Step 1: Install python-dotenv
pip install python-dotenvStep 2: Create .env file in your project
# .env
ANTHROPIC_API_KEY=sk-ant-api03-your-key-here
OPENAI_API_KEY=sk-proj-your-other-key-here
Step 3: Add .env to .gitignore
# .gitignore
.env
*.env
Step 4: Use in your Python code
from dotenv import load_dotenv
import os
# Load environment variables from .env file
load_dotenv()
# Access them
api_key = os.getenv("ANTHROPIC_API_KEY")
print(f"API key loaded: {api_key[:10]}...") # Print first 10 chars onlyProblem: You set an environment variable but programs don't see it.
Cause: Existing terminal windows don't automatically reload environment variables.
Solution:
- Close ALL terminal windows (PowerShell, Git Bash, VS Code terminals)
- Open a brand new terminal
- Check again:
$env:VARNAME(PowerShell) orecho $VARNAME(Git Bash)
Problem: You installed a program (like Python or Claude Code) but Windows says it's not recognized.
Diagnosis:
# Check if the directory is in your PATH
$env:PATH -split ";" | Select-String "Python"
$env:PATH -split ";" | Select-String "local"Solutions:
- Verify the program actually installed (find the
.exefile) - Add that directory to your PATH (see "How to Set" above)
- Close and reopen terminals
- If still not working, restart your computer
Problem: Windows has limits on PATH length (though increased in Windows 10+).
Solution:
- Remove unused directories from PATH
- Keep only what you actually use
- Use shorter directory names when possible
Problem: You have multiple versions installed and don't know which one is being used.
Check which one:
# PowerShell
Get-Command python | Select-Object Source
Get-Command claude | Select-Object Source
# Shows full path to the executable being used# Git Bash
which python
which claude# PowerShell
$env:VARIABLE_NAME
# Git Bash
echo $VARIABLE_NAME# PowerShell
$env:VARIABLE_NAME = "value"
# Git Bash
export VARIABLE_NAME="value"- Press
Windows + R - Type
sysdm.cpland press Enter - Advanced β Environment Variables
- Add or edit in User variables section
- Close and reopen all terminals
# PowerShell - one directory per line
$env:PATH -split ";"
# Git Bash
echo $PATH | tr ';' '\n'# PowerShell
$env:PATH -split ";" | Select-String "directory-name"
# Git Bash
echo $PATH | grep "directory-name"β You should now understand:
- Environment variables are settings that programs use
- User variables are safer for beginners than System variables
- PATH tells Windows where to find programs
- API keys should NEVER be hardcoded in code
- Changes require closing and reopening terminals
.envfiles are good for project-specific settings
β You should be able to:
- View environment variables using GUI or command line
- Set User environment variables using the GUI
- Add a directory to your PATH
- Understand why
claudeworks after installation - Store API keys securely
π Remember:
- Always close and reopen terminals after changing environment variables
- Use User variables (not System) as a beginner
- Never commit API keys to Git
- PATH contains directories, not file paths
Click to expand Prerequisites
Windows 11:
- Windows 11 (64-bit) or Windows 10
- PowerShell 5.1 or later (included by default)
- Internet connection for authentication
- Git for Windows (REQUIRED) - Includes Git Bash terminal
- Download from: https://git-scm.com/download/win
- Why required: Claude Code needs Unix-like shell environment (Git Bash provides this)
- Alternative: WSL (Windows Subsystem for Linux) if you prefer Linux environment
- GitHub CLI (Optional but Recommended) - Makes GitHub operations easier
- Download from: https://cli.github.com/
- What it does: Create PRs, issues, and manage repositories from command line
- When to install: If you frequently work with GitHub repositories
- Not required for: Basic Claude Code functionality
- Optional: Node.js 16+ (only if using npm installation method)
macOS:
- macOS 10.15 (Catalina) or later
- Terminal (included by default)
- curl (included by default)
- Internet connection for authentication
- Optional: Node.js 16+ (only if using npm installation method)
Linux:
- Most modern distributions (Ubuntu 20.04+, Fedora 34+, Debian 11+, etc.)
- bash or zsh shell
- curl (usually pre-installed)
- Internet connection for authentication
- Optional: Node.js 16+ (only if using npm installation method)
π Official System Requirements: https://docs.anthropic.com/en/docs/claude-code/requirements
You'll need an Anthropic account to use Claude Code:
- Create an account: Visit https://console.anthropic.com/
- Verify your email: Check your inbox for verification email
- Set up billing (if using Claude Code extensively):
- Claude Code uses Anthropic's API
- Free tier available for testing
- See pricing at https://console.anthropic.com/settings/billing
π Note: You don't need to pre-purchase anythingβClaude Code will walk you through authentication during setup.
- Download size: ~10-50 MB (varies by installation method)
- Installation time: 2-5 minutes
- Authentication time: 2-3 minutes
- Total setup time: 5-10 minutes
- Restarts needed: None
Choose your operating system below:
Click to expand Windows 11 Installation
π Official Windows Guide: https://docs.anthropic.com/en/docs/claude-code/setup/windows
Before installing Claude Code, you MUST install Git for Windows (which includes Git Bash):
- Download: https://git-scm.com/download/win
- Install: Run the installer and accept all defaults
- Verify: Open Git Bash and type
git --version
Why Git Bash is required:
- Claude Code needs a Unix-like shell environment on Windows
- Git Bash provides Linux/Unix commands that Claude Code relies on
- Most tutorials assume Unix-style commands
- Alternative: Use WSL (Windows Subsystem for Linux) instead
Can I skip Git Bash? No, Claude Code will not work properly on Windows without either Git Bash or WSL.
You have two options for installing Claude Code on Windows:
- PowerShell Script (Recommended) - Easiest, fastest, automatic setup
- npm Installation - If you already have Node.js and prefer npm
π Recommendation: Use the PowerShell script method unless you specifically need npm.
-
Press
Windows keyon your keyboard -
Type
powershell -
Right-click on Windows PowerShell
-
Click "Run as administrator"
-
Click "Yes" when Windows asks for permission
![PowerShell as Administrator]
β οΈ Warning: You need administrator privileges for the installation. If you don't have admin rights, use the npm method instead or ask your IT administrator.
-
Copy this command:
irm https://claude.ai/install.ps1 | iex
-
Paste it into PowerShell (right-click to paste, or press Ctrl+V)
-
Press Enter
-
Wait for the installation to complete (1-2 minutes)
You'll see output like:
Downloading Claude Code... Installing Claude Code... β Claude Code installed successfully
π― Quick Check: You should see "Claude Code installed successfully" at the end.
-
Close the PowerShell window completely
-
Open a NEW PowerShell window (you don't need admin rights this time):
- Press
Windows key - Type
powershell - Press Enter
- Press
-
Type this command and press Enter:
claude --version -
You should see output like:
claude-code version 1.2.3β Success! If you see a version number, Claude Code is installed!
β If you see "command not found" or "not recognized":
- Close PowerShell COMPLETELY
- Open a NEW PowerShell window
- Try
claude --versionagain - Still not working? See Troubleshooting Windows below
For beginners: Let's understand what just happened and where Claude Code lives on your computer.
Installation Location:
C:\Users\<YourUsername>\.local\bin\claude.exe
Example (if your username is "student"):
C:\Users\student\.local\bin\claude.exe
What is the .local folder?
- The dot (
.) makes it a hidden folder (won't show in normal file explorer) - It's a standard location for user-specific programs on Windows
- Similar to how Linux/Mac users store personal programs
Installation Scope: User-Level vs System-Level
Claude Code installs at the User level, which means:
β User-Level Installation (What Claude Code Does):
- Installed only for YOUR user account
- No administrator rights needed
- Doesn't affect other users on the computer
- Located in:
C:\Users\<YourUsername>\... - Added to your User PATH (not System PATH)
β System-Level Installation (What Claude Code Does NOT Do):
- NOT installed for all users
- NOT in
C:\Program Files\ - NOT in System PATH
Why This Matters for You:
- No Admin Rights Needed: You can install Claude Code even on school/work computers where you're not an administrator
- Personal Configuration: Your API keys and settings are private to your account
- Easy Removal: If you want to uninstall, just delete the
.localfolder - Won't Break Other Users: Your installation doesn't affect other people using the same computer
How the PATH Got Updated:
The PowerShell installer did this:
- Created the folder:
C:\Users\<YourUsername>\.local\bin\ - Downloaded
claude.exeinto that folder - Added that folder to your User PATH environment variable
- Now Windows knows where to find
claudewhen you type it
Verifying the Installation Location:
PowerShell:
# See where claude.exe actually is
Get-Command claude | Select-Object Source
# Output will be:
# C:\Users\<YourUsername>\.local\bin\claude.exeGit Bash (after you install Git):
# See where claude is located
which claude
# Output will be:
# /c/Users/<YourUsername>/.local/bin/claude.exeChecking Your PATH Was Updated:
# View your User PATH (one directory per line)
$env:PATH -split ";" | Select-String "\.local"
# You should see:
# C:\Users\<YourUsername>\.local\binWhat If I Want to See the Actual Files?
- Open File Explorer
- In the address bar, type:
%USERPROFILE%\.local\binand press Enter - You'll see
claude.exeand related files
Or use PowerShell:
# List files in the installation directory
Get-ChildItem "$env:USERPROFILE\.local\bin"Prerequisites: You need Node.js installed. Check with node --version. If not installed, get it from https://nodejs.org/
- Press
Windows key - Type
powershell - Press Enter (no admin rights needed for npm method)
-
Run this command:
npm install -g @anthropic-ai/claude-code
-
Wait for installation (2-3 minutes, depending on internet speed)
You'll see output like:
added 15 packages in 45s -
Verify installation:
claude --versionYou should see the version number.
π Note: The npm method requires you to update Claude Code manually with npm update -g @anthropic-ai/claude-code.
Installation complete! Now skip to Authentication Setup
Click to expand macOS/Linux Installation
π Official macOS Guide: https://docs.anthropic.com/en/docs/claude-code/setup/macos π Official Linux Guide: https://docs.anthropic.com/en/docs/claude-code/setup/linux
You have two options for installing Claude Code:
- curl Script (Recommended) - Easiest, fastest, automatic setup
- npm Installation - If you already have Node.js and prefer npm
π Recommendation: Use the curl script method unless you specifically need npm.
macOS:
- Press
Cmd + Spaceto open Spotlight - Type
terminal - Press Enter
Linux:
- Use your distribution's terminal (usually Ctrl+Alt+T or search for "Terminal" in applications)
-
Copy this command:
curl -fsSL https://claude.ai/install.sh | sh -
Paste it into Terminal (Cmd+V on Mac, Ctrl+Shift+V on Linux)
-
Press Enter
-
Enter your password if prompted (your typing won't showβthis is normal)
-
Wait for the installation to complete (1-2 minutes)
You'll see output like:
Downloading Claude Code... Installing Claude Code... β Claude Code installed successfully
π― Quick Check: You should see "Claude Code installed successfully" at the end.
-
In the same Terminal window, type:
claude --version
-
You should see output like:
claude-code version 1.2.3β Success! If you see a version number, Claude Code is installed!
β If you see "command not found":
- Close Terminal COMPLETELY
- Open a NEW Terminal window
- Try
claude --versionagain - Still not working? See Troubleshooting macOS/Linux below
Prerequisites: You need Node.js installed. Check with node --version. If not installed:
- macOS: Use Homebrew:
brew install nodeor download from https://nodejs.org/ - Linux: Use your package manager:
sudo apt install nodejs npm(Ubuntu/Debian) or check https://nodejs.org/
(Same as Method 1 above)
-
Run this command:
npm install -g @anthropic-ai/claude-code
-
Wait for installation (2-3 minutes, depending on internet speed)
You'll see output like:
added 15 packages in 45s -
If you get permission errors, try with sudo:
sudo npm install -g @anthropic-ai/claude-code
-
Verify installation:
claude --version
You should see the version number.
π Note: The npm method requires you to update Claude Code manually with npm update -g @anthropic-ai/claude-code.
Installation complete! Continue to Authentication Setup
Click to expand Authentication Setup
π Official Authentication Guide: https://docs.anthropic.com/en/docs/claude-code/authentication
This is the most important step. Without authentication, Claude Code cannot access Anthropic's AI services.
What is an API key?
Think of an API key like a digital password that lets Claude Code talk to Anthropic's servers. It's how Anthropic knows:
- Who you are
- Which account to bill
- How much you can use Claude Code
π Security Note: Your API key is sensitive information. Never share it publicly, commit it to Git, or post it online.
You don't need to manually copy an API keyβthe claude auth login command will handle this automatically via your browser!
How it works:
- You run
claude auth login - Your browser opens to Anthropic's website
- You log in to your Anthropic account
- Anthropic sends the API key directly to Claude Code securely
- Claude Code saves it for future use
-
Open your terminal (PowerShell on Windows, Terminal on Mac/Linux)
-
Type this command and press Enter:
claude auth login
-
You'll see a message like:
Opening browser for authentication... Waiting for authentication to complete... -
Your default web browser should open automatically to https://console.anthropic.com/login
![Browser opens for authentication]
β οΈ If the browser doesn't open automatically:- Copy the URL shown in the terminal
- Manually open your browser
- Paste the URL and press Enter
-
On the Anthropic website, log in using:
- Your email and password, OR
- Google account, OR
- GitHub account
![Anthropic login page]
-
If you don't have an account, click "Sign Up" and create one:
- Enter your email
- Verify your email (check inbox)
- Complete account setup
-
After logging in, you'll see a page asking:
"Claude Code wants to access your account" This will allow Claude Code to: - Make API requests on your behalf - Access your usage and billing information [Cancel] [Authorize] -
Click "Authorize"
![Authorization confirmation page]
-
You'll see a success message:
β Authentication successful! You can close this browser window. -
Switch back to your terminalβyou should see:
β Authentication successful! API key stored securely.
π― Quick Check: If you see "Authentication successful!" in your terminal, you're done!
Test that authentication worked:
claude "Hello! Can you help me with coding?"Expected output:
Claude Code is ready! Hello! I'd be happy to help you with coding. What would you
like to work on? I can assist with writing new code, debugging existing code,
explaining concepts, and much more.
β Success! If Claude responds, authentication is complete!
β If you see "authentication failed" or "invalid API key", see Troubleshooting Authentication below.
For your information, Claude Code stores your API key securely:
Windows:
%USERPROFILE%\.claude\credentials
macOS/Linux:
~/.claude/credentials
π Security: These files are readable only by your user account. Never share these files or their contents.
Click to expand Editor Integration Setup
π Official Editor Integration Guide: https://docs.anthropic.com/en/docs/claude-code/editor-integration
Ctrl+G is Claude Code's killer feature. When you press it during a Claude Code session:
- Your configured text editor opens
- You can write a long, detailed prompt
- When you save and close the editor, the prompt is sent to Claude
Why this matters:
- Write complex, multi-paragraph prompts comfortably
- Use your familiar editor with syntax highlighting
- Edit and refine prompts before sending
- Much better than typing long prompts in the terminal
Pick your favorite editor and set the EDITOR environment variable:
For VS Code (most popular):
[Environment]::SetEnvironmentVariable("EDITOR", "code --wait", "User")For Notepad (simplest):
[Environment]::SetEnvironmentVariable("EDITOR", "notepad", "User")For Sublime Text:
[Environment]::SetEnvironmentVariable("EDITOR", "subl --wait", "User")For Vim:
[Environment]::SetEnvironmentVariable("EDITOR", "vim", "User")π Note: The --wait flag tells VS Code/Sublime to wait until you close the file before returning control to Claude Code. This is critical!
-
Close PowerShell completely
-
Open a NEW PowerShell window
-
Run:
echo $env:EDITOR -
You should see:
code --wait(or whatever editor you chose)
-
Start a Claude Code session:
claude
-
Press Ctrl+G
-
Your editor should open with an empty file
-
Type a test prompt:
Hello Claude! This is a test of the Ctrl+G feature. Please respond if you receive this message. -
Save the file and close the editor
-
Claude should respond to your prompt!
β Success! If your editor opened and Claude responded, Ctrl+G works!
Pick your favorite editor and add it to your shell configuration:
For zsh (default on modern macOS):
VS Code:
echo 'export EDITOR="code --wait"' >> ~/.zshrc
source ~/.zshrcVim:
echo 'export EDITOR="vim"' >> ~/.zshrc
source ~/.zshrcnano:
echo 'export EDITOR="nano"' >> ~/.zshrc
source ~/.zshrcSublime Text:
echo 'export EDITOR="subl --wait"' >> ~/.zshrc
source ~/.zshrcFor bash (older systems):
Replace ~/.zshrc with ~/.bash_profile in the commands above.
π Note: The --wait flag tells VS Code/Sublime to wait until you close the file. This is critical!
echo $EDITORYou should see:
code --wait
(or whatever editor you chose)
-
Start a Claude Code session:
claude
-
Press Ctrl+G (or Cmd+G on macOS)
-
Your editor should open with an empty file
-
Type a test prompt:
Hello Claude! This is a test of the Ctrl+G feature. Please respond if you receive this message. -
Save the file and close the editor
-
Claude should respond to your prompt!
β Success! If your editor opened and Claude responded, Ctrl+G works!
Claude Code's Ctrl+G works with any editor that can:
- Be launched from the command line
- Wait for the file to be closed (with
--waitflag)
Popular choices:
- VS Code:
EDITOR="code --wait" - Sublime Text:
EDITOR="subl --wait" - Vim:
EDITOR="vim" - Emacs:
EDITOR="emacs" - nano:
EDITOR="nano" - Notepad (Windows):
EDITOR="notepad"
Click to expand Claude Code Features
π Official Features Documentation: https://docs.anthropic.com/en/docs/claude-code/features
Now that Claude Code is installed, let's understand what makes it powerful:
What it does:
- Claude Code automatically reads files in your current directory
- It understands your project structure
- It can suggest changes across multiple files
Example:
cd /path/to/your/project
claude "analyze the architecture of this codebase"Claude will read your files and provide insights about:
- Code structure
- Dependencies
- Patterns and best practices
- Potential improvements
What it does:
- Claude can modify multiple files in a single response
- Changes are shown as diffs before applying
- You can review and accept/reject changes
Example:
claude "refactor the authentication logic to use JWT tokens across all files"Claude will:
- Identify all files that need changes
- Show you diffs for each file
- Wait for your approval
- Apply changes when you confirm
What it does:
- Have ongoing conversations with Claude
- Ask follow-up questions
- Iterate on solutions
Example session:
$ claude
Claude Code> help me optimize this SQL query
[Claude provides optimization suggestions]
Claude Code> how would that perform with 1 million rows?
[Claude explains performance implications]
Claude Code> show me the updated query
[Claude provides optimized version]
What it does:
- Opens your text editor for complex prompts
- Better than typing in terminal
- Use your familiar editor features
When to use it:
- Writing detailed requirements
- Providing multiple code examples
- Creating complex refactoring instructions
Example: Press Ctrl+G and write:
I need help refactoring our user authentication system. Here's the current approach:
[paste current code]
Requirements:
1. Use JWT tokens instead of sessions
2. Add refresh token support
3. Implement role-based access control
4. Maintain backward compatibility
5. Add comprehensive tests
Please analyze the current code and suggest a migration plan.
What it does:
- Before changing files, Claude shows you exactly what will change
- You can review line-by-line diffs
- Accept or reject changes
Example output:
File: src/auth.js
- const session = require('express-session')
+ const jwt = require('jsonwebtoken')
File: src/routes/login.js
- req.session.userId = user.id
+ const token = jwt.sign({ userId: user.id }, SECRET)
+ res.cookie('token', token, { httpOnly: true })You'll be prompted: Apply these changes? (yes/no)
Built-in commands:
/help- Show available commands/clear- Clear the screen/exitor Ctrl+D - Exit Claude Code session/undo- Undo last file changes/diff- Show pending diffs again
What it does:
- Claude automatically includes relevant files in context
- Focuses on files most relevant to your request
- Manages token limits efficiently
Example: If you ask about "authentication", Claude will prioritize:
- Files with "auth" in the name
- Recently modified files
- Files in common authentication directories
Click to expand Your First Session Guide
Let's walk through a complete Claude Code session step-by-step!
# Navigate to your project directory
cd /path/to/your/project
# Or create a test project
mkdir claude-test
cd claude-testclaudeYou'll see:
Claude Code v1.2.3
Ready to assist with your coding! Type /help for commands or start asking questions.
Claude Code>
Ask for help understanding code:
Claude Code> what files are in this project?
Create a new file:
Claude Code> create a simple Express.js server with a /health endpoint
Get explanations:
Claude Code> explain how JWT authentication works
Press Ctrl+G (or Cmd+G on Mac) and write:
I'm building a REST API for a todo application. Please create:
1. A basic Express.js server setup
2. Todo model with:
- id, title, description, completed, createdAt
3. CRUD endpoints:
- GET /todos (list all)
- GET /todos/:id (get one)
- POST /todos (create)
- PUT /todos/:id (update)
- DELETE /todos/:id (delete)
4. Basic error handling
5. Input validation
Structure the code with proper separation of concerns.
Save and close your editor. Claude will process your request and generate the files!
Claude will show you:
I'll create the following files:
File: server.js
[shows content]
File: models/todo.js
[shows content]
File: routes/todos.js
[shows content]
Apply these changes? (yes/no/edit)
Type yes and press Enter to apply changes.
Claude Code> add input validation for the POST endpoint
Claude will show a diff and you can review before applying.
When done:
Claude Code> /exit
Or press Ctrl+D.
π Congratulations! You've completed your first Claude Code session!
Click to expand Verification Checklist
Let's make sure everything is working:
-
claude --versionshows version number- Open terminal and run
claude --version - Should show:
claude-code version X.X.X
- Open terminal and run
-
claude auth statusshows authenticated- Run
claude auth status - Should show:
β Authenticated as [your-email]
- Run
-
Basic prompt works
- Run
claude "hello" - Should get a friendly response from Claude
- Run
-
Ctrl+G opens your editor
- Run
claudeto start a session - Press Ctrl+G (or Cmd+G on Mac)
- Your configured editor should open
- Run
-
Claude Code can read project files
- Navigate to a project directory
- Run
claude "what files are in this project?" - Claude should list your files
-
Diff preview works
- Ask Claude to modify a file
- Should see diff preview before applying
-
Help command works
- In a Claude Code session, type
/help - Should see list of available commands
- In a Claude Code session, type
β All checked? Great job! You're ready to use Claude Code!
β Something not working? Check the troubleshooting section below.
Click to expand Troubleshooting Guide (All Platforms)
Problem: Windows can't find the claude command.
Solutions:
-
Restart PowerShell completely
- Close ALL PowerShell windows
- Open a NEW PowerShell window
- Try
claude --versionagain
-
Check if PATH was updated
- Run:
$env:PATH -split ';' | Select-String 'claude' - Should see a path containing "claude"
- If not found, reinstall Claude Code
- Run:
-
Try full path
- Run:
Get-Command claude - Note the full path shown
- Try running:
C:\Users\YourName\AppData\Local\Programs\claude\claude.exe --version - If this works, PATH wasn't updated correctly
- Run:
-
Reinstall using npm method
- Uninstall:
npm uninstall -g @anthropic-ai/claude-code - Reinstall:
npm install -g @anthropic-ai/claude-code
- Uninstall:
Problem: The shell can't find the claude command.
Solutions:
-
Check installation location
which claude
If nothing appears, Claude Code isn't in PATH.
-
Verify installation
ls -la ~/.local/bin/claude # or ls -la /usr/local/bin/claude
-
Add to PATH manually
For zsh:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc source ~/.zshrc
For bash:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bash_profile source ~/.bash_profile
-
Reinstall
curl -fsSL https://claude.ai/install.sh | sh
Problem: Claude Code can't authenticate with Anthropic's servers.
Solutions:
-
Try authentication again
claude auth logout claude auth login -
Check Anthropic account status
- Visit https://console.anthropic.com/
- Make sure you're logged in
- Check if your account is active
- Verify billing settings (if required)
-
Clear credentials and re-authenticate
Windows:
Remove-Item -Force "$env:USERPROFILE\.claude\credentials" claude auth login
macOS/Linux:
rm -f ~/.claude/credentials claude auth login -
Check network/firewall
- Ensure you can access https://api.anthropic.com
- Check if corporate firewall blocks API access
- Try from different network
-
Verify account limits
- Visit https://console.anthropic.com/settings/limits
- Check if you've hit API rate limits
- Verify billing is set up correctly
Problem: Pressing Ctrl+G does nothing or shows an error.
Solutions:
-
Check EDITOR variable is set
Windows:
echo $env:EDITORmacOS/Linux:
echo $EDITOR
Should show something like
code --wait -
Verify editor is in PATH
Test if editor command works:
code --version # for VS Code vim --version # for Vim
-
Reset EDITOR variable
Windows:
[Environment]::SetEnvironmentVariable("EDITOR", "notepad", "User")
macOS/Linux:
export EDITOR="nano" echo 'export EDITOR="nano"' >> ~/.zshrc source ~/.zshrc
Try with a simple editor first (Notepad/nano) to verify Ctrl+G works.
-
Restart Claude Code session
- Exit Claude Code completely (Ctrl+D or
/exit) - Start a new session:
claude - Try Ctrl+G again
- Exit Claude Code completely (Ctrl+D or
Problem: npm can't install Claude Code globally due to permissions.
Solutions:
-
Use npm with sudo (Linux/macOS only)
sudo npm install -g @anthropic-ai/claude-code
-
Configure npm to use a different directory (recommended)
Create a directory for global packages:
mkdir ~/.npm-global npm config set prefix '~/.npm-global'
Add to PATH:
zsh:
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.zshrc source ~/.zshrc
bash:
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bash_profile source ~/.bash_profile
Now install without sudo:
npm install -g @anthropic-ai/claude-code
-
Use the curl/PowerShell installation method instead
- This avoids npm entirely
- See installation sections above
Click to expand Common Pitfalls Quick Reference
Quick reference for the most common issues:
| Problem | Quick Fix |
|---|---|
| "Command not found" | 1. Close terminal completely 2. Open NEW terminal 3. Try again |
| "Authentication failed" | 1. Run claude auth logout2. Run claude auth login3. Follow browser flow |
| "Ctrl+G doesn't work" | 1. Verify: echo $EDITOR shows editor2. Set: export EDITOR="nano"3. Restart Claude session |
| "Can't read project files" | Make sure you're IN the project directory: cd /path/to/project |
| "npm permission errors" | Use curl/PowerShell install method instead, or configure npm directory |
| "Which install method?" | PowerShell/curl (recommended) unless you specifically need npm |
Click to expand AI Prompting Tips
If you've tried everything in the troubleshooting guide and you're still stuck, here's how to get help from AI assistants:
1. Describe Your Exact Situation
Instead of: "Claude Code doesn't work"
Try: "I'm on Windows 11. I installed Claude Code via PowerShell script successfully, but when I type 'claude --version' in PowerShell, I get 'command not found' error. I've restarted PowerShell three times and tried opening a new admin PowerShell window."
2. Include What You've Already Tried
"I've already tried:
- Reinstalling Claude Code with the PowerShell script
- Restarting PowerShell completely
- Running
$env:PATH -split ';'to check PATH - The PATH doesn't show any claude directory"
3. Share Error Messages Word-for-Word
Copy and paste the exact error:
PS C:\Users\YourName> claude --version
claude : The term 'claude' is not recognized as the name of a cmdlet, function,
script file, or operable program.
4. Mention Your Setup Details
- Operating System and version (Windows 11, macOS Sonoma 14.2, Ubuntu 22.04)
- Installation method used (PowerShell script, curl script, npm)
- Node.js version if using npm (
node --version) - Shell type (PowerShell, zsh, bash)
For Installation Issues:
"I'm installing Claude Code on macOS Ventura using the curl script method.
I ran 'curl -fsSL https://claude.ai/install.sh | sh' and it completed with
'installed successfully' message. However, when I run 'claude --version' I get
'command not found'. I've closed and reopened Terminal twice.
Output of 'which claude': (empty, nothing)
Output of 'echo $PATH': /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
What should I check next?"
For Authentication Problems:
"I'm trying to authenticate Claude Code on Windows 11. When I run 'claude auth login',
my browser opens to Anthropic's website, I successfully log in and click 'Authorize',
the browser shows 'Authentication successful', but when I switch back to PowerShell,
it shows 'Error: authentication failed - invalid response'.
I've tried:
- Logging out and back in on Anthropic's website
- Running 'claude auth logout' then 'claude auth login' again
- Using a different browser (Chrome instead of Edge)
How can I fix this authentication issue?"
For Editor Integration Issues:
"I'm on macOS with zsh shell and VS Code installed. I ran:
echo 'export EDITOR=\"code --wait\"' >> ~/.zshrc
source ~/.zshrc
When I check: echo $EDITOR shows 'code --wait' correctly.
When I check: code --version shows VS Code is installed and in PATH.
However, when I start a Claude Code session with 'claude' and press Ctrl+G
(actually Cmd+G on Mac), nothing happens. No editor opens, no error message.
What else should I verify for the Ctrl+G feature?"
Run these commands and include the output in your question:
Windows PowerShell:
# System information
$PSVersionTable.PSVersion
node --version # if using npm
npm --version # if using npm
# Claude Code information
claude --version
where.exe claude
# Environment variables
echo $env:EDITOR
echo $env:PATH | Select-String "claude"macOS/Linux Terminal:
# System information
uname -a
node --version # if using npm
npm --version # if using npm
echo $SHELL
# Claude Code information
claude --version
which claude
ls -la ~/.local/bin/claude # or /usr/local/bin/claude
# Environment variables
echo $EDITOR
echo $PATH | grep -i claude
# Authentication status
claude auth statusCopy this template and fill in your details:
**Operating System:** [Windows 11 / macOS Sonoma 14.2 / Ubuntu 22.04]
**Installation Method:** [PowerShell script / curl script / npm]
**Node.js Version:** [if using npm: node --version output]
**Claude Code Version:** [claude --version output, or "not working"]
**Shell/Terminal:** [PowerShell / zsh / bash]
**Problem Description:**
[Describe exactly what's not working]
**What I've Tried:**
1. [First thing you tried]
2. [Second thing you tried]
3. [Third thing you tried]
**Error Messages:**
[Paste exact error messages here]
**Command Outputs:**
[Paste diagnostic command outputs here]
**Expected Behavior:**
[What should happen]
**Actual Behavior:**
[What actually happens]
- Claude Code itself: Start a session and ask!
claude "help me troubleshoot installation" - ChatGPT: https://chat.openai.com - paste the template above
- Google Gemini: https://gemini.google.com - paste your detailed question
- Anthropic Discord: Official Anthropic community (check docs for invite link)
- Stack Overflow: Search first, then ask with [claude-code] tag
- GitHub Discussions: https://github.com/anthropics/claude-code/discussions
β "It doesn't work" - Too vague β "When I press Ctrl+G in Claude Code on Windows 11, VS Code doesn't open, but 'code --version' works fine in PowerShell"
β "I get an error" - Need details β "I get 'authentication failed - invalid API key' when running 'claude auth status' after successfully completing browser authentication flow on macOS"
β "Help please!" - No context β "I followed Step 3 of the Windows installation guide (PowerShell script method). The install completed successfully, but 'claude --version' returns 'command not found'. Output of 'where.exe claude': (nothing). Do I need to manually add to PATH?"
Remember:
- AI assistants (including Claude Code itself!) can help with installation issues
- The more specific your question, the better the answer
- Include what you've already tried - it saves time
- Error messages are valuable - always include them
- It's okay to ask follow-up questions if the first answer doesn't solve it
Click to expand Success Guide & Next Steps
π Congratulations! You've successfully installed Claude Code and set up AI-assisted development!
-
Use Claude Code for AI-assisted coding
- Navigate to any project:
cd /path/to/project - Start a session:
claude - Ask for help:
claude "explain this codebase"
- Navigate to any project:
-
Use Ctrl+G for complex prompts
- Press Ctrl+G (or Cmd+G) in any Claude session
- Write detailed prompts in your editor
- Save and close to send
-
Let Claude modify multiple files
- Ask for refactoring across your codebase
- Review diffs before applying
- Iterate on changes interactively
-
Explore Claude Code commands
- Type
/helpin a session to see all commands - Use
/clearto clear the screen - Use
/undoto revert changes
- Type
Test these three things to confirm everything works:
# 1. Check Claude Code is installed
claude --version
# 2. Test authentication
claude auth status
# 3. Start an interactive session
claude "hello, let's code together!"All three working? Perfect!
Now that Claude Code is installed, here are great resources to learn more:
π Official Claude Code Resources:
- Documentation Home: https://docs.anthropic.com/en/docs/claude-code
- Getting Started Guide: https://docs.anthropic.com/en/docs/claude-code/getting-started
- Video Tutorials: https://docs.anthropic.com/en/docs/claude-code/tutorials
- Best Practices: https://docs.anthropic.com/en/docs/claude-code/best-practices
- Command Reference: https://docs.anthropic.com/en/docs/claude-code/commands
- Tips and Tricks: https://docs.anthropic.com/en/docs/claude-code/tips
- FAQ: https://docs.anthropic.com/en/docs/claude-code/faq
Essential First Steps:
- Read the Getting Started guide (link above)
- Try the interactive tutorial (run
claude tutorial) - Practice with Ctrl+G on small projects first
- Learn the built-in commands (
/helpcommand) - Understand the diff workflow (review before applying)
Try Claude Code on these beginner-friendly projects:
-
Analyze an existing project
cd /path/to/your/project claude "analyze this codebase and suggest improvements"
-
Create a simple API
mkdir todo-api && cd todo-api claude "create a REST API for a todo app with Express"
-
Refactor legacy code
cd /path/to/legacy-project claude "help me refactor this to use modern JavaScript"
-
Debug an issue
claude "I'm getting this error: [paste error]. Help me debug it" -
Write tests
claude "write unit tests for the authentication module"
Customize Claude Code:
Set default model (if you have access to multiple):
claude config set model claude-3-opus-20240229Set context window preferences:
claude config set max-tokens 100000Configure diff display:
claude config set diff-style unifiedView all settings:
claude config listClick to expand Additional Resources
All official Anthropic Claude Code documentation:
- Main Documentation: https://docs.anthropic.com/en/docs/claude-code
- Setup Overview: https://docs.anthropic.com/en/docs/claude-code/setup
- Getting Started: https://docs.anthropic.com/en/docs/claude-code/getting-started
- Windows Setup: https://docs.anthropic.com/en/docs/claude-code/setup/windows
- macOS Setup: https://docs.anthropic.com/en/docs/claude-code/setup/macos
- Linux Setup: https://docs.anthropic.com/en/docs/claude-code/setup/linux
- Authentication: https://docs.anthropic.com/en/docs/claude-code/authentication
- Editor Integration: https://docs.anthropic.com/en/docs/claude-code/editor-integration
- Command Reference: https://docs.anthropic.com/en/docs/claude-code/commands
- Best Practices: https://docs.anthropic.com/en/docs/claude-code/best-practices
- API Documentation: https://docs.anthropic.com/en/api
- FAQ: https://docs.anthropic.com/en/docs/claude-code/faq
- Troubleshooting: https://docs.anthropic.com/en/docs/claude-code/troubleshooting
- Anthropic Discord: Official community server (check docs for invite)
- GitHub Discussions: https://github.com/anthropics/claude-code/discussions
- Stack Overflow: Questions tagged [claude-code]
- Reddit: r/ClaudeAI community
Claude Code works great with these tools:
- VS Code: Your editor for Ctrl+G - https://code.visualstudio.com/
- Git: Version control for your AI-assisted changes - https://git-scm.com/
- Docker: For containerized development - https://www.docker.com/
- GitHub Copilot: Complementary AI coding tool - https://github.com/features/copilot
If you want to explore other AI coding assistants:
- GitHub Copilot: AI pair programmer in your IDE
- Cursor: AI-powered code editor
- Tabnine: AI code completion
- Amazon CodeWhisperer: AWS's AI coding companion
- Codeium: Free AI code completion
| Version | Date | Changes |
|---|---|---|
| 1.0 | 2025-01-14 | Initial comprehensive guide created with collapsible sections and AI help |
Questions or Issues?
If you encounter problems not covered in this guide:
- Check the official troubleshooting docs
- Search GitHub Discussions
- Ask in the Anthropic Discord community
- Use the "Still Stuck? How to Get AI Help" section above
Built for MACA Course students by Claude Agent
This guide was created to help beginners get started with Claude Code and AI-assisted development. Welcome to the future of coding!