Maintain AGENTS.md from repository evidence
Overview
Create or improve agent instructions that help a coding agent change the
repository correctly without rediscovering its workflow. Base every
repository-specific command, path, and rule on evidence in the current
checkout.
Prefer a focused diff over a wholesale rewrite. There is no universal line
limit, required section list, symlink layout, or commit-attribution policy;
follow the repository's own needs and maintainer intent.
When to Use
- The user asks to create, update, shorten, or audit
AGENTS.md.
- A monorepo needs root instructions plus narrower package-level overrides.
- Existing agent instructions contain stale commands, duplicated policy, or
unsupported claims.
- The user wants to reconcile
AGENTS.md with CLAUDE.md,
.github/copilot-instructions.md, or other repository instruction files.
Use @agents-generator instead when the task specifically calls for its
packaged generation modes, assets, or backup workflow. Use this skill when a
maintainer-readable, evidence-first edit is the primary goal.
How It Works
1. Preserve existing intent
Before writing, read every instruction file that applies to the target path,
including existing AGENTS.md files and relevant tool-specific files such as
CLAUDE.md, GEMINI.md, .github/copilot-instructions.md, and
.github/instructions/*.instructions.md.
- Improve an existing
AGENTS.md in place when possible.
- Preserve accurate maintainer-authored rules and repository-specific policy.
- Do not replace another tool's instruction file with a symlink unless the
user requests it and repository evidence shows identical content is desired.
- Do not silently choose between conflicting instructions. Follow the
higher-priority applicable rule, or ask when the intended policy cannot be
established from the repository.
2. Build a bounded evidence map
Inspect only enough of the repository to establish how work is actually done:
- Read the project overview and contribution guidance, such as
README*,
CONTRIBUTING*, and relevant docs.
- Read manifests, lockfiles, workspace files, task runners, and build config
to identify supported tools and exact commands.
- Read CI workflows to learn required checks. Do not assume every CI or
deployment job is safe or appropriate to run locally.
- Inspect representative source and test files for naming, layout, and test
conventions.
- Identify generated files, migrations, vendored code, large fixtures,
secrets boundaries, and production-only operations.
Prefer rg --files and rg for discovery when available. Track the source of
each non-obvious command or rule so unsupported claims do not enter the final
file.
3. Choose the instruction scope
Use the root AGENTS.md for repository-wide guidance. Add or revise a nested
AGENTS.md only when a subtree has materially different commands,
architecture, conventions, or safety boundaries.
Keep shared rules at the root and only differences in nested files. For tools
that implement the public AGENTS.md convention, the nearest file in the
directory tree controls the working subtree. Do not copy the full root file
into every package.
4. Write high-signal guidance
Choose headings that fit the repository instead of forcing a fixed template.
Include the following only when supported by evidence:
- Repository map: the few directories and boundaries an agent must know.
- Setup and commands: exact install, development, build, lint, type-check,
and test commands, with the working directory when it is not obvious.
- Focused validation: targeted checks for a small change and broader checks
required before handoff.
- Change rules: generated-file ownership, migrations, schemas, APIs,
dependencies, and cross-package coordination.
- Safety boundaries: secrets, production data, destructive commands,
deployments, and operations that require explicit authorization.
- Contribution rules: repository-specific naming, formatting, commit, or
pull-request requirements that affect implementation or handoff.
Write direct, testable statements. Prefer:
- From the repository root, run `npm test -- path/to/file.test.ts` for a focused test.
over:
- Make sure tests pass and follow best practices.
Link to maintained documentation instead of copying it. Distinguish required
checks from optional, slow, privileged, or deployment-only checks.
5. Validate before handoff
- Re-read each changed
AGENTS.md completely.
- Remove contradictions, duplicate rules, placeholders, and stale claims.
- Confirm every mentioned file and directory exists.
- Cross-check commands against manifests or CI, and run safe, proportionate
checks when useful.
- If nested files changed, confirm each contains only subtree-specific rules
and does not conflict accidentally with the root.
- Review the diff as a maintainer: every added line should change an agent's
decision or prevent a realistic mistake.
Report the files changed, evidence used, checks actually run, and unresolved
uncertainty. Never say a command was tested when it was only read from config.
Examples
Create a focused root file
Evidence found:
package-lock.json selects npm.
package.json defines lint, typecheck, and test scripts.
- CI runs those three checks from the repository root.
src/generated/ is produced by npm run generate.
A useful result might include:
# Agent instructions
## Commands
- Run commands from the repository root.
- Install with `npm ci`.
- For handoff, run `npm run lint`, `npm run typecheck`, and `npm test`.
## Generated code
- Do not edit `src/generated/` directly; update its source and run `npm run generate`.
Do not add a package manager, command, or generated-file rule that the evidence
did not establish.
Revise without erasing policy
If an existing file has accurate release restrictions but a stale test
command, change only the stale command and any directly affected explanation.
Preserve the release restrictions, even when a shorter replacement would look
cleaner.
Best Practices
- Keep instructions concise enough to scan, but let repository complexity
determine length.
- Prefer repository-specific decisions over generic engineering advice.
- Include targeted commands when the project supports them; do not invent a
file-scoped invocation for a tool that only supports suite-level runs.
- State where commands run and whether they modify files.
- Reference formatter and linter config instead of restating every rule.
- Make tool-specific files additive when their semantics differ; do not assume
all agents interpret formats or precedence identically.
Security & Safety Notes
- Treat this as a state-changing skill because it may edit repository files.
Review the diff before handoff.
- Never include secrets, credentials, internal URLs, personal data, or local
environment values in agent instructions.
- Do not run deployment, publication, database mutation, history rewrite, or
other consequential commands merely to validate documentation.
- Preserve approval gates already present in repository policy.
- Do not upload private repository instructions to third-party services. Ask
for explicit consent before transmitting any repository content externally.
Common Pitfalls
- Guessing commands: infer tools from manifests and CI, not popularity.
- Forcing one layout: a symlink or a fixed section list may erase
tool-specific or maintainer-authored guidance.
- Overwriting an existing file: make the smallest evidence-backed change.
- Copying the README: include only information that changes agent behavior.
- Duplicating nested files: keep shared guidance at the root and local
differences near the relevant code.
- Claiming validation that did not run: distinguish inspection from
execution in the handoff.
Limitations
- Repository evidence can be incomplete or contradictory; ask when a material
policy choice cannot be resolved safely.
- A documented command may still require credentials, services, or operating
system support that are unavailable locally.
- AGENTS.md support and precedence vary across coding tools; verify the target
tool when interoperability matters.
- This skill improves instruction quality but cannot prove that every future
agent will follow the file correctly.
Related Skills and Tools
@agents-generator - packaged generation, dry-run, update, and backup modes.
@folder-specific-claude-and-agents-md - deeper guidance for scoped
Claude/AGENTS instruction layouts.
- agents.md - public format and scope guidance.
1---2name: agents-md3description: Create, revise, or audit AGENTS.md files from repository evidence, verified commands, and correctly scoped instructions without overwriting maintainer intent.4---56# Maintain AGENTS.md from repository evidence78## Overview910Create or improve agent instructions that help a coding agent change the11repository correctly without rediscovering its workflow. Base every12repository-specific command, path, and rule on evidence in the current13checkout.1415Prefer a focused diff over a wholesale rewrite. There is no universal line16limit, required section list, symlink layout, or commit-attribution policy;17follow the repository's own needs and maintainer intent.1819## When to Use2021- The user asks to create, update, shorten, or audit `AGENTS.md`.22- A monorepo needs root instructions plus narrower package-level overrides.23- Existing agent instructions contain stale commands, duplicated policy, or24 unsupported claims.25- The user wants to reconcile `AGENTS.md` with `CLAUDE.md`,26 `.github/copilot-instructions.md`, or other repository instruction files.2728Use `@agents-generator` instead when the task specifically calls for its29packaged generation modes, assets, or backup workflow. Use this skill when a30maintainer-readable, evidence-first edit is the primary goal.3132## How It Works3334### 1. Preserve existing intent3536Before writing, read every instruction file that applies to the target path,37including existing `AGENTS.md` files and relevant tool-specific files such as38`CLAUDE.md`, `GEMINI.md`, `.github/copilot-instructions.md`, and39`.github/instructions/*.instructions.md`.4041- Improve an existing `AGENTS.md` in place when possible.42- Preserve accurate maintainer-authored rules and repository-specific policy.43- Do not replace another tool's instruction file with a symlink unless the44 user requests it and repository evidence shows identical content is desired.45- Do not silently choose between conflicting instructions. Follow the46 higher-priority applicable rule, or ask when the intended policy cannot be47 established from the repository.4849### 2. Build a bounded evidence map5051Inspect only enough of the repository to establish how work is actually done:52531. Read the project overview and contribution guidance, such as `README*`,54 `CONTRIBUTING*`, and relevant docs.552. Read manifests, lockfiles, workspace files, task runners, and build config56 to identify supported tools and exact commands.573. Read CI workflows to learn required checks. Do not assume every CI or58 deployment job is safe or appropriate to run locally.594. Inspect representative source and test files for naming, layout, and test60 conventions.615. Identify generated files, migrations, vendored code, large fixtures,62 secrets boundaries, and production-only operations.6364Prefer `rg --files` and `rg` for discovery when available. Track the source of65each non-obvious command or rule so unsupported claims do not enter the final66file.6768### 3. Choose the instruction scope6970Use the root `AGENTS.md` for repository-wide guidance. Add or revise a nested71`AGENTS.md` only when a subtree has materially different commands,72architecture, conventions, or safety boundaries.7374Keep shared rules at the root and only differences in nested files. For tools75that implement the public AGENTS.md convention, the nearest file in the76directory tree controls the working subtree. Do not copy the full root file77into every package.7879### 4. Write high-signal guidance8081Choose headings that fit the repository instead of forcing a fixed template.82Include the following only when supported by evidence:8384- **Repository map:** the few directories and boundaries an agent must know.85- **Setup and commands:** exact install, development, build, lint, type-check,86 and test commands, with the working directory when it is not obvious.87- **Focused validation:** targeted checks for a small change and broader checks88 required before handoff.89- **Change rules:** generated-file ownership, migrations, schemas, APIs,90 dependencies, and cross-package coordination.91- **Safety boundaries:** secrets, production data, destructive commands,92 deployments, and operations that require explicit authorization.93- **Contribution rules:** repository-specific naming, formatting, commit, or94 pull-request requirements that affect implementation or handoff.9596Write direct, testable statements. Prefer:9798```markdown99- From the repository root, run `npm test -- path/to/file.test.ts` for a focused test.100```101102over:103104```markdown105- Make sure tests pass and follow best practices.106```107108Link to maintained documentation instead of copying it. Distinguish required109checks from optional, slow, privileged, or deployment-only checks.110111### 5. Validate before handoff1121131. Re-read each changed `AGENTS.md` completely.1142. Remove contradictions, duplicate rules, placeholders, and stale claims.1153. Confirm every mentioned file and directory exists.1164. Cross-check commands against manifests or CI, and run safe, proportionate117 checks when useful.1185. If nested files changed, confirm each contains only subtree-specific rules119 and does not conflict accidentally with the root.1206. Review the diff as a maintainer: every added line should change an agent's121 decision or prevent a realistic mistake.122123Report the files changed, evidence used, checks actually run, and unresolved124uncertainty. Never say a command was tested when it was only read from config.125126## Examples127128### Create a focused root file129130Evidence found:131132- `package-lock.json` selects npm.133- `package.json` defines `lint`, `typecheck`, and `test` scripts.134- CI runs those three checks from the repository root.135- `src/generated/` is produced by `npm run generate`.136137A useful result might include:138139```markdown140# Agent instructions141142## Commands143- Run commands from the repository root.144- Install with `npm ci`.145- For handoff, run `npm run lint`, `npm run typecheck`, and `npm test`.146147## Generated code148- Do not edit `src/generated/` directly; update its source and run `npm run generate`.149```150151Do not add a package manager, command, or generated-file rule that the evidence152did not establish.153154### Revise without erasing policy155156If an existing file has accurate release restrictions but a stale test157command, change only the stale command and any directly affected explanation.158Preserve the release restrictions, even when a shorter replacement would look159cleaner.160161## Best Practices162163- Keep instructions concise enough to scan, but let repository complexity164 determine length.165- Prefer repository-specific decisions over generic engineering advice.166- Include targeted commands when the project supports them; do not invent a167 file-scoped invocation for a tool that only supports suite-level runs.168- State where commands run and whether they modify files.169- Reference formatter and linter config instead of restating every rule.170- Make tool-specific files additive when their semantics differ; do not assume171 all agents interpret formats or precedence identically.172173## Security & Safety Notes174175- Treat this as a state-changing skill because it may edit repository files.176 Review the diff before handoff.177- Never include secrets, credentials, internal URLs, personal data, or local178 environment values in agent instructions.179- Do not run deployment, publication, database mutation, history rewrite, or180 other consequential commands merely to validate documentation.181- Preserve approval gates already present in repository policy.182- Do not upload private repository instructions to third-party services. Ask183 for explicit consent before transmitting any repository content externally.184185## Common Pitfalls186187- **Guessing commands:** infer tools from manifests and CI, not popularity.188- **Forcing one layout:** a symlink or a fixed section list may erase189 tool-specific or maintainer-authored guidance.190- **Overwriting an existing file:** make the smallest evidence-backed change.191- **Copying the README:** include only information that changes agent behavior.192- **Duplicating nested files:** keep shared guidance at the root and local193 differences near the relevant code.194- **Claiming validation that did not run:** distinguish inspection from195 execution in the handoff.196197## Limitations198199- Repository evidence can be incomplete or contradictory; ask when a material200 policy choice cannot be resolved safely.201- A documented command may still require credentials, services, or operating202 system support that are unavailable locally.203- AGENTS.md support and precedence vary across coding tools; verify the target204 tool when interoperability matters.205- This skill improves instruction quality but cannot prove that every future206 agent will follow the file correctly.207208## Related Skills and Tools209210- `@agents-generator` - packaged generation, dry-run, update, and backup modes.211- `@folder-specific-claude-and-agents-md` - deeper guidance for scoped212 Claude/AGENTS instruction layouts.213- [agents.md](https://agents.md/) - public format and scope guidance.