Complete Claude Code Guide: From Installation to Advanced Usage

Complete Claude Code Guide: From Installation to Advanced Usage

A comprehensive tutorial covering everything you need to know about Claude Code - from basic installation and setup to advanced features like MCP integration, automation, and security best practices.

Lesson 1 2025-07-03 07:59

Claude Code Installation & Setup Guide

Claude Code Installation & Setup Guide

Welcome to the comprehensive installation and setup guide for Claude Code! This guide will walk you through everything you need to get Claude Code up and running on your system.

What is Claude Code?

Claude Code is Anthropic's official CLI tool that brings the power of Claude AI directly to your terminal. It's designed for developers who want to integrate AI assistance into their coding workflow, offering features like:

  • Interactive conversation mode
  • File editing and code analysis
  • Integration with external tools through MCP (Model Context Protocol)
  • Automation capabilities
  • Security-focused permissions system

System Requirements

Before installing Claude Code, ensure your system meets these requirements:

  • Node.js: Version 16 or higher (18+ recommended)
  • RAM: 4GB minimum (8GB+ recommended for large projects)
  • Internet connection: Required for API calls
  • API key: From Anthropic Console

Supported Platforms

Claude Code works on: - macOS: Intel and Apple Silicon - Linux: Ubuntu 18+, Debian 10+, CentOS 7+ - Windows: Windows 10/11 (WSL recommended)

Installation Methods

The most straightforward way to install Claude Code is through npm:

# Install globally
npm install -g @anthropic-ai/claude-code

# Verify installation
claude --version

Method 2: macOS with Homebrew

For macOS users, you can use Homebrew:

# Install Node.js if not already installed
brew install node

# Install Claude Code
npm install -g @anthropic-ai/claude-code

# If you encounter path issues, run:
export PATH="$PATH:$(npm bin -g)"

Method 3: Arch Linux AUR

For Arch Linux users:

# Using yay
yay -S claude-code

# Or using paru
paru -S claude-code

Method 4: Docker (Containerized)

For containerized environments:

# Pull the Docker image
docker pull ghcr.io/rchgrav/claudebox:latest

# Run Claude Code in a container
docker run -it -v "$PWD":"$PWD" -w "$PWD" \
  ghcr.io/rchgrav/claudebox:latest

Method 5: Windows with WSL

For Windows users (recommended approach):

  1. Enable WSL 2 and install Ubuntu
  2. Inside Ubuntu, run:
sudo apt update && sudo apt install -y nodejs npm
npm install -g @anthropic-ai/claude-code

Initial Setup

Step 1: Get Your API Key

  1. Visit Anthropic Console
  2. Create an account or sign in
  3. Navigate to API Keys section
  4. Generate a new API key

Step 2: Configure API Key

Set your API key as an environment variable:

# Set temporarily
export ANTHROPIC_API_KEY="sk-your-key-here"

# Make permanent - choose your shell:

# For Bash
echo 'export ANTHROPIC_API_KEY="sk-your-key-here"' >> ~/.bashrc
source ~/.bashrc

# For Zsh
echo 'export ANTHROPIC_API_KEY="sk-your-key-here"' >> ~/.zshrc
source ~/.zshrc

# For Fish
echo 'set -gx ANTHROPIC_API_KEY "sk-your-key-here"' >> ~/.config/fish/config.fish

Step 3: Basic Configuration

Configure Claude Code with your preferences:

# Interactive setup
claude config

# Set basic defaults
claude config set -g model claude-sonnet-4
claude config set -g verbose true
claude config set -g outputFormat text

Step 4: Test Installation

Verify everything is working:

# Basic functionality test
claude "Hello, Claude!"

# Print mode test
claude -p "What is 2+2?"

# Health check
claude /doctor

Configuration Options

Environment Variables

Here are some useful environment variables you can set:

# Disable telemetry
export DISABLE_TELEMETRY=1

# Disable error reporting
export DISABLE_ERROR_REPORTING=1

# Disable non-essential model calls
export DISABLE_NON_ESSENTIAL_MODEL_CALLS=1

# Set maximum thinking tokens
export MAX_THINKING_TOKENS=50000

Security Settings

For security-conscious users:

# Set allowed tools
claude config set allowedTools "Edit,View"

# Trust dialog settings
claude config set hasTrustDialogAccepted
claude config set hasCompletedProjectOnboarding

First Steps

Interactive Mode

Start Claude Code in interactive mode:

claude

This opens a REPL where you can have conversations with Claude.

One-Shot Mode

For quick queries:

claude -p "Explain this error message"

With Initial Prompt

Start with a specific question:

claude "Help me debug this Python script"

Troubleshooting Installation

Common Issues

  1. Command not found: Ensure npm global bin is in your PATH
  2. Permission errors: Try using sudo with npm install (not recommended) or fix npm permissions
  3. API key issues: Verify your API key is set correctly
  4. Network issues: Check your internet connection and proxy settings

Health Check

Run the health check command to diagnose issues:

claude /doctor

Expected output should include: - βœ… API Key: Valid - βœ… Network: Connected - βœ… Model Access: Available

Getting Help

If you encounter issues:

  1. Check the official documentation
  2. Use the /bug command within Claude Code
  3. Verify your Node.js version is 16+
  4. Try reinstalling Claude Code

What's Next?

Now that you have Claude Code installed and configured, you can:

  1. Learn basic commands - Explore the commands reference
  2. Set up MCP integration - Connect external tools and services
  3. Configure security settings - Set up permissions and safety measures
  4. Explore advanced features - Automation, scripting, and workflows

Quick Reference

Essential Commands

claude                          # Start interactive mode
claude "your question"          # Start with initial prompt
claude -p "query"              # One-shot query
claude -c                      # Continue last session
claude config                 # Configuration menu
claude --version               # Check version
claude --help                  # Show help

Configuration Files

  • Global config: ~/.claude.json
  • Project config: settings.json (varies by project)
  • Project memory: CLAUDE.md (in project root)

Congratulations! You now have Claude Code installed and ready to use. The next step is to explore the commands and features that make Claude Code such a powerful development tool.