CLAUDE.md、AGENTS.md 與 Cursor rules:應該編寫哪個指令檔?
CLAUDE.md, AGENTS.md or Cursor rules: which file should you write?
文章建議同時使用多種編碼智能體時,把共用規則放在 AGENTS.md,讓 CLAUDE.md 以 @AGENTS.md 引入,並只在 Cursor rules 中設定特定檔案適用的規則。Codex 預設在 AGENTS.md 合併大小達 32 KiB 後停止加入更多檔案,文章指出低於 8 KiB 較佳;Claude Code 的 CLAUDE.md 則以少於 200 行為常見目標。
Each coding agent reads a different instruction file. If you use more than one agent, you can end up with three files that say the same thing. That costs tokens and drifts out of date. Here is a simple way to keep it tidy.
Who reads what
| File | Read by | When it loads |
|---|---|---|
CLAUDE.md |
Claude Code | Every session |
AGENTS.md |
Codex, Cursor and other tools | Every task. Codex starts at the project root and walks down to your folder, with at most one file per folder |
Cursor rules (.cursor/rules) |
Cursor | Always on, or only when the rule's globs or description match |
Setting names and limits change between versions, so check the docs for the version you run. We last checked the Codex docs on Nov 25, 2026: developers.openai.com/codex.
A simple setup for more than one tool
- Put the real rules in
AGENTS.md. - Make
CLAUDE.mdone line that imports it:@AGENTS.md. - Use Cursor rules only for things that apply to certain files, with
globs. - Put folder rules in a nested
AGENTS.mdinside that folder (for examplesrc/ui/AGENTS.md), so they load only when work happens there.
How long should they be
- Codex stops adding AGENTS.md files once the combined size reaches 32 KiB by default. Under 8 KiB is better.
- For Claude Code, keep
CLAUDE.mdshort. A common target is under 200 lines. Move long workflows into skills. - Short files are cheaper and more likely to be read in full.
What to put in them
- The commands to build, test and run the project.
- Rules that are not obvious from the code: naming, folders that are off limits, how to write a commit.
- Things that went wrong before, written as one plain line each.
Leave out old meeting notes, long style essays, and anything the agent can see by reading the code.
Free and paid help
-
Agent Cost Saver (free, also on Gumroad) has
cost_audit.py. It flags a CLAUDE.md and AGENTS.md that repeat the same text, oversize files and always-on rules. - AGENTS.md Starter Pack has short copy-paste AGENTS.md files for common project types.
Related guides
Made by Tidy Byte Tools.
Originally published at https://tidybytetools.github.io/guides/claude-md-vs-agents-md-vs-cursor-rules/. Tools by Tidy Byte Tools.
來源:DEV Community · dev.to