---
title: "Claude Code：从命令行工具到真正的 AI agent - 一位 CTO 的经验"
url: "https://zuey.me/articles/claude-code-tu-tool-dong-lenh-den-ai-agent-thuc-thu-kinh-nghiem-tu-mot-cto?lang=zh"
locale: zh
access: free
full_text: true
published_at: "2025-08-19T13:42:22.000Z"
tags: ["Claude Code", "AI Agents", "编程"]
translations:
  en: "https://zuey.me/articles/claude-code-tu-tool-dong-lenh-den-ai-agent-thuc-thu-kinh-nghiem-tu-mot-cto.md?lang=en"
  vi: "https://zuey.me/articles/claude-code-tu-tool-dong-lenh-den-ai-agent-thuc-thu-kinh-nghiem-tu-mot-cto.md?lang=vi"
  ko: "https://zuey.me/articles/claude-code-tu-tool-dong-lenh-den-ai-agent-thuc-thu-kinh-nghiem-tu-mot-cto.md?lang=ko"
  ja: "https://zuey.me/articles/claude-code-tu-tool-dong-lenh-den-ai-agent-thuc-thu-kinh-nghiem-tu-mot-cto.md?lang=ja"
---
# Claude Code：从命令行工具到真正的 AI agent - 一位 CTO 的经验

> Claude Code 不只是命令行工具，而是真正的 AI agent。我整理了 AI native 创业公司 CTO Patrick 的心得：CLAUDE.md、GitHub 集成、Explore - Plan - Execute 框架，以及 double escape 技巧。

大家好！今天想聊聊 Claude Code——很多人在用，但 90% 的能力都还没发挥出来。Patrick（一家 AI native 创业公司的 CTO）和他团队的一个视频让我大开眼界：原来可以把 Claude Code 从普通聊天机器人变成超强的 AI agent。

> **INFO:** **TL;DR**：给每个子文件夹写 CLAUDE.md，让大家像 tag 真实开发者一样在 GitHub 上 tag Claude，把好用的 prompt 存成 commands，按 **Explore - Plan - Execute** 循环来做，再用 **double escape** 把一个“聪明的 Claude”fork 到多个终端。

### Claude Code 是什么，为什么值得关注？

看完视频又查了些资料，我的理解是：**Claude Code 不只是一个命令行工具**——它是即将到来的强大 AI agent 浪潮中的**第一个 AI agent**。

#### 核心区别：Claude Code vs Cursor

Patrick 解释得非常清楚：

| 工具 | 擅长什么 |
| --- | --- |
| **Claude Code** | 擅长 **multi-step processing**。遇到大任务时，它会自己拆成 subtasks，一步步执行。非常适合从零开始一个项目。 |
| **Cursor** | 依然适合解决具体问题、处理特定文件或代码行，因为选中很方便。 |

有意思的是，Patrick 说他光靠 Claude Code 就能 **“every other couple of days”** 开一个新项目。生产力的提升简直惊人。

### 高效使用 Claude Code 的秘诀

#### 1. CLAUDE.md——“Claude Code 的 README”

这是你的**主要 context 文件**。运行 `/init` 时，它会：

- 生成 codebase 概览
- 分析所有文件
- 理解启动流程和结构

**Patrick 的 pro tip**：给**每个子文件夹**都建一个 CLAUDE.md。这样 Claude 就不用“疯狂 grep”，可以细致地追踪每个函数和文件。

#### 2. GitHub 集成——真正的 game changer

这才是最 **WOW** 的部分：

- 只要跑一条命令，Claude Code 就会自动接入 GitHub repo
- 你可以像 tag 真实开发者一样 tag Claude
- 它会建 issue、列 checklist、执行，甚至处理 code review

> 我可以同时跑 30 条不同的命令，让 Claude Code 为所有 feature 生成 PR，最后再自动 tag Claude。等我回到家，一切都搞定了。
>
> — Patrick

#### 3. Commands——分享“超神 prompt”

Claude Code 里的 commands = 存成文件的 prompt，可以：

- 在多个项目之间共享
- 在团队内共享
- 组成完整的 workflow

比如 Patrick 有一个超长但非常好用的 **codebase analyzer command**，他甚至做了一个 GitHub action，直接在 GitHub 界面上运行。

