做产品 PMaker
空格的键盘
直接要代码
你:做一个评论区
AI 直接输出 400 行代码
↳ 没有分页
↳ 没想过没评论时长什么样
↳ 楼中楼要不要?它自己定了
↳ 提交失败草稿会丢
你读完 400 行才发现 → 返工
先要一页规格
你:先别写代码,列规格
AI 输出 20 行清单:
· 数据结构:楼中楼两层
· 排序:按时间倒序
· 空态:邀请首条评论
· 提交失败:保留草稿
· 未定:要不要点赞?
你花 30 秒改两条 → 再写

同一个需求的两种交办方式。差别不在 AI 的能力,在你什么时候介入判断。

Spec Before Code

Ask for code directly and you'll read four hundred lines before realizing it misunderstood. Ask for a one-page spec first and the same error shows up in twenty lines in thirty seconds.

What you'll run into
  • 代码跑起来了,但楼中楼、分页、编辑权限这些它自己替你决定了
  • 改到第三轮,它忘了第一轮的约定,你得把需求重讲一遍
  • 发现不对时只能一处一处说「把这里改成那样」,改完还有同类问题

Before letting the AI write code, have it write in plain language what it intends to do: the data structures, the states on the page, how edge cases are handled, and where it's unsure. You read that page, change a few lines, then let it proceed.

This looks like an extra step, but it saves the most expensive step of all. The AI writing code costs you almost no time, but reading the code, discovering it misunderstood, then describing how to fix it—these three things all drain your attention, and they scale linearly with code volume. A spec is twenty lines; you can scan it in thirty seconds, and catching an error here costs almost nothing.

More importantly, the spec forces out the questions you haven't thought through yourself. The sentence "build a comment section" hides seven or eight decisions: threaded replies or not, editable or not, soft delete or hard delete, visible to logged-out users or not. If you don't say, the AI decides for you—and it usually picks the most common convention, which may not be the one you want.

The other patterns in "Working with AI"—three-part prompts, reference anchoring, distilling constraints—all depend on having this habit first.

The four parts of a spec

All four are essential; the last one is the most valuable.

1 数据 有哪些实体、关键字段、彼此的关系 这块错了,后面全错 2 状态 界面会出现哪几种样子 至少覆盖正常、空、加载、出错 3 边界 超长内容、零条数据、并发修改 权限不足、网络失败 4 未定项 它只能靠猜的地方,逐条列出来问你 这一块决定了要不要返工
The first three are it thinking clearly for you; the fourth is it admitting what it hasn't figured out. A spec without the fourth silently hands the decisions away.

Design considerations

Note for the AI

You can fix this line as the opening sentence every time you start a new module.

PROMPT · first step
我要做:[一句话描述功能]

先不要写任何代码。先给我一份不超过 30 行的规格,包含四部分:

1. 数据:涉及哪些实体、关键字段、彼此的关系。
2. 状态:这个界面会出现哪几种样子,各自什么条件下出现。
   至少覆盖正常、空、加载中、出错。
3. 边界:你能想到的异常情况和你打算怎么处理
   (超长内容、零条数据、权限不足、并发修改、网络失败)。
4. 未定项:我没说清楚、你只能靠猜的地方,逐条列出来问我。
   不要自己替我决定。

用中文,列表形式,不要展开解释。我确认之后再动手写代码。

After confirming, the second line:

PROMPT · first step
规格按以下修改后定稿:
- [你的修改 1]
- [你的修改 2]
- 未定项的答复:[逐条回答]

请把定稿的规格写入 docs/specs/[模块名].md,然后按它实现。
之后我对这个模块提的任何修改,都要先同步更新那份规格文件。

Real Examples

docs/specs/comments.md
## 数据
Comment { id, postId, parentId?, body, author, createdAt }
楼中楼最多两层,parentId 只能指向顶层评论
## 状态
正常 / 空(邀请首条)/ 加载(骨架 3 条)/ 出错(可重试)
## 边界
正文 > 500 字折叠;提交失败保留草稿到 localStorage

Save the final spec as a file in the project and bring it along on every round of changes afterward. Weeks later, this file is also the one thing you'll still be able to understand when you come back.

未定项(AI 主动列出)
1. 未登录用户能看到评论吗?还是要求登录后才可见?
2. 作者能编辑自己的评论吗?有时间限制吗?
3. 删除是软删除(显示"该评论已删除")还是直接消失?
4. 需要点赞或举报吗?

The "undecided" column is the core payoff of this pattern. Any one of those four questions guessed wrong means starting over. Answer them before writing code—five seconds each.