Skip to main content

agents-md-guard

license: MIT

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:

  1. which instruction files changed;
  2. whether the commit carries Human-Reviewed-By: Name <email>;
  3. 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.

Metadata

Release files for agents-md-guard 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agents-md-guard 0.1.0
File Size Uploaded Provenance Actions
agents_md_guard-0.1.0.tar.gz 14.1 kB Without provenance Details for agents_md_guard-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for agents-md-guard 0.1.0
File Interpreter ABI Platform Actions
agents_md_guard-0.1.0-py3-none-any.whl Python 3 none any Details for agents_md_guard-0.1.0-py3-none-any.whl

Total release size: 26.3 kB

Release files / agents_md_guard-0.1.0.tar.gz

Download URL agents_md_guard-0.1.0.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c0557492e26ae90176b11b874d342bb4880a9f9fb7a178b4cf4ee55692c412f5
BLAKE2b-256 checksum
How to use checksums
9d704c91ca8fd2595162e90c9d43a6195ed166fba1966dae7fbf5e78a99fc3c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / agents_md_guard-0.1.0-py3-none-any.whl

Download URL agents_md_guard-0.1.0-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dbc91bf1611cef40aa46e038127fcc86cfe9b30876100d7baa7d34dcf9aacbdf
BLAKE2b-256 checksum
How to use checksums
351d9d8479250d7ebf2479ddbae8763ef0830c1dc168f177dae46d4998a99437
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for agents-md-guard 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page