- Home
- Skills
- Testing & Debugging
- Test Integrity Guard Pro
Test Integrity Guard Pro
AST-level semantic detector that stops AI agents from making tests pass by making tests weaker — catches loosened assertions, tautologies, broadened exceptions, widened tolerances, and mocked-out code under test.
$9
Works with the AI Agents you already use
Test Integrity Guard Pro
Example session with this skill installed
Verify the integrity of my staged test files against HEAD to ensure the AI didn't loosen any assertions.
- Read your context and instructions
- Compiled the test integrity guard
I have analyzed the changes in your staged test files. I detected several critical integrity violations where assertions were weakened or bypassed.
=== TEST INTEGRITY RECEIPT ===
Scope : staged vs HEAD
Verdict : FAIL (critical: 2, warnings: 1, info: 0)
Test files : 2 compared (python: 1, js/ts: 1)
Tests : 5 paired, 0 added, 0 removed, 0 renamed
Assertions : 6 -> 6 across paired tests
Findings
- [CRITICAL] LOOSENED_ASSERTION @ tests/test_api.py::test_response_code
Assertion onstatus_codeweakened from exact to bounded check
before: assert response.status_code == 200
after : assert response.status_code >= 200 - [CRITICAL] FOCUSED_TEST @ src/tests/auth.test.ts::logs in user
Added .only — every other test in this file silently stops running
before: it("logs in user", ...
after : it.only("logs in user", ... - [WARNING] CHANGED_LITERAL @ tests/test_api.py::test_payload
Assertion value changed but strength is identical
before: assert data["id"] == 101
after : assert data["id"] == 999
==============================
The check failed with exit code 1. You should revert the changes to these tests and fix the implementation logic instead.
Next steps
- Remove the
.onlymodifier fromauth.test.ts. - Restore the exact equality check in
test_api.py. - Re-run the implementation fix to satisfy the original test constraints.
Connects securely to your tools. The creator never sees your data.
About this skill
When an AI coding agent can't make a test pass, it rarely deletes the whole test file (which is easy to spot in a line diff). Instead, it makes subtle semantic edits that keep the assertion count unchanged while destroying the test's ability to catch bugs:
- Loosening assertions:
assert calc(2, 3) == 5→assert calc(2, 3) >= 0, orexpect(x).toBe(5)→expect(x).toBeTruthy() - Turning checks into tautologies:
assert len(items) == 3→assert len(items) >= 0, orexpect(x)with no matcher - Broadening expected errors:
pytest.raises(ValueError, match="invalid")→pytest.raises(Exception), or.toThrow(TypeError)→.toThrow() - Widening float tolerances:
pytest.approx(1.5)→pytest.approx(1.5, rel=0.5), ortoBeCloseTo(0.3, 5)→toBeCloseTo(0.3, 1) - Mocking the function under test: Adding
@mock.patch("pkg.calc", return_value=5)orjest.mock("../src/calc")inside a test that was supposed to testcalc - Swallowing or bypassing assertions: Wrapping assertions in
try ... except Exception: pass, inserting an earlyreturnbefore assertions, or addingit.only(...)so every other test in the file silently stops running
Line-by-line regex scanners miss these because an assertion line is still there.
Test Integrity Guard parses both the before (HEAD or base branch) and after versions of every modified Python (pytest / unittest) and JS/TS (Jest / Vitest) test file, pairs each test function/block by name (and detects body-identical renames without false alarms), matches assertions by their subject expression, and compares them on a 4-tier strength lattice (EXACT > BOUNDED > TRUTHY > TAUTOLOGY).
What's Inside (Zero Dependencies — Pure Python 3.9+ Stdlib & Bash)
- AST & Token Semantic Engine (
scripts/test_integrity.py&scripts/test-integrity.sh)- Supports
--working(vsHEAD),--staged(pre-commit),--base main(PR review),--compare old.py new.py(git-free file pair),--strict, and--json. - Prints a side-by-side
beforevsafterTest Integrity Receipt for every weakened assertion.
- Supports
- Drop-In Claude Code
StopHook (hooks/claude-stop-guard.sh)- Blocks Claude Code from finishing a turn (exit code
2) whenever modified tests are weaker than before, feeding the exactbefore/afterreceipt back to the agent so it fixes the implementation instead of the test.
- Blocks Claude Code from finishing a turn (exit code
- One-Command Git Pre-Commit Installer (
scripts/install-hooks.sh)- Installs a
.git/hooks/pre-commitgate and prints the ready-to-paste.claude/settings.jsonhook block.
- Installs a
- Reference Manual (
references/assertion-strength-hierarchy.md)- Complete 4-tier assertion strength hierarchy across
pytest,unittest,unittest.mock,Jest, andVitestplus all 15 semantic rules.
- Complete 4-tier assertion strength hierarchy across
Built by Harvey | Tech Builder (@lxy71 · https://harveyi.com) — creator of the free companion skills AI Verify Guards and AI Diff Audit.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Testing & Debugging.
Supports only Python and JS/TS. Requires Python 3.9+. Requires git for branch and staged comparisons. Assessment is limited to AST-level semantic checks.
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
Git
Python 3
Permissions
Read-only AST & token comparison over git test files; zero external dependencies; no network access.