Distilling rules
Rules you keep repeating go into project files, so you do not have to say them again. But that file has to stay lean — otherwise it becomes noise itself.
- 每开一个新会话都要重新交代一遍项目规矩
- 约束文件越写越长,最后它开始不遵守了
- 文件里还留着三个月前的规矩,现在早就不这么做了
What to distill
| 类型 | 例子 |
|---|---|
| 会导致返工的技术规矩 | 权限一律后端校验、金额在后端算、密钥不能进代码 |
| 全站统一的设计约定 | 间距只用这六个值、颜色只用令牌、组件必须实现四态 |
| 明确不做的范围 | 不做团队协作、不做移动端。挡住「顺手补齐」 |
| 协作方式 | 先给方案再写代码、改动前先更新规格文件、做完自检并报告 |
| 项目的入口信息 | 目录结构约定、命令怎么跑、组件放在哪 |
How to write it
- Write imperatives, not descriptions. "Spacing only in multiples of 4" is a constraint; "this project uses a 4px grid system" is an intro. The latter doesn't change its behavior.
- Section by headings, items by short lines. Clear sections let it jump to the relevant part instead of re-reading the whole thing each time.
- Add a "why" only on the critical ones. Knowing the reason lets it apply the rule correctly in edge cases. But only on the few that matter — not on every line.
- Put it at the very front. The start and end of context are best remembered; the middle gets ignored.
How to keep it from bloating
A rules file is not a hard switch; the model follows it probabilistically. The longer it gets, the lower the chance each line is taken seriously — which is why it has to stay thin.
One more practice: after the rules are written, restate the few key ones in the current instruction anyway. The file holds the long-term baseline; the instruction holds the focus for this run. The two are not substitutes.
One level up: skills
Rules govern "what to follow when doing the work." One level above that is "how to do a certain kind of task" — for example, a fixed release process, or the way a walkthrough checklist is run. This kind of content is longer and more process-like; it fits better as a standalone file you call in when needed, rather than something that sits in context every time.
The test is simple: what has to take effect every time goes into the rules; what you only reach for occasionally becomes a callable file. That keeps the rules file thin while the complex processes do not get lost.
