Lesson 3 of 3 · Claude Code Field Guide

Installation & First Run

interactive5 min

Story: From Zero to First Prompt

Kenzo had been reading about Claude Code for weeks. Blog posts, Twitter threads, YouTube demos -- he'd seen other developers do incredible things with it. But every time he sat down to install it, he'd get distracted or overthink it. "I'll set it up this weekend when I have time to really dig in," he kept telling himself.

Then one Tuesday afternoon, his tech lead dropped a Slack message: "We need to migrate our 47 API endpoints from Express to Fastify by Friday. Can you scope out the effort?"

Kenzo stared at the message. Forty-seven endpoints. Four days. Just scoping the migration would take a full day of reading through each handler, understanding the middleware chain, and documenting the changes needed.

Concept Card

He decided this was the moment. He opened a terminal and typed:

Bash
npm install -g @anthropic-ai/claude-code

Three minutes later, Claude Code was installed. He authenticated with his API key, navigated to the project directory, typed claude, and wrote his first prompt:

"Analyze all API endpoints in this Express app. List each one with its route, HTTP method, middleware chain, and any Fastify-incompatible patterns. Output as a markdown table."

Fourteen seconds later, Claude Code had read 23 files, analyzed every route handler, identified the middleware dependencies, found three patterns that would need manual attention during migration, and produced a comprehensive migration scope document.

14 sec

Full Codebase Analysis

Claude Code read 23 files and produced a complete migration scope -- a task that would have taken a full day manually

What would have taken Kenzo a full day took less than a minute. The installation itself? Under five minutes.

Concept Card

The lesson: don't overthink the setup. The installation is simple. The first prompt is the hard part -- and even that is just a sentence.


Concept: Installing and Configuring Claude Code

Prerequisites

Before installing Claude Code, make sure you have these prerequisites:

Required:

  • Node.js 18 or higher -- Claude Code is distributed as an npm package
  • An Anthropic API key -- You need an account at console.anthropic.com
  • A terminal -- macOS Terminal, iTerm2, Windows Terminal, any Linux terminal, or VS Code's integrated terminal

Recommended:

  • Git -- Most Claude Code workflows involve git operations
  • A real project to work with -- Claude Code is most impressive when it has a real codebase to explore

Let's verify your prerequisites:

Warning

Do not let Installation & First Run become a hidden assumption. If teammates cannot see the rule, config, or verification path, Claude will behave inconsistently across sessions.

Bash
# Check Node.js version (need 18+)
node --version

# Check npm version
npm --version

# Check git
git --version
Warning

If your Node.js version is below 18, upgrade before proceeding. Claude Code uses modern Node.js features and will not work with older versions. Use nvm install 18 or download from nodejs.org.

Installation

Claude Code is installed globally via npm. One command:

Bash
npm install -g @anthropic-ai/claude-code

That's it. No complex setup wizards, no Docker containers to configure, no IDE plugins to install. The package installs the claude command globally on your system.

Verify the installation:

Bash
claude --version

You should see a version number printed. If you get "command not found," your npm global bin directory might not be in your PATH. Fix it with:

Bash
# Find where npm installs global packages
npm config get prefix

# Add the bin directory to your PATH (add to your .zshrc or .bashrc)
export PATH="$(npm config get prefix)/bin:$PATH"

Authentication

Claude Code needs an Anthropic API key to communicate with the Claude model. There are two ways to provide it:

Method 1: Interactive Login (Recommended for Personal Use)

Bash
claude

The first time you run claude without a key configured, it will launch an interactive authentication flow. You'll be prompted to enter your API key or log in through the browser.

Tip

If Installation & First Run becomes part of a recurring workflow, document the exact trigger, boundary, and verification step now. Future speed comes from clarity, not from memory.

Method 2: Environment Variable (Recommended for Teams & CI/CD)

Bash
# Add to your .zshrc, .bashrc, or .env
export ANTHROPIC_API_KEY="sk-ant-your-key-here"

Then Claude Code will automatically pick up the key from the environment.

Method 3: Direct flag

Bash
claude --api-key "sk-ant-your-key-here"

