LESSONS
Getting Started
Claude Code Installation & Setup
What is Claude Code?
Claude Code is an agentic coding tool from Anthropic that lives in your terminal. It understands your codebase, helps you edit files, and executes terminal commands—all within a chat-based interface.
- • Natural language coding - Describe what you want in plain English
- • Context-aware - Understands your entire project structure
- • File editing - Can read, create, and modify files
- • Terminal integration - Runs commands and shows results
Requirements
- • macOS or Linux (Windows via WSL2)
- • Node.js 18+ -
node --version - • npm (comes with Node.js)
- • Anthropic API Key or Anthropic Max Plan
Installation
Install Claude Code globally using npm:
# Install Claude Code globally npm install -g @anthropic-ai/claude-code # Verify installation claude --version # Start Claude Code claude
sudo npm install -g @anthropic-ai/claude-code or fix npm permissions.
API Key Setup
Claude Code needs your Anthropic API key. You can set it up in two ways:
Option 1: Interactive Login (Recommended)
Run claude and follow the prompts to log in with your Anthropic account.
# Start Claude Code and follow login prompts
claude
Option 2: Environment Variable
Set your API key as an environment variable in your shell profile:
# Add to ~/.zshrc or ~/.bashrc export ANTHROPIC_API_KEY="sk-ant-..." # Reload your shell source ~/.zshrc
Your First Run
Navigate to a project directory and start Claude Code:
# Navigate to your project cd /path/to/your/project # Start Claude Code claude # Try these commands: /init # Analyze project and create CLAUDE.md /help # Show all available commands /status # Show current context and settings
Adding Context
/init, CLAUDE.md, # memory, @ references
/init - Project Initialization
The /init command analyzes your project structure and generates a CLAUDE.md file containing project context.
# Run this at the start of any new project
/init
# Claude will analyze:
# - File structure
# - Dependencies (package.json, requirements.txt, etc.)
# - Existing documentation
# - Code patterns and conventions
Always run /init when starting work on a new codebase. It helps Claude understand the project context.
CLAUDE.md - Project Memory
The CLAUDE.md file stores project-specific context that persists across sessions. It has three levels:
./CLAUDE.md
Specific to current project
~/.claude/CLAUDE.md
Shared across local projects
Enterprise settings
Organization-wide context
# - Add to Memory
Use the # prefix to add information directly to CLAUDE.md. This is useful for recording learnings or project conventions.
# When you discover important patterns:
# Always use TypeScript strict mode in this project
# Record learned lessons:
# FileSystemContext requires FileSystemProvider wrapper
# Document conventions:
# API routes follow /api/v1/resource pattern
@ - File References
Use @ to reference specific files in your prompts. This adds the file content to context.
# Reference a specific file
@src/components/Button.tsx add a loading state
# Reference multiple files
@package.json @tsconfig.json explain the build setup
# Reference with context
Based on @types/user.ts create a user form component
Plan Mode
Think before you act with structured planning
What is Plan Mode?
Plan Mode lets Claude analyze and plan without executing code changes. It's essential for complex tasks where you want to understand the approach before implementation.
# Press Shift+Tab twice to toggle Plan Mode
Shift + Tab + Tab
# Or use the command
/plan
When to Use Plan Mode
- - Analyzing unfamiliar codebases
- - Planning complex refactors
- - Exploring multiple approaches
- - Understanding dependencies
- - Simple, one-line fixes
- - Familiar, routine tasks
- - Urgent bug fixes
- - Quick code generation
Plan Mode Workflow
# 1. Enter Plan Mode
[Plan Mode ON]
# 2. Ask Claude to analyze
Analyze how authentication works in this project
# 3. Claude explores without changing files
# - Reads relevant files
# - Identifies patterns
# - Creates a plan
# 4. Review the plan
# 5. Exit Plan Mode and execute
[Plan Mode OFF]
Implement the plan
Plan Mode only affects file modifications. Claude can still read files, search, and explore in Plan Mode.
Thinking Modes
"think more", "ultrathink" for deep analysis
Extended Thinking
Claude can use extended thinking for complex problems. Use keywords in your prompt to trigger deeper analysis.
Extended reasoning mode. Good for moderately complex problems.
think more about this architecture
Maximum reasoning capacity. Use for highly complex analysis.
ultrathink about this bug
When to Use Extended Thinking
# Debugging complex issues
ultrathink about why this race condition occurs
# Architecture decisions
think more about the trade-offs between these approaches
# Security analysis
ultrathink about potential vulnerabilities in this code
# Performance optimization
think more about how to optimize this database query
Extended thinking uses more tokens. Use it for genuinely complex problems, not simple tasks where quick answers suffice.
Context Management
/clear, /compact for efficient token usage
Why Context Management Matters
Claude has a context window limit. As you work, the conversation accumulates tokens. Managing context helps maintain performance and relevance.
/clear - Reset Conversation
Completely resets the conversation. Use when switching to a completely different task.
# Clear entire conversation
/clear
# When to use:
# - Switching to unrelated work
# - After completing a major task
# - When context becomes cluttered
/compact - Compress Context
Summarizes and compresses the conversation while retaining key information. Use to continue work with less token usage.
# Compress conversation
/compact
# When to use:
# - Long sessions approaching token limit
# - Before adding large file references
# - To maintain context across breaks
- - Complete reset
- - Loses all context
- - Fresh start
- - Preserves key info
- - Reduces token usage
- - Continues session
KNOWLEDGE CHECK
Ready for the Challenge?
Apply what you've learned by building features in a real project.