The main problem is that the important rules are hard to spot among filler. Here's a rewrite:
# Project Guidelines
Next.js 15 (App Router) + TypeScript, managed with **pnpm**. Scripts are in `package.json`.
## Rules
- Run every package and script command through `pnpm` (`pnpm add`, `pnpm dlx`, `pnpm <script>`). The lockfile is `pnpm-lock.yaml`, and running another package manager corrupts it.
- Use precise types everywhere. For data whose shape you don't know yet, use `unknown` and narrow it with type guards or a schema. Never use `any`.
- Keep React components presentational. Put business logic in <!-- TODO: e.g. `src/lib/` or `src/server/` --> and call it from the component.
- Style with Tailwind utility classes only.
## Database (Prisma + PostgreSQL)
After any edit to `prisma/schema.prisma`, run both commands, in this order:
1. `pnpm prisma migrate dev --name <descriptive_name>`
2. `pnpm prisma generate`
If you skip step 2, the generated types go stale and the build fails in ways that are hard to trace back.
## Testing
Vitest. Put each test next to its source file as `<name>.test.ts`.
## Done means
You're finished only when both commands pass with zero errors on your final change:
- `pnpm lint`
- `pnpm test`
What I changed and why:
- Cut lines that don't change behavior. "Be careful and thorough" and "write good code that follows best practices" are things the agent already tries to do. They make the file longer and draw attention away from the rules that matter.
- Gave each rule one home. "Run tests" appeared twice and "use pnpm" was said twice in one bullet. When an instruction is repeated, it's hard to tell how important it is compared with the rest. Lint and test now live in a single Done means section at the end, where the agent checks whether it's finished.
- Said what to do, not just what to avoid. Rules like "Don't use npm or yarn", "Never use
any", and "Don't write CSS / inline / styled-components" put the banned thing front and center. Each rule now names what to use instead (pnpm,unknown+ narrowing, Tailwind classes). I kept "Never useany" as a hard limit, paired with the alternative. - Added the reasons agents can't figure out on their own. The lockfile damage and the stale Prisma types are why those rules exist. A rule that comes with its reason is less likely to be dropped as optional.
- Turned the Prisma steps into a numbered list instead of a paragraph ending in "Don't forget!!".
- Made "finished" checkable. "Run lint and test" became "both pass with zero errors". Before, an agent could run the tests, see failures, and still stop.
One thing for you to fill in: "Don't put business logic in components" probably gets ignored because the agent doesn't know where that logic should go. Replace the TODO with your real directory, such as src/lib/ or server actions in app/**/actions.ts.
Optional: if agents still use npm or skip lint, put it in a hook instead of the doc. A PreToolUse hook can block npm/yarn commands, and a Stop hook can run pnpm lint && pnpm test. I can set either one up with /update-config if you want.
Real run recorded with claude-code / claude-opus-5-5. Output is shown verbatim, unmodified.
它做什麼
一份關於如何撰寫任何「給代理讀的文件」的指南。出發點是:同樣的幾個槓桿,就能讓 skill、CLAUDE.md 或被連結的文件變得可預測,因為代理每次執行都應該走同樣的流程。
運作方式
- 上下文指標: skill 的描述、AGENTS.md 裡的一行字,其措辭決定了代理何時、多可靠地去讀它背後的內容。
- 兩種成本: 每新增一項,要不佔用上下文(始終載入的文字),要不佔用人的注意力(記得有哪些文件)。
- 資訊層級: 步驟放主檔案,參考資料放到指標後面,避免文件臃腫。
- 完成標準: 每一步以可檢查的條件結束,避免代理提前收工。
- 精簡: 每個意思只寫在一處,刪掉模型本來就會遵守的句子,用「要做什麼」取代「禁止什麼」。
- 另一份檔案談 skill 特有的取捨:frontmatter、僅使用者可呼叫與模型可呼叫、路由類 skill。
適合情境
撰寫或精簡 skill、CLAUDE.md、AGENTS.md。
需要了解
我們試用時,它改寫了一份範例 CLAUDE.md,逐項說明改動,並留下一個 TODO,而不是替你編一個目錄名稱。
純指令檔:沒有腳本、不連網。 當你要求它修改某個檔案時,代理可能會寫入你專案中的該檔案。 壓縮檔中另附原始儲存庫的 MIT 授權檔 LICENSE 與 agents/openai.yaml(供 Codex 使用的顯示名稱)。