Claude Code Guardrails: stop false "done" reports

    by laika

    1

    Three bash hooks that surface failed commands, force checked-vs-unchecked replies, and break retry loops.

    Free

    2 usesSecurity scanned

    Works with the AI Agents you already use

    Claude Code Guardrails: stop false "done" reports

    Example session with this skill installed

    Install the guardrail hooks for this project. Make sure we have the loop breaker and the verification quantifier.

    • Read your context and instructions
    • Compiled the claude code guardrails

    Installed the three guardrail hooks into this project. This is the real output from bash install.sh ~/myproj (macOS, jq 1.7):

      installed  ~/myproj/.claude/hooks/verify-before-done.sh
      installed  ~/myproj/.claude/hooks/quantify-claims.sh
      installed  ~/myproj/.claude/hooks/loop-breaker.sh
    
      settings   ~/myproj/.claude/settings.json  (backup written alongside)
      json ok
    
    Restart Claude Code, or open /hooks once, to load them.
    

    Check

    WhatCommandResult
    Hook events registeredjq '.hooks | keys' .claude/settings.json["PostToolUse", "UserPromptSubmit"]
    Backup writtenls .claude/settings.json.bak.20260929125322
    Second runbash install.sh ~/myprojadds no duplicate entries

    What the agent sees after a failing test run

    Fed a Bash result of === 2 failed, 14 passed === with exit code 1, verify-before-done.sh returned this context to the agent:

    The command that just ran shows failure signals: failing tests.
    
    Do NOT report this turn as done, fixed, working, or passing until you have
    addressed it. Required:
      1. Read the actual output and exit code. Do not infer them.
      2. State plainly what failed and why.
      3. Anything you could not verify, label as unverified.
    

    Next steps

    • Restart Claude Code or open /hooks once so the hooks load.
    • To remove: restore the newest settings.json.bak.*, or delete the three entries whose command ends in verify-before-done.sh, quantify-claims.sh or loop-breaker.sh.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Claude Code sometimes summarizes a turn as finished when a command in it failed. A rule in CLAUDE.md does not reliably prevent that: in one workspace the verification rule was in context for all 22 verification-shaped replies and was followed in 13 of them (59%). Hooks fire at the moment the rule matters, so these three move the rules out of the instructions file.

    What is included (3 bash hooks, 58-69 lines each, bash + jq only):

    • verify-before-done: after each Bash call, scans the output for failure signals (non-zero exit, failing test counts, tracebacks, connection refused, permission denied) and adds a note naming what it found. Skips cat/grep/head/--help so reading a file about failures does not fire it.
    • quantify-claims: on verification-shaped prompts, asks the reply to open with "verified n% (numerator/denominator)" and to name what was not checked.
    • loop-breaker: counts consecutive calls to the same tool and, past a threshold, tells the agent to stop and choose a different move. Ordinary tools (Bash, Read, Grep, Edit, Write) are skipped by default.

    install.sh merges into your existing settings.json, writes a timestamped backup first, and adds nothing on a second run. Nothing is sent anywhere; the hooks only read the hook payload on stdin. Read the hooks before installing.

    What it does not do: it does not make an agent honest or prevent every false completion. It makes failed output hard to skip past.

    Requires bash and jq. Written for Claude Code hook settings (settings.json). It does not make an agent honest or prevent every false completion; it makes failed output hard to skip past. The failure scan matches common patterns (exit codes, test counts, tracebacks) and can miss tool-specific wording.

    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

    2 uses

    Times used to date

    Free to use

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 2 months ago

    • Free with an Agensi account

    Permissions

    Terminal / Shell

    File Scopes

    skill/**
    Listed2 months ago

    What's inside

    Frequently Asked Questions

    A rule in CLAUDE.md is read once and can be skipped. A hook runs at the moment it matters: right after a Bash call, or when a verification-shaped prompt arrives. In one measured workspace the written rule was followed in 13 of 22 cases (59%).

    bash, jq, and Claude Code with hooks support. Tested on macOS.

    Yes. install.sh writes to <project>/.claude/ by default, or to ~/.claude/ with --global.

    install.sh, the three hook scripts (verify-before-done.sh, quantify-claims.sh, loop-breaker.sh), SKILL.md with install/check/remove steps, and the MIT license. install.sh writes a timestamped backup of settings.json before it changes anything.

    Not normally. The hooks live in settings.json, which Claude Code updates do not overwrite. If the hook format changes, re-run install.sh; running it again adds no duplicate entries.

    New in LLM Ops

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for LLM Ops.

    Free