### “Explore - Plan - Execute” 框架

这是 Patrick 推荐的**核心方法论**：

```mermaid
flowchart LR
  E["Explore：读 codebase，建立 context"] --> P["Plan：按风险等级拆分工作"]
  P --> X["Execute：逐个 PR 写代码"]
  E -->|"概览不对就 /clear 重来"| E
```

*Explore - Plan - Execute 循环*

#### 1. Explore 阶段

```text
# 不要直接跳到执行，先这样做：
"Prepare to work on this. Read the codebase, understand the structure."
```

**重点**：逼 Claude 花 token 去建立 context。如果概览不对，就 `/clear` 重新开始——别试图去修。

#### 2. Plan 阶段

Patrick 不用 plan mode，而是更喜欢：

```text
"Think hardest. Write function names in 1-3 sentences about what they do. Write test names in 5-10 words about behavior they cover."
```

**按风险规划**：

#### 小任务

别想太多，直接写代码

#### 中到大任务

拆成可测试、可部署的 PR

#### 高风险

计划做 2-3 版，仔细 review

#### 3. Execute 阶段

利用 explore 阶段建立的 context。Patrick 推荐：

```text
"Work on PR1. Think hard. Write elegant code. NO backwards compatibility."
```

### Double escape——神级技巧

这是视频里真正的**宝藏**：

1. explore 并建立 context 之后（7 分钟，50k tokens）
2. 按 **double escape** fork 对话
3. 开一个新 tab，点 **resume**
4. 你就能有 **5 个终端**共享同样出色的 context

> 如果碰到一个聪明的 Claude，就留着它，反复使用。
>
> — Patrick

### 用 Claude 做测试驱动开发（TDD）——出乎意料地好

虽然 Patrick 自己写代码时讨厌 TDD，但交给 Claude 就不一样了：

> Claude 先写一个会失败的测试，再写让测试通过的代码。它做得非常出色。
>
> — Patrick

### 其他深刻洞见

#### Context 管理

> **WARN:** **永远不要用 compact**——“纯属浪费时间，会造出一个非常拧巴的笨 Claude”。当 context window 只剩 5% 时，先把内容记录下来，再 rewind 回 40%。

#### 模型选择

- 默认是 Sonnet，Opus 贵 4 倍
- Max plan（$200/月）可无限使用——**Patrick 强烈推荐**
- 开启 thinking hard 的 Sonnet 4 在很多任务上有时比 Opus 还好

#### “企业级”问题

Claude “loves to be enterprise ready”——你得跟这个倾向对着干，因为它会产出过度复杂的方案。

### MCP（Model Context Protocol）——扩展能力

Claude Code 支持 MCP，可以：

- 连接 Google Drive、Jira、Slack
- 加入自定义开发工具
- 把功能扩展到写代码之外

### Agent swarms——不远的未来

视频还提到了 **agent swarms**——多个容器并行解决问题，然后人工或通过 LLM judge 比较结果。Patrick 的一个朋友搭了 3 个 Opus 实例，配上 acceptance criteria 和 style guide。

### 总结——谁适合用 Claude Code？

分析完视频又做了些研究，我觉得 Claude Code 适合：

#### ✅ 适合用

- 想自动化重复性任务的开发者
- 需要统一 workflow 的团队
- codebase 庞大复杂的项目
- 经常开新项目的人

#### ❌ 也许还不是时候

- 还不熟悉命令行的新手
- 1000 行以下的小项目
- 更喜欢 Cursor 这类可视化 IDE 体验的人

### AI 编程的未来

Patrick 强调，Anthropic 的 ML 团队和产品团队之间的**紧密协作**让 Claude Code 与众不同。Opus 4 和 Sonnet 4 被调教得“特别想用 bash 命令”——和 Claude Code 完美契合。

---

> **TIP:** **结论**：Claude Code 不只是一个编程工具——它让我们一窥 agentic workflow 的未来。当 AI agent 成为主流，从 Claude Code 学到的模式和经验将适用于很多其他领域。

你试过 Claude Code 了吗？来分享一下你的体验吧！

*P.S.：原视频长达 2 个多小时，内容极其密集。如果你认真对待 AI 编程工具，推荐完整看一遍。*
