agents-md-writer
Skill2 starsChanged 16 days agoMITView on GitHub
Write, review, or refactor AGENTS.md / CLAUDE.md project instruction files. Use when the user asks to "initialize AGENTS.md", "write project rules", "review my AGENTS.md", "clean up CLAUDE.md", "set up project conventions for the agent", or says 写项目规范 / 初始化 AGENTS.md / 检查 AGENTS.md 是否合规 / 整理项目规范. Ships a section skeleton, writing principles, and a lint script.
- Reads credentials
4 other projects use a version of this.
Adopted by
Most recently taken up by
- jqaisystems/jqai-ai-skillstheir own version, first seen Nov 1, 2026
- cathaysia/skillstheir own version, first seen Oct 23, 2026
- pauloribeiro16/my-skillstheir own version, first seen May 28, 2026
- Cogni-AI-OU/cogni-ai-agent-skillstheir own version, first seen May 19, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- Cogni-AI-OU/cogni-ai-agent-skills★ 4same name
- jqaisystems/jqai-ai-skills★ 3same name
- cathaysia/skills★ 2same name
- pauloribeiro16/my-skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
The file
Show its rules and text
We split this skill into the rules it gives an agent
20 rules. 0 are common, 17 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
17
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Keep it short: redundant instructions consume context and can compete with important constraints.
- Distinctive: line 35
Verify every command or path that survives content selection before including it.
- Distinctive: line 53
Verify every path as you write it, then re-verify the whole file at the end.
- Distinctive: line 54
If you cannot verify a command, do not write it.
- Distinctive: line 65
Delete whole sections that do not apply.
- Very specific: line 69
Run the bundled script by its absolute skill path, not a project-local ./scripts/ path:
- Distinctive: line 77
Run the rest by hand — see Checklist.
- Distinctive: line 88
Read the file, walk the Checklist top to bottom.
- Distinctive: line 89
Verify three things for real:
- Distinctive: line 97
Do not rewrite the file. The user asked for a diagnosis.
- Very specific: line 101
When the user asks about the whole machine or a whole workspace, locate the files through the filesystem index.
- Distinctive: line 136
If yes, omit it. A directory map can also imply that unlisted paths do not matter.
- Distinctive: line 139
Keep a rule when it supplies missing knowledge that changes an action, for example:
- Distinctive: line 158
Use supplied context, existing decision records, or verified history as evidence.
- Distinctive: line 160
Keep short, currently relevant records here.
- Distinctive: line 192
If the root file passes ~200 lines, first check for duplicated code/config information, then move detailed decisions or module-local …
- Distinctive: line 207
Ask whether the rule still holds in a different repo.
- Distinctive: line 219
Keep one source of truth plus thin entry files — never maintain parallel copies.
- Very specific: line 234
Check .gitignore does not already exclude CLAUDE.md or GEMINI.md.
- Distinctive: line 235
If the user only runs one agent, create only that one entry file.
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md Writer
Reply in the user's language. These instructions are in English for token efficiency; that does not dictate the conversation language. If the user writes in Chinese, answer in Chinese — including the review findings and the confirmation prompts.
AGENTS.md is project-level context. Loading and discovery depend on the agent; see the registry. Keep it short: redundant instructions consume context and can compete with important constraints. There is no universal instruction-count or line-count limit that guarantees compliance.
Scope: write only project knowledge that code and configuration do not express: hidden constraints, operational traps, and important decisions with their reasons. Do not reproduce a directory map, script list, dependency versions, or conventions already evident in the repo. Personal preferences belong in the global agent config, not here.
Pick a path
| User intent | Path |
| No AGENTS.md yet, create one | A — Write |
| File exists, check it for problems | B — Review (do not edit) |
| File exists, rewrite / merge / trim | C — Refactor |
Path A — Write
1. Probe. Never guess.
Verify every command or path that survives content selection before including it.
ls -A # repo root
jq '.scripts' package.json 2>/dev/null # npm scripts (no jq? read the file — do not truncate with grep -A)
cat pyproject.toml 2>/dev/null # Python deps and test config
cat Cargo.toml 2>/dev/null # Rust
find . -maxdepth 1 \( -name Makefile -o -name '*.mk' -o -name 'dev-*.sh' \)
git log --format=%s -20 # existing commit stylePowerShell equivalents: Get-ChildItem -Force, (Get-Content package.json | ConvertFrom-Json).scripts.
Do not use shell globs to probe. Under zsh, ls *.mk with no match aborts the whole command
before ls ever runs, and 2>/dev/null cannot suppress it — the error comes from the shell, not
from ls. Use find.
- The project README can be wrong. The filesystem is the source of truth.
- Verify every path as you write it, then re-verify the whole file at the end.
- If you cannot verify a command, do not write it. Mark it as a known gap. Never invent one.
- Discovery is input to your reasoning, not a list to copy into AGENTS.md. Apply Content selection before writing. If nothing qualifies, report that; do not manufacture a file to fill a template.
2. Follow the skeleton
Candidate sections and layering: references/skeleton.md. No section is
mandatory; do not add a section merely because it appears in the template.
Blank templates: templates/AGENTS.md.template (English),
templates/AGENTS.zh.md.template (Chinese).
Delete whole sections that do not apply. Do not leave placeholders behind.
3. Run the checks
Run the bundled script by its absolute skill path, not a project-local ./scripts/ path:
<skill-dir>/scripts/lint-agents-md.sh AGENTS.md
pwsh -File <skill-dir>/scripts/lint-agents-md.ps1 AGENTS.mdThe lint covers mechanical checks only. It does not prove rule compliance or functional correctness. Run the rest by hand — see Checklist.
4. Add entry points for other agents
See Entry points. If no AGENTS.md was needed, do not create entry files pointing to a nonexistent file.
Path B — Review
Read only. Do not edit.
- Read the file, walk the Checklist top to bottom.
- Verify three things for real:
- Commands — run the read-only ones. For anything with side effects, check it is at least
declared (e.g. present in
jq '.scripts' package.json). - Paths —
test -eeach one. - Conflicts — against the global config and any other AGENTS.md in the repo.
- Commands — run the read-only ones. For anything with side effects, check it is at least
declared (e.g. present in
- Report: one-line verdict (fine / needs fixes / rewrite), then a list of
location → problem → suggested fix.
Do not rewrite the file. The user asked for a diagnosis.
Reviewing many files at once
When the user asks about the whole machine or a whole workspace, locate the files through the
filesystem index. Never run an unbounded recursive scan over $HOME.
mdfind -0 -name 'AGENTS.md' | xargs -0 ./scripts/lint-agents-md.sh # macOS, Spotlight index
mdfind -0 -onlyin ~/work 'kMDItemFSName == "AGENTS.md"' | xargs -0 ... # scoped
plocate AGENTS.md # Linux, if indexed
find <dir> -maxdepth 4 -name AGENTS.md # fallback, always scopedReport as a table — path, line count, error/warning counts — then ask which ones to fix. Fix them one at a time, and for each one list the full path and the exact changes before writing anything.
Path C — Refactor
cp AGENTS.md AGENTS.md.bakand tell the user where the backup is.Classify every existing block and show the table before touching anything:
Destination What goes there Keep in project Constraints and traps not expressed by code or config; important decisions Promote to global Personal preferences: language, output style, local machine setup Push down to subdirectory Hidden constraints that only concern one module Move to a skill / decision document Multi-step procedures or detailed Event / Decision / Reason records Delete Duplicated repo information, stale content, freshness stamps, one-off requests - Show the classification and concrete changes. If the user already authorized this scope, proceed; ask only about unresolved choices that change product behavior or discard still-relevant knowledge.
- Re-run the checklist. Preserve important decisions in the structured format below; do not discard their reasons while trimming the original discussion.
Content selection
For each candidate rule, ask: can the agent already learn this from code or configuration? If yes, omit it. A directory map can also imply that unlisted paths do not matter; inspect the repository for the current task instead of making a fixed map in AGENTS.md.
Keep a rule when it supplies missing knowledge that changes an action, for example:
- Integration tests silently skip without a local database; a green run can be incomplete.
- A command documented as local maintenance actually targets a shared environment by default.
- A tempting solution was rejected for a compatibility reason the code cannot reveal.
A command or path may appear as part of explaining such a trap, after verification. Do not add an ordinary command catalogue or directory listing around it. Do not copy generic coding advice.
Important decisions
Record important project decisions as Event / Decision / Reason (事件 / 决策 / 原因 in Chinese):
- **Event**: A request can time out after the payment provider accepts it.
- **Decision**: Do not automatically retry payment creation until idempotency is guaranteed.
- **Reason**: A retry can charge twice; the provider does not deduplicate requests.Use supplied context, existing decision records, or verified history as evidence. Never invent an
incident, a rejected option, or its rationale. Ask about a missing reason when it is material.
Keep short, currently relevant records here; put detailed records in an existing decision-document
location and link them with a reading trigger. Do not preserve every rejected idea. Update or retire
obsolete decisions rather than accumulating contradictions. See
references/rules-and-decisions.md when reviewing decisions or
critical constraints.
Execution mechanisms
For critical constraints, inspect whether tests, lint, CI, or tool permissions actually enforce them. Report the existing mechanism or the gap; AGENTS.md text and a passing document lint are not enforcement. A configured CI check is not proof that merging or releasing is blocked on it. Reuse verified mechanisms. Do not install hooks, create new checks, or change permissions unless that work is authorized. Keep this assessment in the review report; include it in AGENTS.md only when it explains a project-specific trap that the configuration does not reveal.
Writing principles
| Principle | Why |
| Make every instruction verifiable | "Confirm the integration cases ran" identifies evidence; "Test thoroughly" does not. |
| Never let two rules contradict | Conflicting instructions make behavior less predictable; resolve or report the conflict. |
| Keep it as short as it can be | Keep only knowledge missing from code and config. Push module-local constraints down. |
| No YAML frontmatter | AGENTS.md has no frontmatter spec. Loaders inject it as plain markdown, so it lands in context verbatim as noise. |
| No freshness dates or version stamps | Do not duplicate git log or dependency config. A real deadline or incident date may be meaningful; review date warnings in context. |
| No meta-rules ("this file only describes how to...") | Written for the human maintainer. Does not change agent behaviour. Pure budget. |
| Multi-step procedures, module-local content | Move to a skill or a subdirectory AGENTS.md. Keep them out of the root file. |
| Pointers to external docs go last | The top of the file is for the hardest constraints. |
Length
No hard line limit. The test is: can you delete a line without losing information?
If the root file passes ~200 lines, first check for duplicated code/config information, then move detailed decisions or module-local constraints to their appropriate location. This is a review signal, not a target length; a useful file may contain only a few lines.
Verifiable instructions
| Candidate | Treatment |
| Ordinary formatting or coverage advice | Omit it when formatter configuration or tests already express it. |
| Integration tests can report green without a database | Explain that they skip; verify database availability before relying on the run. |
| A vendor-maintained directory must not be edited | Name the verified path and the ownership reason if the repo does not reveal it. |
| Payment creation must not retry | Record Event / Decision / Reason and verify any existing regression check. |
Global vs project
Ask whether the rule still holds in a different repo. Yes → global. No → project.
| Rule | Belongs to | Why |
| "Always answer in Chinese" | Global | Holds anywhere. It is a personal preference. |
"Match the existing commit style in git log" | Global | The method is universal. |
"Commits here use feat(scope): ..." | Omit if evident in history or commit config | Do not repeat discoverable conventions. |
"Never read .env" | Global | Universal safety floor. |
"config/secrets.yml is ops-owned, do not edit" | Project | Names a specific file in this repo. |
Entry points
Keep one source of truth plus thin entry files — never maintain parallel copies.
| Situation | Action |
| Codex, pi, omp, OpenCode, Grok CLI, Kimi Code, OpenClaw, DeepSeek Harness, Hermes, Copilot | Nothing to do. They read AGENTS.md directly. |
| Claude Code | Create CLAUDE.md containing one line: @AGENTS.md |
| Gemini CLI | Create GEMINI.md with prose pointing at AGENTS.md |
| Cursor, Cline, Windsurf | Different formats — do not symlink. See the registry. |
Per-agent paths, evidence levels, format caveats, and how to detect installed agents instead of
hardcoding a list: references/agent-registry.md.
- Do not use symlinks for project-level entry files. Committed symlinks degrade into plain text
files containing a path on Windows and some CI runners. Symlinks are fine for user-level config
(
~/.claude/,~/.codex/). - Check
.gitignoredoes not already excludeCLAUDE.mdorGEMINI.md. - If the user only runs one agent, create only that one entry file.
Checklist
Rows 1–5 are covered by scripts/lint-agents-md.sh / .ps1 as heuristics. Run the rest by hand.
| # | Check | How | Auto |
| 1 | No hardcoded developer-machine paths | /Users/<name>/, /home/<name>/, C:\.... Machine-bound paths (remote hosts, external tool installs) must state which machine and OS. | ✅ |
| 2 | No YAML frontmatter | First line is not --- | ✅ |
| 3 | No redundant freshness stamps | Review date warnings in context; retain meaningful event dates or deadlines. | ✅ |
| 4 | Referenced paths exist | Every backticked path resolves on disk | ✅ |
| 5 | Length is justified | Report line count; flag root files over ~200 lines for push-down | ✅ |
| 6 | Commands actually run | Execute read-only ones. Declared-only for the rest. Mark unverifiable ones as known gaps. | |
| 7 | Cross-platform commands are complete | If the project is developed on multiple OSes, give portable commands or list them per platform and label which is which. | |
| 8 | Referenced tools exist | "Run ESLint" requires an ESLint config in the repo. Otherwise label it a known gap. | |
| 9 | No contradictions | Look for "always X" next to "never X" | |
| 10 | Verification instructions are checkable | Describe the specific evidence needed to resolve a hidden trap. Put prohibitions in hidden constraints. Human-only checks must be labelled; AI must not claim they are done. | |
| 11 | Subdirectory files do not repeat the parent | Diff against the root file; keep only the differences. | |
| 12 | Entry files exist | See Entry points, or confirm they are gitignored. | |
| 13 | Only knowledge absent from code / config | No directory maps, command catalogues, dependency lists, or repeated coding conventions. | |
| 14 | Important decisions retain their context | Event / Decision / Reason, supported by evidence; detailed records have a triggered pointer. | |
| 15 | Critical rules have an enforcement assessment | Report verified tests, lint, CI, permissions, or gaps; do not claim document lint enforces behavior. |
Content that belongs elsewhere
- Runtime prompts or deployment artifacts placed at the repo root as AGENTS.md. The agent will read them as constraints on working in this repo. They are not.
- One-off requests, temporary plans, single-iteration goals. These go in
docs/or an issue.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

