Make Your AI Agent Pass Tests Before It Says "Done"

    by Nicolas Baranov

    1

    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

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    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 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/.
    VerdictMeaningBlocks the stop
    VERIFIEDTests ran and passed; no protected path touchedno
    TESTS_FAILINGTests ran and failedyes
    TESTS_WEAKENEDTests or assertions were removed or skipped this turnyes
    POLICY_VIOLATIONA protected path, or the policy itself, changedyes
    UNVERIFIED_*No tests found, could not run, or timed outno, 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.

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

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

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

    Terminal / Shell
    Read Files
    Write Files
    Environment Variables

    File Scopes

    .claude/settings.local.json
    .skilllayer-policy.yml
    ~/.skilllayer/**

    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.

    Listedtoday

    What's inside

    Creator

    Nicolas Baranov

    Nicolas Baranov

    5 skills on Agensi

    Frequently Asked Questions

    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.

    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.

    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.

    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.

    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.

    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.

    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.