
Claude Code Skills That Fix Their Own Mistakes: Building Verification Loops
Chris Harper
3 min read
Aug 13, 2026 · 12:09 UTC
Package your build-test-fix cycle as a Claude Code skill and every session checks and corrects its own work automatically — without waiting for you to prompt it.
A verification loop is a cycle Claude Code runs until the work actually passes: take action → run checks → if failures, fix them → recheck → repeat. Out-of-the-box Claude Code catches tool errors inline, but packaging the loop as a dedicated skill makes it automatic, consistent, and composable across any session.
Adding verification to CLAUDE.md (simplest form):
## Verification commands
After any code change, always run:
1. `pnpm run lint` — must exit 0
2. `pnpm run test --changed` — must exit 0 with no failing tests
3. `pnpm run build` — must produce no TypeScript errors
Fix any failures before considering the task complete.
Claude reads these instructions and applies them every session — no explicit /verify call needed.
Packaging as a reusable skill:
<!-- .claude/skills/verify-pr/prompt.md -->
Run these checks in order. If any fail, fix the failures, then re-run from step 1.
Stop only when all three exit 0. Report: rounds taken and what was fixed each round.
1. `pnpm run lint`
2. `pnpm run test`
3. `pnpm run build`
Call it explicitly or chain it after another task in one prompt:
Refactor the auth module to use the new TokenService interface, then /verify-pr
Claude does the refactor, then immediately enters the verification loop — no separate prompt.
Four patterns:
| Pattern | When to reach for it |
|---|---|
| Embedded in CLAUDE.md | Default — applies to every session automatically |
Standalone skill (/verify) | Cross-cutting checks: security scans, a11y audits |
| Chained after a task | Keeps implementation and verification in one prompt |
| Tied to a hook | Runs automatically before git commit, impossible to skip |
Hook-based automatic verification:
// .claude/settings.json
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "if echo \"$CLAUDE_TOOL_INPUT\" | grep -q 'git commit'; then pnpm run lint && pnpm run test; fi"
}
]
}
]
}
}
This fires lint + tests automatically before any git commit Bash call — not just when Claude remembers to check.
Cost note: Each verification round uses tokens for check output + Claude's analysis. On a fast suite (<10s) the overhead is negligible; on a slow one, limit to changed files (--changed) so loops stay quick.
Sources: Building verification loops in Claude Code with skills — claude.com · Hooks reference — Claude Code Docs · Skills — Claude Code Docs