Self-Verifying Agent Loop: Plan, Check, Retry, Close
Turns a goal into a task plan with machine-run checks, executes with retry caps, escalates, and refuses to close until verified.
Before & after
Same prompt, same agent — the only difference is the skill.
That sounds like a job for an automated workflow. You'll want to break it down into discrete tasks, then figure out how to verify each one. The challenge is you need domain-specific tools for each task, and some tasks will fail and need retry logic. You might also want to set spending or attempt caps so it doesn't loop forever. Really though, it depends on what your domain is and what tools you have available—I'd need to understand your setup better to give you a concrete plan.
GOAL: Drive marketing funnel task set to verified close TASK PLAN → Research content gaps in product category → Write 3 blog posts addressing gaps → Upload posts to CMS and schedule → Generate social teasers for each post → Verify publishing and engagement setup DOMAIN TOOLING Marketing domain includes: content research, writing, CMS integration, social scheduling, analytics verification. VERIFICATION GATES (machine-run checks) • Blog post length >=800 words • All posts scheduled within 1 week • Social teasers reference original posts • CMS entries have alt text • Analytics filters match business objectives BUDGET & RETRY Max 12 task executions. Retry failed tasks 2x with revised approach. Escalate research gaps to human if both retries fail. Never close until all verifications pass or explicitly waived by user.
About this skill
Your agent says 'done' and the tests still fail. It retries the same fix eight times until the context runs out. Or it gets to green by quietly editing the test. This skill runs goals as a bounded loop. Every task gets a machine-run check written before any work starts. Retries must change something. Nothing closes until the evidence says so.
What it does
- Compiles a goal into tasks, each with an exact pass condition (exit code, metric threshold, zero matches), dependencies, and allowed scope
- Protects tests, thresholds, and check scripts. Weakening a check to get a pass counts as a failure, not a pass.
- Classifies each failure before retrying it (bug, flaky, environment, spec ambiguity) and stops a task when the same failure shows up twice in a row
- Keeps an append-only evidence ledger in your workspace, so long runs and subagents can resume without trusting memory
- Escalates with a one-screen packet: what failed, what was tried, and which decision it needs from you
- Ends with an honest status (DONE, PARTIAL, or BLOCKED) after a final regression run, with waivers recorded by whom and why
What you get
A compiled plan with checks and budgets, execution with a running ledger when tools are available, and a close report. It can also audit an agent transcript that claims to be done, or produce a reusable loop spec for your team's domain.
Best for
Claude Code users and teams running agents or subagents on multi-step work (coverage targets, migrations, content batches, data reconciliations) who are tired of false 'done' claims and runaway retry loops.
SKILL.md preview
---
name: self-verifying-agent-loop
… (sign up to view the full skill)More ai & agents skills
View all AI & Agents skills →New Skill Scaffolder
Create a new Claude Code skill correctly: right mechanism, valid name and folder, a triggering description, and a smoke test.
Skill Library Lint and Overlap Report
Lint every skill in a repo at once: frontmatter, name-folder match, weak descriptions, overlapping triggers, broken refs, plus a CI script.
Skill Test Runner (Trigger and A/B)
Test a skill in fresh sessions: ready-to-run prompts, commands, and rubric for trigger recall, false triggers, and blind A/B.
Chief AI Officer Plan Review
Evidence-first review of one AI plan: eval gaps, cost per successful task, model and vendor risk, prompt injection, and EU AI Act screen.