使用 Claude Code 进行软件开发
Dani Zysman
AI Curriculum Manager @ DataCamp

在 Claude Code 中,Agent 是专业化的 AI 助手:
| Agent | 目的 | 何时使用 |
|---|---|---|
| Explore | 只读代码库调研 | "Map this architecture" |
| Plan | 研究与制定策略 | "How should we approach this?" |
| General | 使用全套工具执行任务 | 大多数工作的默认选项 |
使用 /agents 列出全部可用 agent

.claude/agents/code-reviewer.mdname:Agent 标识符description:触发条件___
# code-reviewer.md
name: code-reviewer
description: Reviews code for
best practices
___
Check for:
1. Clear naming conventions
2. Proper error handling
3. Performance concerns
> /agents> [Select] Create new agent> [Select] Project level (.claude/agents)> [Select] Generate with Claude (recommended)> Create a code reviewer agent that reviews code for naming, error handling, and performance.
查看并批准生成的文件。
music-analytics-api/
app.py
routes.py # <- 我们将评审此文件
models.py
analytics.py
CLAUDE.md
.claude/
agents/
code-reviewer.md # <- 我们的自定义 agent
无子 agent(直接处理):
"Fix the bug in routes.py"
-> Claude 直接处理
"Add validation here"
-> Claude 直接处理
触发子 agent:
"Map the architecture"
-> Explore agent
"How should we refactor?"
-> Plan agent
> @code-reviewer review @routes.py
Review Complete
Quick Fixes:
- Remove unused `session` import (line 3)
- Replace hardcoded `* 5` popularity metric with a named constant
Structural Issues:
- Album dictionaries built twice in get_album_stats() and
get_average_tracks() extract to a shared helper
- get_artist_albums() returns empty list if artist doesn't exist;
validate artist first
- No range validation on artist_id parameter
Would you like me to fix any of these?

| 问题类型 | 系统响应 |
|---|---|
| "What does this function do?" | Claude 直接回答 |
| "How does auth work across this codebase?" | Explore agent 调研 |
| "What's the best approach to refactor this?" | Plan agent 研究方案 |
| "code review @routes.py" | 由自定义 agent 处理 |
使用 Claude Code 进行软件开发