# AI Code Diff & PR Hygiene Gate

> Pure-Python unified-diff gate catching deleted test assertions, AI slop, hardcoded local paths, secrets, scope creep, and import boundaries.

AI Code Diff & PR Hygiene Gate is a paid AI agent skill on Agensi by Wasabi hu, in Code Quality & Review. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $5.99 (one-time purchase)
- Creator: [Wasabi hu](https://www.agensi.io/creators/wasabi-hu)
- Category: [Code Quality & Review](https://www.agensi.io/skills/code-quality-review)
- Version: 1.0.0
- Last updated: 2026-12-01
- Security: scan passed (2026-12-01); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/ai-code-diff-pr-hygiene-gate
- Tags: code-review, git-diff, ci-cd, testing, security, python

## About this skill

Coding agents often take shortcuts, such as commenting out failing tests, swallowing exceptions, or leaving hardcoded local paths in diffs. This skill provides a deterministic, zero-dependency gate that inspects unified diffs to enforce code hygiene and architectural boundaries before you commit.

### What it does
- **Slop detection** flags empty exception handlers, TypeScript `any` escapes, and production debug macros like `dbg!()` or `todo!()`.
- **Test integrity auditing** catches deleted or commented-out assertions and newly added tests that lack actual validation logic.
- **Leak prevention** identifies hardcoded local home directories, credential prefixes, and forbidden email addresses in the diff.
- **Architectural enforcement** blocks forbidden cross-layer imports and ensures paired files, like schemas and generated artifacts, are updated together.
- **Scope control** restricts edits to allowed directory globs and caps the total number of files an agent can modify in one pass.

### How it works
1. **Pipe the diff** from `git diff` or a patch file directly into the script via stdin.
2. **Run specific auditors** for general hygiene, test integrity, or architectural scope based on your needs.
3. **Review violations** provided in standard agent text, JSON, or SARIF formats for CI integration.
4. **Apply suppressions** using inline comments like `# diff-gate:allow(...)` for intentional exceptions.

### Frameworks & tools
This skill uses Python 3.11+ standard library modules including `ast`, `tomllib`, and `pathlib`. It operates as a standalone utility with no external dependencies or network requirements.

### Why this beats prompting it yourself
LLMs are notoriously bad at catching their own subtle "lazy" errors like missing assertions or silent `try/except` blocks. This tool uses deterministic AST and regex patterns to provide 100% reliable detection that doesn't cost tokens or suffer from hallucinations.

### Use cases
- Preventing AI agents from quietly disabling tests to make a PR pass.
- Blocking sensitive local file paths from entering the repository history.
- Enforcing strict module boundaries in monorepos via import restrictions.
- Verifying that generated code artifacts match their source definitions.

### Known limitations
Does not replace full compilers or type checkers. Requires Python 3.11 or higher and does not execute git commands directly.

## Requires

- Python
- Git

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the AI Code Diff & PR Hygiene Gate skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### What specific problems does this skill solve for AI-generated code?

This skill acts as a deterministic gate that inspects unified diffs to catch AI slop like empty exception handlers, deleted test assertions, and hardcoded local file paths that agents often introduce when trying to make code pass quickly.

### What software or accounts are required to run these tools?

You only need Python 3.11 or higher. The skill is a zero-dependency utility that uses the Python standard library and does not require external packages, network access, or specialized software accounts.

### What kind of outputs and configuration options does this skill provide?

It provides violation reports in standard agent text, JSON, or SARIF formats for CI integration, and it supports a TOML configuration file to define custom architectural boundaries and file edit limits.

### Are there any limitations to what this code gate can detect?

The skill is not a replacement for full compilers or type checkers and it does not execute git commands directly; it requires you to pipe the diff output from stdin or a patch file.

### How should I instruct my agent to interact with this skill?

You can ask your agent to pipe its proposed git diff into the scripts to check for hygiene violations, test integrity issues, or architectural scope creep before it finalizes a commit.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
