Prerequisites

Before diving into Claude Code, ensure you have the following:

  • Operating System: macOS, Linux, or Windows 10+ with PowerShell
  • Claude Account: Free or Pro/Max account with API access enabled
  • Terminal Knowledge: Basic comfort with command-line interfaces
  • Internet Connection: Required for authentication and API calls

What is Claude Code?

Claude Code is Anthropic's command-line interface (CLI) for Claude, enabling developers to write, refactor, and debug code entirely through natural language. Unlike traditional IDEs, Claude Code runs in your terminal and executes your instructions autonomously, planning multi-step tasks and iterating until completion.

Key Differences from Competitors

Claude Code vs Cursor vs Copilot: Cursor is an IDE wrapper adding AI features to VS Code. GitHub Copilot is a code autocomplete tool within your editor. Claude Code is a standalone CLI agent that autonomously manages your entire project, making architectural decisions and handling complex refactoring tasks that would take hours manually.

Step 1: Install Claude Code on Your System

Installation is straightforward and takes 2-3 minutes across all platforms.

macOS and Linux Installation

Open your terminal and run:

curl -fsSL https://claude.ai/install.sh | bash

After installation, close and reopen your terminal, or run:

source ~/.bashrc

Verify installation:

claude --version

Expected output: Claude CLI version 1.2.0 (or higher)

Windows PowerShell Installation

Open PowerShell as Administrator and run:

irm https://claude.ai/install.ps1 | iex

If you see an execution policy error:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

Then run the installation command again.

Alternative for Windows: Use WinGet for automatic permission handling:

winget install Anthropic.ClaudeCLI

Step 2: Authenticate Your Claude Account

Claude Code uses browser-based authentication for security. No API keys are stored locally.

First-Time Setup

  1. Open your terminal and run: claude
  2. Your default browser will open an authentication page
  3. Log in with your Claude account (same email you use on Claude.ai)
  4. Grant permissions when prompted
  5. Return to your terminal—you'll see a confirmation message

Pro Tip: Authentication persists across sessions. You only need to authenticate once unless you sign out explicitly.

Step 3: Create Your CLAUDE.md Configuration File

CLAUDE.md is your project's instruction manual for Claude Code. It defines your project structure, build process, and coding standards.

Generate a Starter Configuration

Navigate to your project directory and run:

cd my-project
claude /init

This generates a CLAUDE.md file with sections for:

  • Project Overview: Brief description and purpose
  • Architecture: Folder structure and key dependencies
  • Build Commands: How to compile and run your project
  • Code Style: Naming conventions, formatting rules
  • Ignored Files: Patterns to exclude (.git, node_modules, etc.)

Customize Your CLAUDE.md

Example for a Python project:

# Project Overview
Flask REST API for task management

## Architecture
- app.py (main entry point)
- models/ (SQLAlchemy models)
- routes/ (API endpoints)
- tests/ (pytest unit tests)

## Build Commands
- pip install -r requirements.txt
- python app.py

## Code Style
- PEP 8 compliance
- Type hints required
- Docstrings for all functions

## Ignored Files
__pycache__/
venv/
*.pyc
.env

Step 4: Master Essential Commands and Keyboard Shortcuts

These commands control your Claude Code session:

Core Commands

  • /help – Display available commands
  • /clear – Clear conversation history
  • /cost – Show API usage and estimated costs
  • /status – View current project context
  • /exit – End the session safely

Keyboard Shortcuts

  • Tab – Autocomplete file names and commands
  • @filename – Reference specific files in your message
  • ! – Execute shell commands directly (e.g., !npm test)
  • Ctrl+C – Cancel current operation
  • ↑/↓ – Navigate command history

Step 5: Build Your First Project with Claude Code

Now let's create a practical project from scratch using natural language.

Create a Simple Project Directory

mkdir claude-weather-app
cd claude-weather-app
claude

Natural Language Project Brief

Describe your project in plain English:

Create a Python command-line weather app that:
1. Takes a city name as input
2. Fetches current weather data from a free API
3. Displays temperature, humidity, and conditions
4. Has error handling for invalid cities
5. Includes unit tests using pytest

What happens next:

  1. Claude analyzes your request and creates a project plan
  2. It generates necessary files (main app, requirements.txt, tests)
  3. Shows you diffs of proposed changes
  4. Waits for your approval: type yes to accept or no to revise
  5. Iterates until your project is complete and functional

Reviewing Diffs and Making Changes

Always review what Claude proposes before approving:

