- Home
- Skills
- Code Quality & Review
- Make Your AI Agent Pass Tests Before It Says "Done"
Make Your AI Agent Pass Tests Before It Says "Done"
Adds a Claude Code Stop hook that runs your tests itself when the agent tries to finish, and sends it back to work if the tests fail, were weakened, or a protected path changed. No model, no network.
$5
What it does
- Runs your tests itself when the agent tries to finish, and reads the real exit status
- Sends the agent back to work with the failing tests when they fail
- Blocks weakened tests: removed tests or assertions, added skips, deleted test files
- Blocks changes to paths your committed policy protects
- Never reports a check that could not run as a pass
- Lets the agent stop after two blocks and records the work as unverified
Who it's for
Developers who let Claude Code work on its own
The agent cannot end its turn on failing tests: the hook runs them and sends it back with the failures.
Try asking: “Set up the verify hook so you can't tell me it's done unless the tests pass.”
Team leads reviewing agent-written changes
Removed tests, added skips and edits to protected paths are caught before the change reaches review.
Try asking: “Protect migrations/ and .github/workflows/ with a SkillLayer policy.”
Users of Cursor, Codex and other agents
A one-off check of the current changes: tests run by the tool, weakened tests flagged, a clear verdict.
Try asking: “Run the SkillLayer verify check on my current changes.”
Make Your AI Agent Pass Tests Before It Says "Done"
Example session with this skill installed
Set up the verify hook so you can't tell me it's done unless the tests pass.
- Read your context and instructions
- Compiled the make your ai
I'll set this up in two steps and ask before each one.
1. Install (you said yes). I copied the tool to ~/.skilllayer/verify-tool/ and checked that the hook starts:
hook exit: 0
Then I added two hooks to .claude/settings.local.json and kept everything already there: a UserPromptSubmit hook that records where each turn starts, and a Stop hook that checks the work when I try to finish. They take effect in a new Claude Code session.
What it does next
The outputs below are real. They come from our test run in a small repository, with Claude Code's hook input simulated by piping the same JSON into the hook.
The agent broke test_floor and tried to finish. The Stop hook blocked it and told the agent:
skilllayer: this work cannot be accepted as complete — independent verification found problems.
- Tests failing (observed by running them): python3 -m unittest discover -> Ran 2 tests in 0.000s (exit 1, 0.0s)
test_cart.py::test_floor
Fix the issues above, then finish. Do not report success without re-running the tests.
(Blocked attempt 1 of 2; after that the hook lets you stop but records the work as UNVERIFIED.)
You see: skilllayer sent the agent back to work (attempt 1 of 2): tests failing (test_cart.py::test_floor).
The agent then skipped the test instead of fixing it. Blocked again:
- Tests were weakened this turn (observed in the diff) — restore them. If the task really requires removing or skipping tests, say so in your final message: only the user can approve it.
skip/xfail added — test_cart.py:5 (@unittest.skip("flaky"))
- Test files were changed this turn: test_cart.py — do not weaken tests to make them pass.
(Blocked attempt 2 of 2; after that the hook lets you stop but records the work as UNVERIFIED.)
The agent fixed the code properly. The hook passed silently. A one-off check of the same state:
skilllayer verify — ✓ VERIFIED
tests (observed): python3 -m unittest discover -> Ran 2 tests in 0.000s (exit 0, 0.0s)
changed paths: 1
wrote: ~/.skilllayer/verify/repo-2d78c2377a21/receipts/20261204T233818814375Z-VERIFIED.json
If the tool folder is missing, you get skilllayer: the verify tool was not found in ~/.skilllayer/verify-tool, so this work was NOT verified. and the agent is not blocked.
Next: want me to protect any paths, such as migrations/ or .github/workflows/? That adds a .skilllayer-policy.yml, which takes effect once you commit it.
Connects securely to your tools. The creator never sees your data.
About this skill
Your agent says "done, all tests pass". This skill makes that a checked fact instead of a claim.
It sets up a Claude Code Stop hook. When the agent tries to finish, the hook runs your tests itself, reads the live git state and decides. If something is wrong, the agent is sent back to work with the observed facts, and you see a one-line notice. No model and no network are involved, so the same state always gets the same verdict.
What it checks
- Tests: runs your test command (pytest, unittest or
npm testare found automatically) and reads the real exit status. - Weakened tests: fewer tests or assertions, added
skip/xfail, deleted test files. - Protected paths: paths listed in your committed
.skilllayer-policy.yml, for examplemigrations/or.github/workflows/.
| Verdict | Meaning | Blocks the stop |
|---|---|---|
VERIFIED | Tests ran and passed; no protected path touched | no |
TESTS_FAILING | Tests ran and failed | yes |
TESTS_WEAKENED | Tests or assertions were removed or skipped this turn | yes |
POLICY_VIOLATION | A protected path, or the policy itself, changed | yes |
UNVERIFIED_* | No tests found, could not run, or timed out | no, but never reported as a pass |
After two blocked attempts in a row the agent may stop, and the work is recorded as unverified, so a session is never trapped.
How it is set up
The agent asks before each step that writes anything:
- a one-off check of the current changes;
- a copy of the tool in
~/.skilllayer/verify-tool/and two hooks in.claude/settings.local.json; - optionally, a policy file with the paths to protect.
What it does not do
- A passing suite is not proof of correctness. A changed expected value in a test is reported, not blocked.
- It does not read what the agent says, review design, or look for vulnerabilities.
- The hook is for Claude Code only. Other agents can run the one-off check.
Licence
The bundled source is under the Business Source License 1.1 (full text in the package). Use is free for non-commercial use, for an evaluation or pilot of up to 90 days per organisation, and in an organisation where up to 10 developers use it.
Automatic blocking works only in Claude Code. A passing suite is not proof of correctness: a changed expected value in a test is reported, not blocked. It does not review design or look for vulnerabilities. Needs Python 3.10+ and git.
Version 1.1 (in review; buyers get 1.0 until it is approved): the whole tool is one file, scripts/skilllayer.py, 131 KB of Python, standard library only, cut from SkillLayer v0.3.1. It contains no network code. SKILL.md gives its SHA-256, and the agent checks its copy before running it. Version 1.0 bundles the same tool as about 85 .py files with a launcher; the commands the skill runs make no network calls. Both need Python 3.10+ and git, install no packages and change no environment variables. Hook setup, only after the user agrees: copies the tool and templates/hook.sh to ~/.skilllayer/verify-tool/ and adds a UserPromptSubmit hook (timeout 30 s) and a Stop hook (timeout 600 s, tests capped at 540 s) to .claude/settings.local.json. hook.sh finds Python 3.10+ and, if anything is missing, tells the user the work was not verified and exits 0, never blocking on its own error. State, receipts and an event log go to ~/.skilllayer/verify/<repo>-<hash>/, never into the working tree. The policy is read from the committed .skilllayer-policy.yml at the start of each turn. A custom test command comes from $SKILLLAYER_TEST_COMMAND, never from the repository.
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 today
- Software
Python 3.10+
Git
- Optional
- Claude Code (for the automatic hook)
On Windows, the automatic hook needs sh from Git for Windows or WSL.
Permissions
File Scopes
Terminal: runs the skill's Python tool, git and your own test command. Read Files: reads git state and test files. Write Files: only with your yes, copies the tool to ~/.skilllayer/verify-tool/, adds two hooks to .claude/settings.local.json and, optionally, a policy file; receipts go to ~/.skilllayer/verify/. Environment Variables: reads the optional SKILLLAYER_TEST_COMMAND. No network: version 1.1 has no network code; version 1.0's bundled source contains package-registry lookups for commands this skill never runs.
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.