Skip to main content
Glama

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.

Related MCP server: slop-guard

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.

Available Tools

3 tools
agents_md_checkA

Lint an agent instruction file (AGENTS.md, CLAUDE.md, .cursorrules, copilot-instructions.md) for rules that are not binding: missing normative keywords, weak wording, duplicated rules, contradictions, oversized files. With 'repo' + 'rev'/'base'/'staged' it runs the real diff gate instead and reports whether a commit weakens a rule or lacks the Human-Reviewed-By trailer.

Inputs: rev, base, path, repo, +3 more.

agents_md_fix_suggestionsB

Lint the same input as agents_md_check and return one concrete rewrite hint per finding, with the offending line.

Inputs: path, text.

agents_md_rulesA

Return the rule set agents-md-guard enforces: guarded file names, normative keywords (EN + BS), the human approval trailer, lint codes and exit codes.

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 3 tools

    Disambiguation4/5

    agents_md_check and agents_md_fix_suggestions operate on the same input and both produce lint findings, so an agent could initially hesitate between them. The descriptions do resolve it (findings vs. per-finding rewrite hints), and agents_md_rules is clearly a static reference lookup, so boundaries are mostly clear.

    Naming Consistency5/5

    All three tools share the same 'agents_md_' prefix and snake_case style, with short action-oriented suffixes (check, rules, fix_suggestions). The pattern is immediately predictable and scannable.

    Tool Count5/5

    Three tightly scoped tools for a linter/guard server: run the lint, fetch the rule reference, get fix hints. Nothing feels padded or missing at the surface level.

    Completeness4/5

    The core lifecycle (diagnose -> understand rules -> remediate) is covered, including the diff-gate mode via check. Minor gaps: no tool to actually apply fixes or to configure/initialize a guard file, so agents must edit files themselves.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Provides deterministic AST graph queries and rule validation for AI coding agents via MCP tools, enabling structural intelligence without LLM calls.
      MIT
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables agents to analyze text or files for formulaic AI writing patterns and receive numeric scores, band labels, contextual violations, and concrete advice. It offers programmatic prose linting via MCP tools without using an LLM judge or external API calls.
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables deterministic auditing of agent responses against source documents, verification of workspace file paths, line ranges, and AST symbols, rule listing, and reproducible benchmark execution through MCP tools.
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI coding agents to enforce deterministic pre-write AST and secret guardrails, compress context with a Git-portable Markdown memory graph, and manage spec-to-code governance through three MCP tools.
      201 PyPI
      Apache 2.0