writing-agents-md
Writing Agents MD
Overview
AGENTS.md and CLAUDE.md should be minimal guardrails, not repo handbooks.
Do not assume more global instructions improve outcomes; extra always-on guidance often slows or misdirects work.
Keep only information that is all three:
- hard to discover from the repo itself
- globally relevant across most tasks
- stable enough not to rot quickly
If a detail fails any of those tests, delete it, narrow it, or move it into a skill.
When to Use
- Creating a new
AGENTS.mdorCLAUDE.md - Reviewing, pruning, or rewriting an existing
AGENTS.mdorCLAUDE.md - Removing repo summaries, stale rules, or handbook-style guidance from a global agent file
- Deciding whether guidance belongs in a global rule file or a skill
Workflow
- Identify the target file and whether the task is create, rewrite, or review.
- Analyze the repo for high-value, non-obvious, global constraints.
- If
AGENTS.mdorCLAUDE.mdalready exists, read it only after that analysis as historical input, not as the source of truth. If it conflicts with what the repo shows, trust the repo. - Classify each item as
keep,rewrite,delete,move-to-skill, orstale. - Keep only rules that are non-discoverable, global, and stable.
- Rewrite the file into a short, high-signal document.
- Briefly explain what was removed or marked stale and why, so the file does not bloat again.
Core Filter
Before keeping any line, ask:
- Can the model discover this easily and reliably by reading the repo?
- Does this matter for most tasks, not just some tasks?
- Is this likely to remain true as files, paths, and architecture evolve?
If the answer is yes / no / no, it does not belong in a global rule file.
Even if something is technically discoverable, keep it only when omitting it is likely to cause a costly mistake and the model is unlikely to infer the right choice reliably.
Keep
Good candidates for AGENTS.md or CLAUDE.md:
- non-obvious tool choices like
uv, notpip - environment-specific constraints like WSL path behavior
- expensive landmines like false-positive cache behavior
- legacy areas that still have production imports and must not be removed casually
Keep constraints that redirect the agent away from costly wrong defaults. Be cautious with instructions that add new standing requirements the agent would not otherwise follow.
Delete Or Move Out
Usually remove these from global files:
- package scripts copied from
package.json - directory tours and architecture summaries
- tech stack summaries the repo already makes obvious
- file-path-heavy instructions that will rot quickly
- task-specific workflows, style preferences, or domain guidance
Move workflow or domain guidance into a skill instead of keeping it globally.
Every standing instruction is a potential landmine. Prefer a smaller file over a more prescriptive one.
Guardrails
- Do not generate repo overviews, directory tours, or handbook-style summaries in global agent files.
- Do not repeat information the model can discover from code, docs, or config.
- Do not mention legacy technologies without clearly labeling them as legacy or avoid-using.
- Do not keep broad instructions in the global file if they only matter for some tasks.
- If the repo has little truly global guidance, prefer a very short file over a padded one.
- If unsure whether a line earns its keep, cut it.
Output Shape
Aim for a short file that may include sections like:
- environment or tooling constraints
- important landmines
- minimal routing notes to existing skills
Avoid turning the file into a setup guide, architecture document, or coding standards manual.
If the repo has almost no truly global, non-obvious constraints, a tiny file is acceptable and no file is sometimes acceptable too.
References
- See
references/checklist.mdfor the full keep/delete decision list. - See
references/examples.mdfor bad, better, and good examples. - See
references/principles.mdfor the underlying rationale.
More from shihyuho/skills
lessons-learned
Use when starting, executing, or finishing non-trivial implementation tasks where reusable constraints may matter. Recall relevant lessons before work, capture reusable corrections or discoveries during and after work, and keep project memory in `docs/lessons/`.
101fanfuaji
Use when user requests Chinese terminology conversion, checking, or ensuring terminology - "使用繁體中文", "使用台灣用語", "轉換成台灣用語", "確保都是台灣用語", "統一台灣用語", "改成台灣用語", "用台灣的說法", "簡體轉繁體", "繁體轉簡體", "全部改成繁體", "轉成台灣繁體", check/ensure Taiwan/Hong Kong/China terminology, simplified/traditional conversion, or phonetic transcription (Pinyin/Bopomofo)
60executing-plans-preflight
Use before any implementation start — auto-detects and fixes git state issues (branch, dirty files, remote sync) with one confirmation per fix. Trigger on "start implementation", "implement this plan", "start coding", "execute plan", "開始實作", "執行計劃", or any signal that coding is about to begin.
42agent-install-guide
Use when creating INSTALL.md, setup guides, or configuration instructions intended to be executed by AI agents.
35harvest
Capture project memory from planning-with-files source-of-truth into Obsidian-compatible second-brain notes in docs/notes. Use for milestone summaries, decision capture, and timeline snapshots. Trigger on: harvest, /harvest, harvest this, save this to second brain, save what we just did, document this work, capture this knowledge.
29skill-design
Design and refactor Agent Skills with concise, high-signal instructions and explicit trigger metadata. Use when creating a new skill, revising SKILL.md/README.md structure, or improving skill discoverability and portability.
27