Claude Code: Claude Code Introduction and How It Works

Last updated: 2026-08-31

Claude Code is Anthropic's AI coding Agent — it's not a chatbot, but an intelligent entity that can read files, run tests, modify code, and iterate based on feedback.

Claude Code

💡 Tip: Claude Code's core distinction is "Agent" not "Chat". Chat tools answer questions; Agents autonomously execute operations — reading files, running commands, modifying code, and verifying results in a complete work loop.

📋 Prerequisites: No prior knowledge required, basic command line familiarity helpful

1. What You'll Learn


About Code Example Outputs

This course uses a deterministic/non-deterministic separation pattern for code examples, which is the industry best practice for AI Agent tool tutorials:

Marker Meaning Your Output
Output: Deterministic results (installation, configuration, counts, etc.) Should closely match the example
Interaction Flow: Agent behavior flow (LLM calls, tool selection, etc.) Actual text will differ, but the flow will be similar
Verification: How to check exercise results Follow the described steps to verify
💡 Why the difference? Traditional programming: 1 + 1 = 2 (always the same). AI Agent tools: agent.chat("analyze code") = ??? (different every time). This is an essential characteristic of AI Agent tools, not a bug.


2. A Real Team's Story

(1) The Problem: AI Coding Tool Efficiency Bottleneck

Alice is the tech lead at a mid-sized internet company. Her team tried various AI coding tools:

Product manager Bob's requirements keep growing:

"We need to migrate the entire authentication module from Session to JWT, involving 20+ files, and ensure all tests pass."

(2) Claude Code's Solution

Alice installed Claude Code and launched the migration with one command:

BASH
claude "Migrate the authentication module from Session to JWT, ensure all tests pass"

Claude Code autonomously completed:

  1. Read project structure, located all authentication-related files
  2. Modified authentication logic one by one
  3. Ran the test suite
  4. Fixed code based on failed results
  5. Iterated until all tests passed
TEXT 📖 Display only
Files modified: 23
Tests run: 47
Tests passed: 47
Iterations: 3
Time: ~8 minutes

3. What is Claude Code

(1) Core Definition

Claude Code is a command-line AI Agent that works directly in your local code repository:

Feature Description
Positioning AI coding Agent, not a chat tool
Environment Local terminal / IDE terminal
Work style Read files → Analyze → Modify → Verify → Iterate
Permission model High permissions, can read/write files and execute commands
Model Claude Sonnet / Opus

(2) Agent vs Chat: The Essential Difference

100%
graph LR
    A[User Instruction] --> B[Chat Mode]
    A --> C[Agent Mode]
    B --> B1[Generate Answer]
    B1 --> B2[User Manually Executes]
    C --> C1[Understand Intent]
    C1 --> C2[Read Context]
    C2 --> C3[Execute Operation]
    C3 --> C4[Verify Result]
    C4 --> C5{Success?}
    C5 -->|No| C2
    C5 -->|Yes| C6[Report Result]
Dimension Chat Tool Agent (Claude Code)
Interaction Q&A Autonomous iteration
Code operation Output code snippets Directly modify project files
Context User manually provides Auto-read project files
Verification User manually verifies Auto-run tests/commands
Error handling User self-corrects Self-correct and retry

▶ Example 1: Chat vs Agent Comparison

BASH
# Chat approach: User needs multiple steps
# 1. Ask AI how to fix bug
# 2. Copy code
# 3. Paste into file
# 4. Run test
# 5. Test fails, go back to step 1

# Agent approach: One command does it all
claude "Fix the null pointer exception in user.service.ts, ensure tests pass"

4. How Claude Code Works

(1) Workflow

Claude Code's work loop:

100%
graph TB
    U[User Input] --> P[Intent Parsing]
    P --> R[Read Project Context]
    R --> A[Plan Operations]
    A --> E[Execute Operations]
    E --> V[Verify Results]
    V --> S{Success?}
    S -->|Yes| RPT[Report Results]
    S -->|No| A

(2) Permissions and Security

Claude Code has high permissions but provides multi-layer security controls:

