Templates and preferences for your AGENTS.md instructions.
npm install -g @adiasg/agentsmd ยท npx @adiasg/agentsmd <command>
agentsmd adds templating and local
.agentsmdpreferences toAGENTS.mdwhile keeping the tracked source clean.
Features
- ๐งพ Extend AGENTS.md โ
agentsmd makeregeneratesAGENTS.mdwith templates and appends local.agentsmdpreferences onto the committed snapshot. - ๐งฉ Reusable Templates โ Place
{{ name }}tokens inAGENTS.mdor.agentsmdto pull snippets from~/.agentsmd/templates/<name>[.md], sharing guidance across projects. - ๐ Automate the Refresh โ
agentsmd enablehooks Git soAGENTS.mdregenerates on pulls/checkouts and silently ignores your local rendered copy;agentsmd disablerolls back the Git hooks. - ๐งฐ Local Install Only โ Everything the CLI writes stays in your working tree โ no global state or remote services required.
๐ Quick Tour
# 1. Install npm install -g @adiasg/agentsmd # 2. Drop reusable templates into your home library mkdir -p ~/.agentsmd/templates echo "Never run npm run dev yourself." > ~/.agentsmd/templates/nextjs.md # Refer to this template in AGENTS.md or .agentsmd with {{ nextjs }} echo "{{ nextjs }}" > .agentsmd # 3. Place your personal overlay (kept local) echo "Don't hardcode constants - instead place them in a constants.ts file." >> .agentsmd # 4. Render templates and append .agentsmd to AGENTS.md agentsmd make # 5. (Optional) Git automation for regeneration & ignoring file agentsmd enable agentsmd status agentsmd disable
๐งฉ Templating Quick Start
Keep the shared AGENTS.md focused on repository guidelines while layering your personal preferences in .agentsmd. Anywhere you place {{ name }} inside the file, agentsmd make will inline content from your home template library at ~/.agentsmd/templates/<name>.
For each location the lookup checks both <name> and <name>.md, so you can opt in to the Markdown suffix without breaking existing snippets.
Note: Rendering templates requires Python 3 to be available as python3 or python.
Example:
### ~/.agentsmd/templates/nextjs.md - Never run `npm run dev`.
### .agentsmd ### Developer Preferences - Use orange hues for the accent colors. {{ nextjs }}
The resulting AGENTS.md:
<Orignial AGENTS.md contents> ### Developer Preferences - Use orange hues for the accent colors. - Never run `npm run dev`.
๐งฐ CLI Reference
| Command | What it does |
|---|---|
agentsmd make |
Rebuilds AGENTS.md from the last committed version plus your .agentsmd preferences and templates. |
agentsmd enable |
Enables local Git automation for regenerating file on pull/checkout. Installs hooks, merge driver, git rebuild-agents alias, and marks AGENTS.md assume-unchanged. |
agentsmd disable |
Removes all installed local Git automation, restores backed up hooks/config. |
agentsmd status |
Prints installation status. |
agentsmd --version |
Shows the version. |
Run agentsmd help <command> for detailed usage text.
๐งฑ What agentsmd enable Installs
- Hooks โ Managed
pre-commit,post-merge, andpost-checkoutscripts that callagentsmd makewhen appropriate. Original hooks are saved as<hook>.agentsmd.bak. - Merge driver โ Adds
merge=agentsmdto.git/info/attributesso merge conflicts prefer the remoteAGENTS.md. - Git alias โ
git rebuild-agentspoints back to the CLI for quick rebuilds. - Assume unchanged โ
AGENTS.mdis kept out ofgit statusnoise but remains editable locally. - State directory โ
.git/agentsmd-state/tracks backups and ownership markers, enabling clean disable flows.
Disable removes each artifact and puts your repo back exactly as it was.
๐ Contributing
We welcome pull requests! Before opening one:
- Ensure new behaviour is covered by tests where practical.
- Run
npm run lintandnpm run test. - Update documentation (
README.md,docs/PRD.md, and relevant assets) to match your changes.
.devcontainer/ has an environment with the required tooling (Node LTS, shellcheck, shfmt, bats).
โ Troubleshooting
- "fatal: not a git repository" โ Run commands inside a clone; automation never touches directories without
.git. AGENTS.mdstill showing in git status โ Ensure the file is tracked; otherwisegit update-index --assume-unchangedcannot be set.- HEAD missing or
AGENTS.mduntracked โagentsmd makefalls back to the working-treeAGENTS.mdat the repo root before reapplying preferences. Status: DISABLEDwith missing components โ Runagentsmd enableto reinstall; it is safe to re-run and will restore missing pieces.- Missing template referenced โ The token is left as
{{ name }}and a warning is printed; fix files in~/.agentsmd/templates/.
๐ License
MIT License. See LICENSE.