# 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.

Make Your AI Agent Pass Tests Before It Says "Done" is a paid AI agent skill on Agensi by Nicolas Baranov, in Code Quality & Review. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $5 (one-time purchase)
- Creator: [Nicolas Baranov](https://www.agensi.io/creators/creator-1633)
- Category: [Code Quality & Review](https://www.agensi.io/skills/code-quality-review)
- Version: 1.0
- Last updated: 2026-12-05
- Security: scan passed (2026-12-04); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/make-your-ai-agent-pass-tests-before-it-says-done
- Tags: code-review, testing, python, claude-code, git

## 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: "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: "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: "Run the SkillLayer verify check on my current changes."

## 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 test` are 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 example `migrations/` 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:
1. a one-off check of the current changes;
2. a copy of the tool in `~/.skilllayer/verify-tool/` and two hooks in `.claude/settings.local.json`;
3. 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.

## Requires

- Python 3.10+
- Git
- Optional: Claude Code (for the automatic hook)

On Windows, the automatic hook needs sh from Git for Windows or WSL.

## Known limitations

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.

## Technical details

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 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 Make Your AI Agent Pass Tests Before It Says "Done" 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

### How does this stop my AI agent from claiming a task is done when it is actually broken?

When the agent tries to finish, the Stop hook runs your tests itself and compares the turn's changes with where it started. If tests fail, tests were removed or skipped, or a protected path changed, the agent gets the observed facts and goes back to work. After two blocks in a row it may stop, and the work is recorded as unverified.

### Why should I use this instead of just telling my agent to check its own work?

An agent checking itself reports what it believes. This tool runs the tests and reads git itself, with no model involved, so the agent cannot talk its way past a failing exit code.

### What do I need in my project for this skill to work?

Python 3.10+ on the machine and a git repository. Tests are found automatically for pytest, unittest and npm test; for any other command, set SKILLLAYER_TEST_COMMAND in your shell profile. Protected paths are optional and listed in a committed .skilllayer-policy.yml.

### Does the automatic blocking feature work with every AI agent?

No. The automatic hook needs Claude Code's Stop hook. In Cursor, Codex and other agents, ask for the one-off check, which runs the same verification on the current changes.

### How do I tell my agent to start using these checks?

Ask your agent to set up the verify hook. It asks before it copies the tool to ~/.skilllayer/verify-tool/ and adds two hooks to .claude/settings.local.json, keeping your existing settings. The hooks take effect in a new Claude Code session.

### Does a passing result mean my code is 100% correct?

No. It means the tests ran and passed and no protected path changed. If the agent changed an expected value in a test, that is reported, not blocked, and you judge it.

---

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.