Permission Level Scope Confirmation Method
Read Read any project file Auto-allowed
Write Modify project files First confirm / Auto
Execute Run shell commands Requires confirmation (configurable auto)
Network Install packages, access APIs Requires confirmation

▶ Example 2: Claude Code Work Process

BASH
$ claude "Create date.ts under src/utils/ with common date formatting functions and tests"

# Claude Code's autonomous work process:
# 1. Reading src/utils/ directory structure...
# 2. Reading existing utils for style consistency...
# 3. Creating src/utils/date.ts with formatDate(), relativeTime(), etc.
# 4. Creating src/utils/__tests__/date.test.ts
# 5. Running: npm test -- src/utils/__tests__/date.test.ts
# 6. 2 tests failing... fixing edge cases
# 7. Running: npm test -- src/utils/__tests__/date.test.ts
# 8. All 6 tests passed ✓

5. Comparison with Other AI Coding Tools

Tool Type Work Scope Agent Ability Model
Claude Code CLI Agent Full project Strong Claude
GitHub Copilot IDE Plugin Single file completion Weak GPT series
Cursor IDE + Agent Within IDE Medium Multi-model
Aider CLI Agent Full project Medium Multi-model
Codex CLI CLI Agent Full project Strong GPT series
OpenCode CLI Agent Full project Medium Multi-model

▶ Example 3: Alice's Tool Evaluation

PYTHON
def evaluate_tool(tool_name, agent_score, scope_score, multi_file):
    score = agent_score * 0.4 + scope_score * 0.3 + (1 if multi_file else 0) * 0.3
    return round(score, 2)

tools = {
    "Claude Code": {"agent": 9, "scope": 9, "multi_file": True},
    "Copilot": {"agent": 3, "scope": 4, "multi_file": False},
    "Cursor": {"agent": 6, "scope": 7, "multi_file": True},
    "Aider": {"agent": 7, "scope": 8, "multi_file": True},
}

for name, scores in tools.items():
    result = evaluate_tool(name, scores["agent"], scores["scope"], scores["multi_file"])
    print(f"{name}: {result}")

6. Comprehensive Example: Project-Level Refactoring

BASH
# Scenario: Alice needs to migrate an Express project to Fastify

$ claude "Migrate the entire project from Express to Fastify:
1. Replace all route definitions
2. Update middleware syntax
3. Modify startup script
4. Ensure all tests pass
5. Update package.json dependencies"

# Claude Code autonomously executes:
# → Scanning 45 files for Express patterns...
# → Converting route definitions (32 routes)...
# → Updating middleware (8 files)...
# → Running test suite: 89/89 passed ✓
# → Updating package.json...
# → Removing Express dependencies...
# → Final test run: 89/89 passed ✓

❓ FAQ

Q What's the difference between Claude Code and Claude.ai?
A Claude.ai is a web chat interface that only outputs text answers; Claude Code is a CLI Agent that can directly operate your code project. Both use the same underlying model but have completely different interaction modes.
Q Does Claude Code secretly upload my code?
A Claude Code sends code context to the Anthropic API for inference, but Anthropic claims not to use API data for model training. For sensitive projects, consider local model solutions.
Q Can I use Claude Code without internet?
A No. Claude Code requires a connection to the Anthropic API and cannot work offline.
Q What programming languages does Claude Code support?
A Theoretically all — it can read/write any text file and execute any shell command. Best support for TypeScript/Python/Go and other mainstream languages.
Q Which is better, Claude Code or Aider?
A Claude Code has higher integration and stronger Agent capabilities but only supports Claude models; Aider supports multiple models and is more flexible. Choose based on whether you need multi-model support and IDE integration.
Q Will Claude Code replace programmers?
A No. Claude Code is an acceleration tool, good at repetitive work and implementing known patterns, but architecture design, requirement analysis, and complex decisions still need humans.

📖 Summary


📝 Exercises

  1. Basic (⭐): List three core differences between Claude Code and ChatGPT in coding assistance.
  2. Intermediate (⭐⭐): Choose an AI coding tool for your project and write your reasoning (refer to the comparison table).
  3. Advanced (⭐⭐⭐): Design a workflow specifying which tasks suit Claude Code and which suit Copilot, with decision criteria.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