A compact CLI and installable skill bundle for keeping layered
AGENTS.mdrules files current.
agentsmd-hierarchy packages two things together:
- A CLI for validating, normalizing, and pruning rules-only
AGENTS.mdfiles - An installable skill bundle you can drop into Codex, Claude Code, Cursor, or a Codex plugin directory
Large repos still need local editing guidance, but v3 keeps AGENTS.md focused on rules instead of directory inventory. Each AGENTS.md should exist only when a directory has rules that apply to that subtree.
Use comments at the top of individual source files for single-file rules. The CLI expects that pattern, but it does not scan or enforce those comments.
This package helps keep rules files healthy:
- Validate malformed or obsolete
AGENTS.mdfiles - Normalize legacy rules files to the v3 layout
- Prune AGENTS files that no longer contain real Rules
- Install the skill where your agent tooling can actually use it
| Tool | Install Shape |
|---|---|
| Codex | Skill bundle or plugin bundle |
| Claude Code | Skill bundle |
| Cursor | Command file |
If you just want to install it and go:
npx -y agentsmd-hierarchy installThat launches an interactive installer and lets you choose the target tool and scope.
If you prefer deterministic installs:
npx -y agentsmd-hierarchy install --tool codex --scope personal --no-promptIf you want the command available on your PATH:
npm install -g agentsmd-hierarchynpx -y agentsmd-hierarchy install --tool codex --scope personal --no-promptnpx -y agentsmd-hierarchy install --tool claude --scope personal --no-promptnpx -y agentsmd-hierarchy install --tool cursor --scope personal --no-promptRun this from inside a git repo, or pass --project-root.
npx -y agentsmd-hierarchy install --tool codex --scope project --no-promptnpx -y agentsmd-hierarchy install --tool claude --scope project --no-promptnpx -y agentsmd-hierarchy install --tool cursor --scope project --no-promptnpx -y agentsmd-hierarchy install \
--tool codex \
--mode plugin \
--dest ./plugins/agentsmd-hierarchy \
--no-promptOnce installed globally, or via npx, the main workflow looks like this:
agentsmd-hierarchy check .
agentsmd-hierarchy sync .
agentsmd-hierarchy sync src/componentsValidate existing AGENTS.md files without changing them. Directory scopes include existing ancestor AGENTS files plus existing AGENTS files under the target directory. Passing an AGENTS.md file validates only that file.
agentsmd-hierarchy check packages/app
agentsmd-hierarchy check packages/app/AGENTS.mdNormalize existing rules-bearing AGENTS.md files and delete rules-empty files. This command does not create new AGENTS files.
agentsmd-hierarchy sync .
agentsmd-hierarchy sync src/features/paymentsInstall the packaged skill bundle into a supported tool.
agentsmd-hierarchy install --tool codex --scope project --no-promptHelpful flags:
--debugfor structured troubleshooting output--dry-runto preview install changes--jsonto emit install summaries as JSON--forceto replace unmanaged install destinations
The accepted file format is intentionally small:
# path/to/directory
## Rules
- Keep directory-level guidance here.Rules must be a non-empty bullet list. Inventory sections such as ## Directories, ## Files, ## Generated Files, and ## Ignore Files and Directories are obsolete in v3 and fail validation.
Depending on the target, this package installs:
- A full skill bundle under
.codex/skills/agentsmd-hierarchy/ - A full skill bundle under
.claude/skills/agentsmd-hierarchy/ - A Cursor command file under
.cursor/commands/agentsmd-hierarchy.md - A Codex plugin bundle at the destination you choose
The shipped skill teaches agents to:
- Read the
AGENTS.mdrules chain from repo root to target path - Treat
AGENTS.mdfiles as directory-level Rules only - Put single-file rules in comments at the top of the relevant source file
- Use bundled helpers to validate, normalize, and prune rules files deterministically
This repo ships the published package contents and the tests that back them.
npm install
npm testThe published npm package includes:
bin/for the executable entrypointagentsmd-hierarchy/for the distributable skill bundle and helper scripts
This repo uses Changesets for versioning and npm publishing.
Release steps:
- Run
npm run changesetfor each user-facing change and commit the resulting file under.changeset/. - Merge those changesets to
main. - In GitHub, open
Actionsand run theReleaseworkflow manually. - Wait for the workflow to open or update the release PR with the version bump and changelog changes.
- Review and merge that release PR into
main. - In GitHub, run the
Releaseworkflow manually again frommain. - Wait for the workflow to publish the package to npm.
During publish, the workflow also creates the matching GitHub tag and GitHub Release automatically, so npm releases and GitHub releases stay aligned.
- Node.js
>=20
Contribution PRs are welcome.
For user-facing changes, please include a Changeset by running npm run changeset and committing the generated file under .changeset/ alongside your update.
MIT