多步骤任务在写代码之前需要一份书面计划。计划能在你做出任何不可逆决策之前,揭示排序假设和风险最高的步骤。
如果一项任务只是单次修改——重命名一个函数、修正一个拼写错误——你不需要计划。但如果是"在 iOS 应用、Android 应用和 Web 端打通 OAuth",你就需要了。区别在于"走错路的代价"何时浮现。
没有计划,排序决策就会被固化进 LingCode 写的第一个文件里。等到第 8 步你才发现,第 2 步本应放在最后——此时你要么撤销八次提交,要么顶着一个半残的代码库继续返工。两种选择都代价高昂。
一份书面计划能做到三件事,值回你花在编写上的时间:
以下情况需要写计划:
任务确实只是一次修改时,不要写计划。为一行代码的修复写计划,是把拖延症包装成工程严谨性。
计划的质量取决于它所依据的规格说明。如果你还没有做头脑风暴——澄清范围、列出需求、勾勒设计——请先完成那一步。参见动手之前先头脑风暴。
头脑风暴的输出就是计划的输入。向 LingCode 请求计划时,粘贴(或引用)需求列表和设计草图。对着"加 OAuth"规划,你会得到一份通用计划;对着"在 iOS 应用和 Android 应用中添加 Google OAuth,共用同一个 Firebase 项目,并为已有账户的用户保留邮箱/密码登录作为兜底"规划,你才能得到一份真正有用的计划。
提示 LingCode 写一个计划文件,而不是一条聊天消息。文件可以审阅、可以做 diff,执行偏差时也可以随时引用:
Don't write code yet. Write IMPLEMENTATION_PLAN.md in the repo
root.
Structure:
1. Goal — one sentence.
2. Non-goals — bulleted list of things explicitly out of scope.
3. Steps — numbered, each step in this format:
- What changes (files touched, what they do after).
- Why this step is ordered here (what depends on it,
what it depends on).
- How we verify it works before moving on.
4. Riskiest step — name the single step where the project is
most likely to break, and why.
5. Rollback plan — what we revert if step N fails. Per-step
where it matters, otherwise one sentence at the end.
Aim for 6-12 steps. If it's more than 12, the task is too big
and should be split. If it's fewer than 3, it doesn't need a
plan — just do it.
"最高风险步骤"这一节是大多数人会略过的。它也是最能让规划时间物有所值的部分。提前知道哪个步骤最可能搞砸项目,意味着你可以优先执行它——趁你精力充沛、其余工作尚未提交的时候。
LingCode 交出计划文件时,不要直接接受。像审查者一样阅读它,问自己:
确定了最高风险步骤后,让 LingCode 重新排序,使其尽早出现:
The OAuth provider integration is the riskiest step. Reorder
the plan so it happens before the iOS UI work and before the
Android UI work — both can be stubbed until we know the
integration works end-to-end.
Move it to step 2 (after the brainstorm-confirming exploration
in step 1). Adjust dependencies accordingly. Update the
verification for step 2 to be "can complete a real OAuth round
trip in a test app."
你未必总能把风险步骤放在最前面——有时它有硬依赖。在依赖条件允许的范围内,让它尽量靠前。原则是:如果这一步失败,你希望在第一天就知道,而不是第五天。
重新审阅每个步骤的"如何验证有效"这一行。只有每个步骤都有真实的检查,计划才是诚实的。替换所有模糊表述:
xcodebuild test -scheme MyApp 退出码为 0,且没有新增失败。"模糊的验证会让计划沦为"嗯,看起来做完了"。现在收紧这些条件,执行阶段的检查点(下一篇教程)才有实质内容可查。
将计划文件作为独立提交提交到仓库,与任何代码分开。原因有两个:
git add IMPLEMENTATION_PLAN.md
git commit -m "Add implementation plan for OAuth migration"
现在你可以开始执行了。下一篇教程将介绍如何逐步执行计划并设置检查点——这是将计划从一份文档转化为实际结果的后半程。
将规划工作流打包为一个技能,让 LingCode 在处理多步骤工作时自动触发:
---
name: writing-plans
description: Use when you have a spec or requirements for a multi-step task, before touching code. Triggers: 'plan this', 'write an implementation plan', 'how should I approach this multi-step task', 'design doc', complex task with >3 steps, spec / requirements input. Actions: produce IMPLEMENTATION_PLAN.md with goal, non-goals, 6-12 ordered steps each with per-step verification, explicit riskiest step (put first), rollback plan. Output: reviewable plan file. Anti-patterns: ordering-by-dependency-only (risky-first beats dependency-first), unverified steps, no rollback.
---
Write an implementation plan to IMPLEMENTATION_PLAN.md before
writing any code.
Structure the file:
1. Goal — one sentence.
2. Non-goals — bulleted list of out-of-scope items.
3. Steps — 6-12 numbered steps. Each step has:
- What changes (files, new behavior).
- Why ordered here (dependencies, what it unblocks).
- How to verify before moving on (specific commands or
observable outcomes, not "looks right").
4. Riskiest step — name the single step most likely to fail
and why. Move it as early in the order as dependencies
allow.
5. Rollback plan — what to revert if a step fails.
After writing the plan, stop and wait for review. Don't start
implementing. Apply requested edits to the plan file, not to
code.
If the task naturally needs more than 12 steps, split it into
multiple plan files for sequential delivery rather than one big
plan.
保存为 ~/.lingcode/skills/writing-plans/SKILL.md——具体路径和技能发现方式请参见安装技能。