agentsmdmanages a repository's coding agent instructions. This is done through theAGENTS.mdfile at the repository's root.agentsmdkeeps a repository’sAGENTS.mdaccurate without polluting commits. The CLI installs Git-local automation, regenerates the file from developer preferences, and offers diagnostics so contributors can trust the tooling.- Automation must remain developer-local: only
.gitinternals change, while trackedAGENTS.mdfiles stay untouched unless a developer deliberately publishes. - The
agentsmdcommands we want to support:- setup (
enable) - teardown (
disable) - diagnostics (
status) - regeneration (
make)
- setup (
- Setup the Git-local automation for management of the
AGENTS.mdfile, specifically:- Support the generation of
AGENTS.mdfile with templates & preferences as defined inagentsmd make. - Ignore changes to the local
AGENTS.mdfile. - On changes to the tracked
AGENTS.mdbase file (pulls/merges/checkouts etc.) regenerate the file as defined inagentsmd make. - Backup any conflicting existing Git configuration before overwriting it, and support restoration with
agentsmd disable.
- Support the generation of
- Idempotent: repeated runs refresh assets without duplication and respect previous backups.
- Removes all automation introduced by
enableand restores the original state of the Git configuration. - Restore
AGENTS.mdto the canonical tracked state. - Safe when run without prior
agentsmd enable.
- Evaluates the state of the Git-local automation that
agentsmd enablesets up. - When enabled, prints a succint message
Status: ENABLED. - When disabled entirely or a configuration component is missing
Status: DISABLEDand lists missing/mismatched components.
-h,--help: Show top-level usage, including global options and available commands.--version: Print the CLI's version.
- Generates the
AGENTS.mdfile at the repository root with templates & preferences (detailed below). - Every file generation starts from the canonical
AGENTS.mdfile at the Git HEAD of the repository. - Idempotent & deterministic: regeneration results in the same deterministic output.
- Read developer preferences from
.agentsmdat the repository root, and append to the baseAGENTS.mdfile:- Missing
.agentsmdfile: warn once and skip append. - Empty or whitespace-only file: log notice, no append.
- Non-empty file: append content (respect templating as detailed below) and ensure:
- a single blank line between existing content and the appended content.
- a trailing newline at the end of the appended content.
- Missing
- Supports inline template tokens inside the base
AGENTS.mdand.agentsmd:- Recognise
{{ name }}patterns and replace them with the contents of the first template file discovered in~/.agentsmd/templates/<name>. - Attempt to load both
<name>and<name>.md, preferring whichever exists first. This keeps.mdoptional while encouraging Markdown naming for editor tooling. - Missing templates emit a warning and leave the token untouched so developers can fix their library without losing context.
- Recognise
- Developer executes
agentsmd enablefrom the repo root. - CLI installs config and performs an initial
agentsmd makerender. git statusremains clean becauseAGENTS.mdis marked assume-unchanged.
- Developers edit
.agentsmdas needed. - Run
agentsmd maketo refresh the local file. Automation also re-renders after merges or checkouts. - Local edits stay unstaged.
statuscan confirm everything is healthy and highlight missing setup pieces.
- Run
agentsmd disableto restore previous Git setup and revertAGENTS.mdto canonical tracked state. - Re-run
agentsmd enableto reinstall config at any time.
- All commands must run only inside a Git repository, fail with
fatal: not a git repositoryotherwise. AGENTS.mdnot tracked →statusmarks assume-unchanged as missing;enablewarns when unable to mark the flag.- HEAD missing or file untracked →
makefalls back to the working-tree file as the base before reapplying preferences. - Read-only destinations →
makefails with a clear error before overwriting.
- Portability: All scripts are Bash-compatible on macOS and Linux. Python 3 scripts may be used for file modification/templating operations.
- Safety: Automation never modifies tracked repository files besides the managed
AGENTS.md; all other changes stay inside.git. - Testability: Bats coverage for enable/disable/status/make flows, idempotency, repository enforcement, and regeneration behaviour.
- Resilience: Setup tolerates repeated runs and restores user state during disable, even when names collide with existing hooks or aliases.
- CLI command implementations under
lib/agentsmd/commands/(enable.sh,disable.sh,status.sh,make.sh) wired throughbin/agentsmd. - Git asset scripts and templates under
share/agentsmd/git/. - Automated tests (
tests/specs/*.bats) covering product requirements. - README highlights the core value proposition and stays in sync with the supported command surface.