Chapter 05 | Install Claude Code

4 MIN READ | UPDATED: 2026-05-15

Chapter 5: 🎯 Chapter 5: Installing Claude Code

📖 Learning Objectives

Run the claude command and complete your first conversation.

💻 Installation

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

# Verify
claude --version

🚀 First Launch

mkdir ~/work/learn-claude && cd ~/work/learn-claude
claude

The first time, you will be prompted to log in:

sequenceDiagram
    participant You as You
    participant CC as Claude Code
    participant Browser as Browser
    participant Anth as Anthropic

    You->>CC: claude
    CC->>Browser: Open login link
    Browser->>Anth: OAuth Authorization
    Anth->>Browser: token
    Browser->>CC: Write to ~/.claude/credentials
    CC->>You: ready

After logging in, you will see an interactive terminal UI—this is Claude Code's "cockpit."

📝 Three Essential Commands

Whenever you feel lost, these three commands will help you:

Command Purpose
/help Lists all commands
/model Switches models (also shows current model)
/context Shows token usage for the current session

Try /context and you will see:

Tokens: 8.3k / 1m (0.8%)
System prompt: 8.3k tokens
Free space: 991k (99.2%)

→ Opus 4.7's 1M context, currently almost entirely empty.

📁 The Concept of the Working Directory

The directory where Claude Code is launched becomes its "project root." All relative paths for Edit/Write operations are based here. If you change the directory (and restart claude), everything resets.

~/work/learn-claude/        ← Where you launch claude
                            ← This is $CLAUDE_PROJECT_DIR
                            ← .claude/ and CLAUDE.md are in this layer

💬 First Conversation Test

Tell it:

You: Create a hello.txt file in the current directory and write "hello world" inside it.

If your permission mode is default (asks every time), it will pop up a confirmation. After allowing, the file will be created.

$ ls
hello.txt
$ cat hello.txt
hello world

⌨️ Common Keyboard Shortcuts

Key Action
Esc Interrupts Claude's current response
Ctrl+R Search command history
Ctrl+C twice Exits Claude Code
!command Allows you to run shell commands directly (without Claude)

✅ What You Can Do Now

  • Run Claude Code, log in, and check context
  • Have Claude create files in your directory
  • Understand the boundaries of the working directory

In the next chapter, we'll install OpenSpec to give Claude the ability to "remember requirements."