Use before any unattended loop (/loop, workflow script, retry loop, scheduled run): set a checkable exit, must-not list, retry cap, independent judge and blocked end state.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Loop Check?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ivan-ii-tech-digital-loop-check)
---
name: loop-check
description: "Use before any unattended loop (/loop, workflow script, retry loop, scheduled run): set a checkable exit, must-not list, retry cap, independent judge and blocked end state."
---
# loop-check
Before the first unattended iteration starts, write these five down where the loop reads them (its prompt,
its script header, or the change folder's `tasks.md`). Any one missing: ask with `clarify-first`, do not start.
1. **Exit check a machine can run**: a command and its passing result (`npm test` exits 0, `ak-check-all`
passes when ak-quality is installed, a file exists). "Looks done" and "the agent says done" are not exits.
2. **Must not**: what the loop may never touch or do (files, branches, pushes, deletes, deploys, money,
messages to people). Each iteration re-reads it.
3. **Retry cap**: at most N rounds (default 3, as in the lead workflow's fix loop) and a time or token
budget. The same failure after 2 different fixes ends it early (`retry-cap`).
4. **Judge apart from the builder**: the exit check, or a fresh agent that reads the diff and the check
output, never the builder's own report.
5. **End state a machine can read**: in a change folder, `.change.yaml` `status: blocked` plus
`blocked_reason:` with one of `unclear-intent`, `intent-gap`, `verification-failed`, `retry-cap`,
`tool-missing`, `plan-failed-checks`; the evidence (failing command, last output line) goes in the
work-state file (`ak-state save`, then its "Last failing gate" section; the steps are in
`../ak-save/SKILL.md` from this skill's base directory). When `ak-state` is not on PATH (this skill installed
alone), the work-state file is `.agent-kit/state/loop-<name>.md` (`<name>` the loop's name; create it and its
folder when missing, and keep it out of git as `ak-state` does: a `.gitignore` of `*` in that folder when
`git check-ignore` does not ignore the file yet), with the evidence under `## Last failing gate`. Outside a
change folder: that file and a last output line `blocked: <reason> — <evidence>`. Success is the exit check
passing, never read from chat.
While it runs:
- **High context is not permission to stop.** Save state (`ak-state save`, then steps 2-4 of
`../ak-save/SKILL.md` from this skill's base directory; when `ak-state` is not on PATH, the done steps and the
next one into `.agent-kit/state/loop-<name>.md`) and continue in a fresh session; only the exit check, the cap or
a blocked reason ends the loop.
- **A blocked change halts later dispatches.** Before each dispatch, read `.change.yaml`: `blocked` → stop,
quote `blocked_reason`, start nothing for that change. Only the user clears it; never reset the status
yourself.
- An intent gap found at review: save the attempted diff as a patch beside the change before any revert.
- **No command that stops for a guard's question.** Stop only what you started, in the same call (`kill $!` or
its literal PID; a process group asks), never a `pkill -f` sweep. Scratch goes under `$TMPDIR` or `mktemp -d`, never a literal
`/tmp/<name>`. `ln` and `rm -r` go in separate calls. Config and settings files change with the Edit tool, never
`sed -i`, `jq … > tmp && mv` or `printf >`. Never set `CLAUDE_CODE_SESSION_ID` yourself.