@adiasg/agentsmd
v0.0.1
Published
CLI helpers for managing AGENTS.md workflows and Git automation.
Downloads
10
Readme
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 }}agentsmd makeThe 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.
