Claude Code 高效使用指南

核心原则:在审批书面计划之前,绝不让 Claude 写代码。
适用场景 中大型功能开发 前提条件 已安装 Claude Code CLI
研究
→
规划
→
批注迭代
→
Todo
→
实现
→
监工纠偏
四道防线:研究防止无知变更 → 计划防止错误变更 → 批注注入人类判断 → 一旦所有决策完成,实现不中断执行

研究(Research)

让 Claude 深度阅读代码库。必须使用 deeply、in great details、intricacies、go through everything 等限定词——不加这些词,Claude 会认为浅层浏览就够了。

要求将研究结果写入持久化文件 research.md,绝不接受纯口头摘要。这份文档是你的审查面(review surface):可以在规划前发现 Claude 的误解,防止它忽略缓存层、违反 ORM 约定、或重复已有逻辑。

示例提示词:

read this folder in depth, understand how it works deeply, what it does
and all its specificities. when that's done, write a detailed report of
your learnings and findings in research.md
study the notification system in great details, understand the intricacies
of it and write a detailed research.md document with everything there is
to know about how notifications work

规划(Planning)

要求 Claude 生成详细的 plan.md,包含代码片段、文件路径和权衡考量。使用自定义 markdown 文件而非内置 plan mode(原文直言 "The built-in plan mode sucks"),原因有三:

  1. 你拥有编辑器的完整控制权
  2. 可以直接添加行内批注
  3. 文件作为项目产物持久化保存

对于边界清晰的功能,可提供开源项目中的参考实现——Claude 有具体参考时表现显著更好。

示例提示词:

I want to build a new feature <name and description> that extends the
system to perform <business outcome>. write a detailed plan.md document
outlining how to implement this. include code snippets
the list endpoint should support cursor-based pagination instead of
offset. write a detailed plan.md for how to achieve this. read source
files before suggesting changes, base the plan on the actual codebase

批注循环(Annotation Cycle)— 核心技巧

这是整套方法论最具差异化的环节。plan.md 是你和 Claude 之间的共享可变状态,支持位置精确的沟通。

  1. 在编辑器中审阅 plan.md
  2. 直接在文档中添加行内批注(两个词到整段话皆可)
  3. 回复 Claude:"I added a few notes to the document, address all the notes and update the document accordingly. don't implement yet."
  4. 重复步骤 1~3,通常 1~6 轮,直到计划完善
关键守卫语: don't implement yet — 每轮必须加上,防止 Claude 提前动手写代码。

批注的作用:将你的判断注入计划。

原文批注示例(长度从两个词到整段话不等):

经过数轮批注,计划将从通用方案收敛为适配项目的具体方案。

Todo 清单(规划与实现的桥梁)

在计划定稿后、实现之前,单独生成一份细粒度的 todo 清单:

add a detailed todo list to the plan, with all the phases and individual
tasks necessary to complete the plan — don't implement yet

实现(Implementation)

当所有决策在规划阶段验证通过后,实现就是机械执行而非创造性工作——创造性工作已在批注阶段完成。你的角色从架构师转为监工。

没有规划阶段的后果:Claude 会在早期做出看似合理但错误的假设,在其上构建约 15 分钟后才发现需要全部拆解。

标准启动指令(以 TypeScript 项目为例,其他语言请替换对应的类型检查工具和代码规范):

implement it all. when you're done with a task or phase, mark it as
completed in the plan document. do not stop until all tasks and phases
are completed. do not add unnecessary comments or jsdocs, do not use
any or unknown types. continuously run typecheck to make sure you're
not introducing new issues.

各分句用意:

实现过程中的交互技巧

场景做法示例
小修正极简指令wider、still cropped、there's a 2px gap
检查遗漏指出未实现的部分You didn't implement the deduplicateByTitle function
纠正位置指出放错地方的实现You built the settings page in the main app when it should be in the admin app, move it
参考已有代码指向具体位置this table should look exactly like the users table, same header, same pagination, same row density
UI 问题直接贴截图截图比文字描述精确得多
方向错误回滚并重新规划I reverted everything. Now all I want is to make the list view more minimal — nothing else

缩小范围后重新实现几乎总是比渐进修复错误方案效果更好。

保持驾驶员心态

不要给予 Claude 完全自主权。它可能提出技术上正确但对项目不合适的方案——过度工程化、破坏公开 API、或选择不必要的复杂方案。

操作示例
挑选方案"for the first one, just use Promise.all, don't make it overly complicated; for the third one, extract it into a separate function for readability; ignore the fourth and fifth ones, they're not worth the complexity"
裁剪范围"remove the download feature from the plan, I don't want to implement this now"
保护接口"the signatures of these three functions should not change, the caller should adapt, not the library"
推翻技术选择"use this library's built-in method instead of writing a custom one"

分工原则:Claude 负责机械执行,人负责判断。计划捕获大决策,实现中的选择性指导处理新出现的问题。

关于长会话

在单次长会话中运行整个工作流。Claude Code 的 context window 会自动压缩(auto-compaction),而 plan.md 作为磁盘上的文件,在压缩后仍能以完整保真度保留。作者观察到,即使上下文窗口使用超过 50%,也没有出现性能下降。