Context Budget
Treat context as a finite budget to allocate. Every piece of irrelevant content you add takes some attention away from the parts that matter.
What you will run into
- 把整个项目丢给它之后,回答反而变含糊了
- 聊得越久,它越容易违反前面定好的规则
- 贴了一大段报错日志,它抓错了重点
What to Give
| 给什么 | 占比 | 说明 |
|---|---|---|
| 项目约束 | 少量 | 精简的规矩,长期有效。放在最前面 |
| 当前模块的规格 | 少量 | 数据结构、状态、边界。这一块最值得占位置 |
| 直接相关的文件 | 中等 | 指名要改的那两三个,加上它们依赖的接口定义 |
| 这一次的指令 | 少量 | 放在最后。关键约束在这里重申一遍 |
| 留白 | 三成左右 | 给它推理和输出用。填满了它就没有余地了 |
What Not to Give
- The entire repo. Letting it rummage through every file looks easy, but actually fills the window with noise. Name the specific files you want changed.
- The full error log. Scan it yourself first, then paste the key lines. Out of a few hundred lines of stack trace, fewer than ten usually matter.
- The entire history of the last topic. Once you finish something, start a new session—don't drag the previous discussion along.
- Large blocks of sample data. Two or three representative rows are enough, including one edge case.
- Things already settled but re-derived over and over. Write them to a file and let it read them—don't have it re-think each time.
A simple self-check: if you yourself aren't sure whether a piece of content is needed this time, it probably shouldn't be given.
When to Clear and Start Over
| 信号 | 该做什么 |
|---|---|
| 开始违反前面定好的规则 | 把关键决定写进文件,然后开新会话 |
| 它开始重复之前说过的话 | 说明有效信息被稀释了,重开 |
| 换了一个不相关的任务 | 直接开新会话,不要接着聊 |
| 连续三轮都没改对 | 停下。多半是描述有问题,重新写清楚再开一轮 |
There's also a structural move: organize the codebase by feature. Making a login-related change only requires reading the auth directory, instead of pulling a few files from each layer — saving a lot of context. This choice costs almost nothing at project start, and is expensive to retrofit later.
