Skip to content

Chapter 1 · Introduction to Claude Code ​

Chapter goals: Understand Claude Code's positioning and core value, complete installation and authentication setup, and verify the environment is working.

1.1 What Is Claude Code ​

Claude Code is Anthropic's terminal AI coding assistant (agentic coding tool). It runs in your terminal and can directly read/write project files, execute shell commands, run tests, and commit git — not just generate code snippets for you to paste manually.

Key differences from traditional IDE plugins:

FeatureIDE Autocomplete PluginClaude Code
Where it runsInside the editorIndependent terminal process
Can execute commands❌✅ Bash / tests / Git
Context sourceCurrent file onlyEntire project directory
Multi-file editingSingle fileCross-file atomic operations
AutonomyPassive autocompleteActive planning and execution

Core Philosophy

Claude Code follows an "agentic" design philosophy: you describe the goal, it autonomously plans steps, calls tools, verifies results, and iterates — you review and decide.

1.2 Installation ​

Prerequisites ​

  • Node.js 18+
  • macOS / Linux / Windows (WSL)

Global npm Install ​

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

Verify Installation ​

bash
claude --version
# Prints version number, e.g. 2.1.241

claude --help
# Shows all available subcommands and options

1.3 Authentication Setup ​

Claude Code supports two authentication methods:

Method 1: Anthropic API Key (pay-as-you-go) ​

bash
export ANTHROPIC_API_KEY="sk-ant-..."

It's recommended to add this line to ~/.zshrc or ~/.bashrc for persistence.

Method 2: Claude Pro/Max Subscription (included in your subscription) ​

The first time you run claude, select "Log in with Claude account" — a browser will open an OAuth authentication page.

1.4 First Launch ​

Enter any project directory and start Claude Code:

bash
cd my-project/
claude

You'll see an interactive REPL prompt. Type a test message:

text
> Tell me about this project's structure and tech stack

Claude Code will automatically read files in the directory, analyze the code, and provide a summary.

1.5 Version Management ​

bash
# Check current version
claude --version

# Update to the latest
npm update -g @anthropic-ai/claude-code

# Pin a specific version (recommended for team collaboration)
npm install -g @anthropic-ai/claude-code@2.1.241

Version Consistency

When working in a team, it's recommended that all members use the same version of Claude Code to avoid inconsistent behavior from CLAUDE.md instructions.

Chapter Summary ​

  • Claude Code is a terminal AI coding assistant that can directly manipulate files, execute commands, and manage Git;
  • Installed via npm install -g @anthropic-ai/claude-code;
  • Supports both API Key and Pro/Max subscription authentication;
  • Start claude from the project root directory to begin.

🧪 随堂测验

点击你认为正确的选项。答错时会展示正确答案与原因解析。

1. What is the core difference between Claude Code and traditional IDE plugins?

2. What is the correct installation command for Claude Code?

3. Which two authentication methods does Claude Code support?

4. What is the minimum Node.js version required for Claude Code?

🛠️ Hands-on Practice ​

  1. Install Claude Code and verify the version number.
  2. Configure an API Key or log in with your subscription account.
  3. Start claude in an existing project and have it describe the project structure.

After completing, proceed to Chapter 2.