- Home
- Skills
- Code Quality & Review
- AI Code Diff & PR Hygiene Gate
Works with the AI Agents you already use
AI Code Diff & PR Hygiene Gate
by Wasabi hu
Pure-Python unified-diff gate catching deleted test assertions, AI slop, hardcoded local paths, secrets, scope creep, and import boundaries.
$5.99
AI Code Diff & PR Hygiene Gate
Example session with this skill installed
Run the offline PR hygiene and test-integrity gates on my staged diff (synthetic_dirty_pr.diff and synthetic_test_tamper.diff), list every failing rule ID and line number, and show how to fix or suppress intentional exceptions.
- Read your context and instructions
- Compiled the ai code diff
Ran vet_diff_gate.py and audit_test_integrity.py offline on the two synthetic unified diffs (--format json). Both gates returned non-zero (ok: false).
Stage 1 — PR Hygiene & AI Slop (vet_diff_gate.py, 3 files, 10 added lines: 3 errors, 1 warning)
| Severity | Rule ID | Location | Finding |
|---|---|---|---|
| error | slop-guard/empty-except | src/service.py:15 | Added empty broad except Exception: pass. |
| error | slop-guard/ts-as-any | src/client.ts:2 | Added as any type bypass. |
| error | slop-guard/ts-ignore | src/client.ts:3 | Added @ts-ignore / @ts-nocheck. |
| warning | pr-hygiene/lockfile-drift | uv.lock:1 | Lockfile uv.lock modified without changing pyproject.toml. |
Stage 2 — Test Integrity (audit_test_integrity.py, 2 files: 3 errors)
| Severity | Rule ID | Location | Finding |
|---|---|---|---|
| error | test-integrity/deleted-assertion | tests/test_billing.py:5 | Commented out an existing test assertion. |
| error | test-integrity/skipped-test | tests/test_billing.py:7 | Added unconditional skipped/ignored test. |
| error | test-integrity/assertionless-test | tests/test_billing.py:11 | Newly added test function contains zero assertions. |
Commands Executed
python3 scripts/vet_diff_gate.py synthetic_dirty_pr.diff --forbid-email ceo@example.com --format json
python3 scripts/audit_test_integrity.py synthetic_test_tamper.diff --format json
Next Steps
- Replace
except Exception: passwith explicit error handling, removeas any/@ts-ignore, and verify whetherpyproject.tomlshould change alongsideuv.lock. - Restore the commented assertion in
tests/test_billing.py:5, remove the unconditional skip on line 7, and add an assertion to the new test on line 11. - For an intentional, audited exception on a single line, add an inline suppression with the exact rule ID, e.g.
// diff-gate:allow(slop-guard/ts-as-any)or# diff-gate:allow(pr-hygiene/abs-path). - Re-run with
--format sariffor CI/IDE integration.
Connects securely to your tools. The creator never sees your data.
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
anyescapes, and production debug macros likedbg!()ortodo!(). - 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
- Pipe the diff from
git diffor a patch file directly into the script via stdin. - Run specific auditors for general hygiene, test integrity, or architectural scope based on your needs.
- Review violations provided in standard agent text, JSON, or SARIF formats for CI integration.
- 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.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 3 days ago
- Software
Python
Git
Permissions
100% offline read-only Python 3.11+ standard library execution. Reads unified diffs from stdin or a file path plus optional read-only repo/TOML config and prints structured JSON, Markdown, or SARIF 2.1.0 to stdout. Zero network requests, zero subprocesses, zero environment variables, zero file mutations.
What's inside
Frequently Asked Questions
New in Code Quality & Review
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Code Quality & Review.