This works but isn't recommended for regular use since the key appears in your shell history.

Info

Your API key is associated with your Anthropic account and determines your usage limits and billing. You can create and manage API keys at console.anthropic.com. Keep your key secret -- anyone with your key can make API calls on your account.

Your First Launch

Navigate to a project directory and launch Claude Code:

Bash
cd /path/to/your/project
claude

When Claude Code starts, you'll see a clean prompt waiting for your input. There's no loading screen, no tutorial wizard, no configuration questionnaire. Just a prompt.

What happens behind the scenes at launch:

  1. Directory detection -- Claude Code notes your current working directory as the project root
  2. CLAUDE.md loading -- If a CLAUDE.md file exists in the project (or your home directory), it's loaded as persistent context
  3. Git detection -- If the directory is a git repository, Claude Code is aware of git status, branch info, and recent commits
  4. Session initialization -- A new conversation session begins with a clean context

Map Your Installation & First Run Layers

  1. Open your global, project, and local Claude configuration files.
  2. Write down which rule for this lesson belongs in each layer and why.
  3. Start a fresh Claude Code session and confirm the effective behavior matches your intent.

The First Prompt

This is the moment of truth. What should your first prompt be? Here are some excellent starting prompts for a new project:

Exploration prompts (great first prompts):

"Give me an overview of this project. What does it do, what tech stack does it use, and how is the code organized?"

"Summarize the architecture of this application."

"What are the main entry points and how does data flow through the system?"

Your First Prompt

Do

Start with a real task or exploration prompt that gives Claude meaningful work to do

Don't

Waste context with small talk like 'Hi' or 'What can you do?' -- Claude already knows its capabilities

Specific task prompts:

"Find all TODO comments in the codebase and list them with file locations."

"What dependencies does this project have and are any outdated?"

"Read the README and tell me if it accurately reflects the current state of the code."

The anti-pattern -- don't do this:

"Hi"
"What can you do?"
"Help me code"

These waste context. Claude Code already knows what it can do. Give it a real task from the start.

Understanding the Output

When Claude Code responds, you'll see several types of output:

Test a Safe Installation & First Run Override

  1. Add one narrow allow rule and one narrow deny rule related to this lesson.
  2. Ask Claude to trigger both cases in a scratch project or branch.
  3. Note which rule wins and whether the result matches the hierarchy described here.

Tool use indicators: You'll see when Claude is reading files, running commands, or searching your codebase. These appear as indented lines showing the tool name and parameters:

  Read file: src/index.ts
  Read file: package.json
  Bash: cat tsconfig.json

The response: After gathering information, Claude provides its response in formatted text. Code blocks are syntax-highlighted. File paths are clearly indicated.

Action proposals: When Claude wants to write a file or run a command, it shows you exactly what it plans to do and asks for approval:

  Write file: src/utils/validation.ts
  [shows file contents]

  Allow? (y/n)

Configuration Options

Claude Code has several configuration options you can set:

Setting the model:

Bash
# Use a specific model version
claude --model claude-sonnet-4-20250514

Non-interactive mode (for scripts/CI):

Bash
# Pipe input, get output, no interactive prompts
echo "Explain this project" | claude --print

Resume a previous session:

Bash
# Continue where you left off
claude --resume

Output format:

Bash
# Get JSON-formatted output
claude --output-format json

Project Setup Best Practices

To get the most out of Claude Code from day one, set up your project properly:

Quick Check

What is the main benefit of using Installation & First Run well in Claude Code?

1. Have a README.md Claude Code reads your README to understand the project. A good README means better first-prompt results.

2. Have clear project structure Well-organized code is easier for Claude to navigate. Standard conventions (src/, tests/, lib/) help Claude find things quickly.

3. Create a CLAUDE.md file (covered in depth later) This is your project-specific instruction file for Claude Code. We'll dedicate two full lessons to this.

4. Have a working build/test setup Claude Code can run your build and test commands to verify its own work. If npm test works, Claude can use it.

Tip

The best way to learn Claude Code is to use it on a real project you're actively working on. The AI becomes dramatically more useful when it has a real codebase with real problems to solve, rather than a toy example.

