
agents-md-guard
io.github.gamai-io/agents-md-guard
Block silent weakening of AGENTS.md rules and lint agent instruction files over MCP.
Documentation
agents-md-guard
Blocks silent weakening of AGENTS.md / CLAUDE.md / .cursorrules by an agent.
The problem is measured, not hypothetical: GitHub has roughly 719,000 repositories with agent instruction files, and in the 100 most-starred repositories 33 have at least one commit to those files authored or co-authored by an agent (Sharma, 2026). A one-word change - "MUST ask" to "may ask" - rewrites what the agent is allowed to do, and prose diffs rarely get read.
What it does
On every push or pull request it checks:
- which instruction files changed;
- whether the commit carries
Human-Reviewed-By: Name <email>; - whether a line with a normative keyword (
MUST,NEVER,ALWAYS,FORBIDDEN,OBAVEZNO,NIKAD,NE SMIJE...) was removed or rewritten.
Unapproved changes are blocked. Approved ones pass, with the removed rules printed in the log.
Use
# .github/workflows/agents-md.yml
name: agents-md-guard
on: [push, pull_request]
jobs:
guard:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: gamai-io/agents-md-guard@v1
with: { base: origin/main }
Local check before committing:
python3 agents_md_guard.py --staged
MCP server
The same check is available as an MCP tool, so an agent can inspect the rules it is
being given before it acts. Stdlib only, no SDK, JSON-RPC 2.0 over stdio
(protocol 2025-06-18).
pip install agents-md-guard
{
"mcpServers": {
"agents-md-guard": {
"command": "agents-md-guard-mcp"
}
}
}
| tool | input | returns |
|---|---|---|
agents_md_check | {path} or {text}, or {repo, rev/base/staged} for the diff gate | findings: no_rules, weak_rule, negation_conflict, duplicate_rule, long_rule, too_many_rules, unapproved_rule_file, empty_file |
agents_md_rules | {} | guarded file names, normative keywords (EN + BS), the approval trailer, lint codes, exit codes |
agents_md_fix_suggestions | {path} or {text} | one concrete rewrite hint per finding, with the offending line |
agents_md_check is deterministic and offline: a permissive bullet ("you may send mail")
is a weak_rule, two rules over the same action where one is negated is a
negation_conflict (an error, so ok is false), and a file with zero normative
keywords is no_rules.
Tests
python3 -m pytest -q tests builds throw-away git repositories and asserts the
exit codes: an unrelated commit passes, an unapproved weakening is blocked, an
approved one passes and prints the rule it removed, .github/copilot-instructions.md
is guarded, and the forty-zeros event.before of a first push is not a usage error.
What it is not
It does not verify at runtime that the agent obeyed a rule. This is a diff-time gate on the rules themselves; runtime proof of an action is a different artefact (see gamai-io/gama-mandate for signed receipts).
MIT.
agents-md-guardpip install agents-md-guardRelated Servers
io.github.gamai-io/formfill-broker
Isolated browser for form filling: open, snapshot, fill, verify and read OTP, with evidence.
io.github.gamai-io/gama-decision-os
Decide before acting: allow/sandbox/ask/deny verdict with a decision hash, under 5 ms, no LLM call.
io.github.gamai-io/gama-fastpath
0-LLM pre-LLM gate: blocks destructive shell/SQL, answers money math offline.