--- app.py (new file)
+++ app.py
@@ -1,0 +1,25 @@
+import requests
+from typing import Dict
+
+def get_weather(city: str) -> Dict[str, str]:
+    """Fetch weather data for a given city."""
+    ...

[Diff continues]

Accept these changes? (yes/no)

If you disagree with a change, respond with a natural language correction:

no, use the weather.gov API instead and include wind speed

Best Practices for Claude Code

1. Be Specific in Your Requests

❌ Vague: "Build a web app"

✅ Specific: "Create a FastAPI REST API with PostgreSQL for a blog. Include user authentication with JWT, post CRUD operations, and error handling."

2. Leverage the @file Syntax

When working with existing code, reference files directly:

@models.py add pagination to the User query

3. Use /cost to Monitor Usage

Claude Code counts towards your API usage:

/cost
Current session: $2.34
Today: $12.50
Monthly limit: $100

4. Commit Your Changes Regularly

Use git to track Claude's modifications:

git add .
git commit -m "Claude Code: Add authentication system"

Common Mistakes to Avoid

Mistake 1: Incomplete Project Context

Problem: Not setting up CLAUDE.md leads to Claude making incorrect architectural choices.

Solution: Always run claude /init and customize your configuration before complex tasks.

Mistake 2: Approving Unsafe Changes Without Review

Problem: Blindly accepting every diff can introduce security vulnerabilities or break your app.

Solution: Always read diffs carefully, especially in security-sensitive areas like authentication.

Mistake 3: Overwhelming Claude with Vague Requests

Problem: Asking Claude to "fix the entire app" without specifics wastes API credits and produces mediocre results.

Solution: Break large tasks into smaller, well-defined requests with clear success criteria.

Mistake 4: Ignoring Error Messages

Problem: Claude shows helpful error messages, but users dismiss them and re-run the same command.

Solution: Read errors carefully and adjust your request accordingly.

Troubleshooting Guide

Issue: "Authentication Failed" Error

Solution:

claude /logout
claude /login
# Complete browser authentication again

Issue: Claude Makes Wrong Architectural Decisions

Solution: Update your CLAUDE.md with explicit architecture guidelines and re-run the command with the updated config.

Issue: High API Costs on Simple Tasks

Solution: Use /clear between unrelated tasks to reduce context size. Use /cost to monitor usage in real-time.

Claude Pro vs Claude Max for Coding

Claude Pro ($20/month): Suitable for light coding tasks (1-2 projects weekly). Rate limit: 40 API calls/minute.

Claude Max 5x ($100/month): Full-time developers. 5x the usage of Claude Pro, optimized for large codebases.

Claude Max 20x ($200/month): Heavy power users, commercial coding teams. 20x usage capacity.

Advanced Features

Using Shell Commands in Claude Code

Run system commands directly:

!npm test
!python -m pytest
!docker build .

Machine Learning Project Support

Claude Code handles ML projects well:

  • Generates data preprocessing scripts
  • Writes model training code
  • Implements evaluation metrics
  • Limitation: Cannot visualize plots directly. Run Jupyter separately for visualization.

Multi-File Projects

Claude Code excels at managing large projects with multiple dependencies. Simply point it to your main file or directory:

claude
I need to refactor the entire authentication system in this codebase.
@auth/ @models/ @utils/ - review these and suggest improvements.

FAQ Section

How to install Claude Code on Windows?

For Windows, open PowerShell and run: irm https://claude.ai/install.ps1 | iex. If you encounter execution policy errors, run Set-ExecutionPolicy RemoteSigned -Scope CurrentUser first. Alternatively, use WinGet: winget install Anthropic.ClaudeCLI which handles permissions automatically.

Can I use Claude Code for machine learning tutorial projects?

Yes, Claude Code handles machine learning projects well for data preprocessing, model training scripts, and experiment tracking. However, it runs in your terminal and cannot visualize plots like Jupyter notebooks. Best practice: use Claude Code to generate and refactor ML code, then run notebooks separately for visualization and experimentation.

What is the difference between Claude Pro and Claude Max for coding?

Claude Pro ($20/month) provides enough usage for light daily coding sessions. Claude Max 5x ($100/month) offers 5 times the usage for full-time developers. Claude Max 20x ($200/month) is for heavy power users. Start with Pro and upgrade if you consistently hit rate limits.

How do I use Claude Code for coding tasks?

Start Claude in your project directory with the claude command. Describe your task in natural language and Claude will autonomously plan, execute, and iterate until completing your request. Use slash commands like /help, /clear, and /cost to manage your session.

References