Troubleshooting Common Installation Issues

"command not found: claude" Your npm global bin isn't in PATH. Run npm config get prefix and add the bin subdirectory to your PATH.

"ANTHROPIC_API_KEY not set" Set the environment variable or run claude interactively to authenticate.

Quick Check

After reading this lesson, what should you validate when applying Installation & First Run?

"Node.js version too old" Upgrade Node.js to version 18 or higher. Use nvm for easy version management: nvm install 20.

"Permission denied during install" Don't use sudo npm install -g. Instead, fix npm permissions: npm config set prefix ~/.npm-global and add ~/.npm-global/bin to your PATH.

Slow responses Claude Code communicates with Anthropic's API. Slow responses usually indicate network latency or API load. Check your internet connection and the Anthropic status page.


Apply: Install and First Prompt

Try This Now

Exercise 1: Installation Walkthrough

Follow these steps to install Claude Code on your machine:

  1. Open your terminal
  2. Verify prerequisites:
    Bash
    node --version   # Should be 18+
    npm --version    # Should be 8+
    git --version    # Any recent version
  3. Install Claude Code:
    Bash
    npm install -g @anthropic-ai/claude-code
  4. Verify installation:
    Bash
    claude --version
  5. Set up authentication (choose one):
    Bash
    # Option A: Interactive
    claude
    
    # Option B: Environment variable
    export ANTHROPIC_API_KEY="your-key-here"

Exercise 2: First Project Exploration

Navigate to a project you're currently working on and run these prompts in sequence:

Bash
cd /path/to/your/project
claude

Prompt 1: "Give me a high-level overview of this project: what it does, the tech stack, and how the code is organized."

Prompt 2: "What are the most complex files in this project? Which ones would be hardest for a new developer to understand?"

Prompt 3: "Find any potential bugs or code smells in the most recently modified files."

After each prompt, observe:

  • How many files did Claude Code read?
  • How long did the response take?
  • Was the analysis accurate?
  • Did it find anything surprising?

Exercise 3: Your First Real Task

Pick a small, real task from your current project -- something you'd normally spend 15-30 minutes on. Examples:

  • "Add input validation to the [specific] form"
  • "Write unit tests for [specific] utility function"
  • "Add error handling to the [specific] API endpoint"
  • "Update the README to reflect the current project state"

Run it as a Claude Code prompt. When Claude proposes changes:

  1. Read the proposed changes carefully
  2. Ask yourself: would you have written it the same way?
  3. If something looks wrong, tell Claude -- it can iterate
  4. Approve when you're satisfied

Time how long the entire process takes compared to doing it manually.


Reflect: You're Up and Running

What You've Learned

You've gone from zero to a working Claude Code installation. Let's consolidate the essentials:

Key Takeaways

  • Claude Code installs with a single npm command: npm install -g @anthropic-ai/claude-code
  • Prerequisites are minimal: Node.js 18+, an Anthropic API key, and a terminal
  • Authentication can be done interactively or via the ANTHROPIC_API_KEY environment variable
  • Launch Claude Code by navigating to your project directory and running claude
  • Your first prompt should be a real task or project exploration -- not small talk
  • Claude Code automatically detects your project's git status, structure, and configuration files
  • The permission model ensures all file writes and command executions require your explicit approval

The Installation Mindset

The most important thing about installation is that it's not the important thing. Too many developers spend hours optimizing their tool setup before doing any actual work. Claude Code is intentionally simple to install so you can get to the real value -- using it -- as quickly as possible.

How confident do you feel about applying Installation & First Run in a real project?

If you followed the exercises above, you've already completed your first real task with Claude Code. You've experienced the agentic loop firsthand. You've seen it read your files, reason about your code, and propose changes.

Looking Ahead

In the next chapter, we'll dive into working effectively with Claude Code on a daily basis. You'll learn the Quickstart patterns that productive developers use, master the CLI interface's power features, complete a substantial real-world task end-to-end, and understand the agentic loop deeply enough to guide Claude Code through complex multi-step workflows.

The installation was the easy part. Now the real learning begins.