回顾与练习
核心要点
- 一个好的工作空间给 AI 上下文、快速的反馈循环和廉价的撤销——配置才是那个乘数,往往比模型本身更关键。
- 上下文文件(AGENTS.md / CLAUDE.md)是你能写下的最高杠杆的东西:具体的规则、大声的禁止事项,以及指向示例的指针。
- 让版本控制成为本能——小步提交、读 diff、危险的活儿开分支——这样 AI 做的任何事都不会真正不可逆。
- 让循环保持紧凑,并让 agent 自己闭环:编辑、运行、读失败、修复。把诊断(LSP、lint、类型检查)反馈给 AI。
- 用硬性上限和节流器把每一个付费 API 关起来,把密钥留在仓库之外,并用 harness 让安全检查成为 AI 跳不过去的东西。
动手试试
打开你正在做的项目(或脚手架一个空的),亲手写一份 AGENTS.md 初稿:这个项目是什么、技术栈、运行 dev/test/lint 的确切命令、三条真实的约定,以及至少两条大声的禁止事项(例如"绝不读取或打印 .env""不先打招呼不要加依赖")。然后让你的 AI 工具做一个微不足道的改动,看它是否尊重这份文件。每当它做了你不想要的事,就加一行或把一行写得更锋利。你在调的是房间,而不只是代码。
本章提示词
Read my project and help me write a concise AGENTS.md context file for it.
First, inspect the repo and tell me:
- the tech stack and versions you detect
- the commands for install / dev / test / lint / build
- the layout and where the entry point is
Then draft an AGENTS.md with these sections: What this is, Tech stack,
Commands, Conventions, and Don'ts. Be specific and concrete (name the
exact libraries and rules, not "follow our conventions"). State the don'ts
as loudly as the do's, and point to one existing file as a style example.
Keep it under ~40 lines — I'll prune from there.