Loading lesson…
Loading lesson…
Claude Code is Anthropic's official AI-native coding tool. It integrates large-language-model capability directly into the terminal, so you can complete programming tasks by collaborating with AI in natural language. Unlike traditional code-completion tools, Claude Code can understand the context of an entire project and execute complex development tasks. From code generation to refactoring, from debugging to documentation writing, it can handle all of them.
This chapter helps you quickly master the core usage of Claude Code, including installation and setup, basic operations, practical techniques, and commonly used commands. Whether this is your first time using an AI coding tool, or you want to use Claude Code more efficiently, you will find what you need here.
Claude Code is built on Node.js, so before installation make sure Node.js 18 or above is installed on your system. The process is very simple and usually takes only a few minutes.
In traditional development workflows, developers frequently switch between editor, terminal, browser, and docs. Claude Code unifies these workflows into one interface: in the same terminal window, you can write code, run tests, read docs, and even collaborate with teammates. More importantly, it can understand your project structure and remember your coding habits, becoming a true programming assistant.
Manual installation is suitable for developers who like full control over each step, and it also helps you clearly understand tool components.
# Install Claude Code CLI globally
# Use -g to install command globally, so it can be used in any directory
npm install -g @anthropic-ai/claude-code
# Verify installation
# If version is shown (for example 0.1.25), installation succeeded
claude --version
During installation, npm automatically downloads dependencies and configures environment variables. If you run into permission problems, try sudo (macOS/Linux) or run terminal as administrator (Windows).
If you are already using other AI coding assistants (such as Cursor, Windsurf, or the AI Agent in this project), you can let them complete installation for you. The benefit is that AI can detect your environment automatically, handle dependency conflicts, and choose the best installation route for your system.
You can just say:
Help me install Anthropic Claude Code.
Or more specifically:
Install Claude Code CLI and check whether my Node.js version is compatible.
An AI Agent will:
After installation, enter your project directory and start Claude Code:
# Enter project directory (Claude Code works in current directory)
cd /path/to/your/project
# Start Claude Code
claude
At first launch, Claude Code guides you through several important setup steps:
Special Note for Users in Mainland China
Due to network reasons, users in mainland China may not be able to directly access Anthropic official services. Claude Code supports third-party services compatible with Anthropic API format, and this is technically feasible.
You have two options:
- Use API token directly: buy a token from a provider compatible with Anthropic API and configure it with environment variables
- Use a Coding Plan: some providers offer coding-optimized plans that are usually more cost-effective for coding scenarios
Recommended approach: let an AI Agent help you configure. You only need to provide provider config information (API endpoint, key, etc.), and AI can set environment variables correctly.
See detailed setup guide: How to install claudecode and configure environment variables
After installation, do not rush into formal projects. Run a few small experiments first to understand how Claude Code works. These three experiments are designed from easy to advanced, corresponding to three core abilities: natural-language understanding, content generation, and code execution.
The purpose is to experience Claude Code's natural-language understanding. Unlike normal search engines, Claude Code can understand context, carry multi-turn conversation, and adjust answers from your feedback.
Try these prompts:
Hello, who are you?
Claude introduces itself as Claude Code, an AI coding assistant by Anthropic.
What is a closure? Give me the too-long-didnt-read version.
Observe how Claude uses "too-long-didnt-read" as a hint and gives concise but accurate explanation.
What is the difference between JavaScript and TypeScript?
This is a technical comparison question. Check whether Claude provides a structured and in-depth answer.
Experiment point: note Claude's response style. It usually gives the core conclusion first, then details. This "inverted pyramid" style is excellent for fast information retrieval.
This experiment demonstrates Claude Code's content-generation capability. For developers, writing docs is often painful. Claude can quickly generate clear and complete docs from requirements.
Enter this instruction:
Write a Markdown document of commonly used Git commands.
Requirements: include command, explanation, and example.
What Claude does:
Expected output sample:
# Common Git Command Cheat Sheet
## Initialize Repository
| Command | Explanation | Example |
|------|------|------|
| `git init` | Initialize new repository | `git init my-project` |
| `git clone` | Clone remote repository | `git clone https://github.com/user/repo.git` |
...
Advanced attempts: you can add extra requirements like "add Chinese comments", "sort by frequency", "include common error handling", etc., and observe how Claude adapts output.
This is the most challenging experiment. It demonstrates Claude Code's full workflow: understand requirement, write code, create files, run program, and handle errors. Through it, you can really feel the power of an AI coding assistant.
Enter this instruction:
Write a Snake game in Python.
Requirements:
1. Use pygame
2. Show score
3. Press ESC to exit
After writing, help me run it.
Claude executes these steps:
Step 1: Check environment
Step 2: Write code
snake_game.py)Step 3: Run game
Step 4: Follow-up support
Value of this experiment:
Common questions:
Q: What if pygame is not installed?
pip install pygame, or you can ask Claude to install itQ: Terminal is occupied after game starts, what should I do?
Q: Can I switch language?