Claude Code Guardrails: stop false "done" reports
by laika
Three bash hooks that surface failed commands, force checked-vs-unchecked replies, and break retry loops.
Free
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
| What | Command | Result |
|---|---|---|
| Hook events registered | jq '.hooks | keys' .claude/settings.json | ["PostToolUse", "UserPromptSubmit"] |
| Backup written | ls .claude/ | settings.json.bak.20260929125322 |
| Second run | bash install.sh ~/myproj | adds 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
/hooksonce so the hooks load. - To remove: restore the newest
settings.json.bak.*, or delete the three entries whose command ends inverify-before-done.sh,quantify-claims.shorloop-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
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
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
File Scopes
What's inside
Frequently Asked Questions
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.