返回播客Claude
Claude Code 101
Claude Code 中的探索→计划→编码→提交工作流
If you take one thing away from Claude code, let it be this workflow: explore, plan, code, and commit.
如果你从 Claude Code 中只带走一件事,那就是这个工作流:探索、plan、编码、commit。
Without this, most people jump straight to pasting in Claude to write code, which means more course correcting later on.
没有这个流程,大多数人会直接把需求粘贴给 Claude 让它写代码,这意味着后期需要更多纠偏。
The fastest way to handle step one and two is with plan mode.
处理第一步和第二步最快的方式是使用 plan mode。
With plan mode, Claude can't edit files.
在 plan mode 下,Claude 无法编辑文件。
It just reads files to gather research on how to tackle this implementation.
它只会读取文件,研究如何处理这个实现。
To enter plan mode, hit shift and tab until you see the plan mode under the text input.
要进入 plan mode,按下 shift 和 tab,直到看到文本输入框下方出现 plan mode。
I need to add WebP conversion to our image upload pipeline.
我需要在图片上传流程中添加 WebP 转换功能。
Figure out where in the pipeline it should happen, whether we need new dependencies, and how to approach it.
搞清楚它应该在流程中的哪个环节发生,是否需要新的依赖,以及如何实现。
And Claude will read relevant files, do some web searches, and give you a plan of action.
Claude 会读取相关文件,进行一些网络搜索,并给出行动计划。
Make sure you review it and determine if it meets your criteria.
务必对其进行审查,确认它是否符合你的标准。
Otherwise, I can ask it to add on or revise some areas.
如果不符合,我可以让它补充或修改某些部分。
Perfect.
完美。
And this right here is the best place to course correct because it's before any code is written.
这里是最佳的纠偏时机,因为此时还没有任何代码被写出来。
You can also use explore without being in plan mode by just asking Claude to explore your code base.
你也可以不进入 plan mode,直接让 Claude 探索你的代码库。
Now, once the plan looks good, you can select approve to accept the plan and let Claude toggle all of the list items it provided.
现在,当 plan 看起来没问题后,你可以选择批准来接受 plan,让 Claude 逐一完成它提供的列表项。
You can determine if you want Claude to auto accept the file edits or ask every single time.
你可以决定是否让 Claude 自动接受文件编辑,还是每次都询问。
Claude will do its best to troubleshoot your code base before considering the plan finished.
Claude 会尽力在认为 plan 完成之前对你的代码库进行排错。
But at times, you'll need to course correct.
但有时候,你需要进行纠偏。
This is the benefit of working with plan mode because after the plan is finished, we also have the context of how it got to the results to help it guide its next decision.
这就是使用 plan mode 的好处,因为 plan 完成后,我们还有它如何得出结果的上下文,可以帮助它引导下一步决策。
In order for Claude to be confident in its results, it has to be clear on what it deems correct.
为了让 Claude 对其结果有信心,它需要清楚地知道什么才算正确。
When writing your plan, make this explicit.
在编写 plan 时,请明确说明这一点。
Adding tools that will help Claude complete its goals will remove a lot of back and forth.
添加能帮助 Claude 完成目标的工具,可以减少大量来回沟通。
For example, if you're building web UIs, make sure you have the Claude and Chrome extension so that Claude code can control a tab and test out the UI before deeming it finished.
例如,如果你在构建 Web UI,请确保安装了 Claude 和 Chrome 扩展,这样 Claude Code 就可以控制标签页并在认为完成之前测试 UI。
In your project, include a test suite that Claude can continuously validate on.
在你的项目中加入一个测试套件,供 Claude 持续验证。
Claude can even write tests for you.
Claude 甚至可以为你编写测试。
Before passing this off to Claude, make sure that the tests are a source of truth for you and your team to avoid any false positives.
在将其交给 Claude 之前,请确保测试对你和你的团队来说是可靠的事实来源,以避免任何误报。
Quick tip, if you find Claude keeps running into the same issues, ask Claude to save the solution to his Claude MD file.
小提示:如果你发现 Claude 反复遇到同样的问题,让 Claude 把解决方案保存到它的 Claude MD 文件中。
Now, once you have tested for yourself and are happy with the results, it's time to push your code.
现在,一旦你自己测试过并对结果满意,就该推送你的代码了。
A tip before you commit, run a sub agent code reviewer to look at your code.
commit 前的一个小建议:运行一个子 agent 代码审查员来检查你的代码。
Then you get Claude to generate a commit message for you in your style.
然后让 Claude 按照你的风格为你生成 commit 消息。
Rinse and repeat.
周而复始。
If you want to be effective with Claude code, follow the explore, plan, code, and commit workflow.
如果你想高效使用 Claude Code,请遵循探索、plan、编码、commit 的工作流。
Exploration will give the relevant context
探索将为 Claude 提供你项目所需的相关上下文
Claude needs for your project.
Claude 需要用于你的项目。
Plan will create a plan of action that Claude will use to determine if they are successful.
plan 将创建一个行动计划,Claude 将用它来判断是否成功。
Code is the back and forth that you and Claude do before settling on the final outcomes of the plan.
编码是你和 Claude 在确定 plan 最终结果之前来回进行的过程。
Commit helps you review and push your code so you can start on your next feature.
commit 帮助你审查并推送代码,这样你就可以开始下一个功能了。