回顧與練習
核心要點
- 一個好的工作空間給 AI 上下文、快速的反饋迴圈和廉價的撤銷——配置才是那個乘數,往往比模型本身更關鍵。
- 上下文檔案(AGENTS.md / CLAUDE.md)是你能寫下的最高槓杆的東西:具體的規則、大聲的禁止事項,以及指向示例的指標。
- 讓版本控制成為本能——小步提交、讀 diff、危險的活兒開分支——這樣 AI 做的任何事都不會真正不可逆。
- 讓迴圈保持緊湊,並讓 agent 自己閉環:編輯、執行、讀失敗、修復。把診斷(、lint、型別檢查)反饋給 AI。
- 用硬性上限和節流器把每一個付費 關起來,把金鑰留在倉庫之外,並用 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.