Claude Code Setup Guide
Get Claude Code installed and configured on your machine. A step-by-step guide to setting up Anthropic's official CLI for AI-assisted development.
Claude Code Setup Guide
Claude Code is Anthropic’s official CLI tool for AI-assisted software development. It runs in your terminal and gives you a powerful conversational interface for building, debugging, and exploring code.
This guide will get you up and running in minutes.
Prerequisites
Before you start, make sure you have:
- Node.js 18+ installed (download here)
- A terminal (Terminal.app on Mac, any terminal on Linux, or Windows Terminal)
- An Anthropic API key or Claude subscription
Installation
Open your terminal and run:
npm install -g @anthropic-ai/claude-code
This installs Claude Code globally, making the claude command available everywhere.
Verify the installation:
claude --version
You should see the version number printed.
Authentication
Claude Code needs to authenticate with Anthropic. Run:
claude login
This will open a browser window where you can sign in with your Anthropic account. Once authenticated, you’re ready to go.
Alternatively, if you have an API key, you can set it as an environment variable:
export ANTHROPIC_API_KEY=your-key-here
Add this to your shell profile (~/.zshrc or ~/.bashrc) to persist it.
Your First Session
Navigate to a project directory (or create a new one):
mkdir my-project && cd my-project
Start Claude Code:
claude
You’ll see a prompt where you can start chatting. Try something simple:
Create a Python script that prints "Hello, World!"
Claude Code will:
- Write the code
- Create the file
- Show you what it did
You can run the script directly:
python hello.py
Key Commands
While in a Claude Code session:
| Command | What it does |
|---|---|
| Type naturally | Chat with Claude about your code |
Ctrl+C | Cancel current operation |
Ctrl+D or exit | End the session |
/help | Show available commands |
/clear | Clear conversation history |
Working with Existing Code
Claude Code works best when it has context. Navigate to an existing project:
cd ~/your-project
claude
Then ask questions about the codebase:
- “What does this project do?”
- “Find where user authentication is handled”
- “Explain the main function in app.py”
Claude Code will read your files and give you informed answers.
Making Changes
Ask Claude Code to modify your code:
- “Add error handling to the login function”
- “Refactor this to use async/await”
- “Add tests for the User class”
It will show you the proposed changes and ask for confirmation before writing to files.
Tips for Effective Use
1. Be in the right directory
Claude Code uses your current directory as context. Make sure you’re in your project root.
2. Describe intent, not implementation
Say “I need to validate email addresses” instead of “Write a regex for emails.”
3. Iterate
If the first result isn’t quite right, explain what needs to change. Claude Code remembers the conversation.
4. Review changes
Always look at what Claude Code proposes before accepting. You’re still in charge.
5. Use it for exploration
Ask “How would I…” questions. Claude Code is great for learning new patterns.
Common Use Cases
Starting a new project
I want to create a REST API in Python using FastAPI.
Set up the basic project structure with a health check endpoint.
Debugging
This function is returning None when I expect a list.
Here's the error I'm seeing: [paste error]
Refactoring
This file is too long. Help me split it into smaller modules.
Documentation
Add docstrings to all the public functions in utils.py
Configuration
Claude Code can be configured with a .claude/settings.json file in your project or home directory:
{
"model": "claude-sonnet-4-20250514",
"autoConfirm": false
}
See the Claude Code documentation for all options.
Troubleshooting
”Command not found: claude”
Make sure npm’s global bin directory is in your PATH:
export PATH="$PATH:$(npm bin -g)"
Authentication issues
Try logging out and back in:
claude logout
claude login
Rate limits
If you hit rate limits, wait a moment and try again. Consider upgrading your plan for higher limits.
Next Steps
Now that you’re set up:
- Read Getting Started with Vibecoding to learn the workflow
- Join our Community to connect with other Claude Code users
- Check out Events for workshops and meetups
Happy building!