Has the agent resolve the project's own build, typecheck, lint and test commands, run them, scan the diff for leaked secrets (API keys) and debug leftovers, review the diff, prove the stated goal landed, then print a PASS/FAIL report. Use when a feature, fix or refactor is finished and before opening a PR. Not for a security review. Guidance for Law 4 (Verify Before Reporting): the agent runs it because it read it. The one hook behind it is hooks/typecheck-stop.mjs, off by default.
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 Verification Loop?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/naimkatiman-verification-loop)
---
name: verification-loop
tier: "1"
description: "Has the agent resolve the project's own build, typecheck, lint and test commands, run them, scan the diff for leaked secrets (API keys) and debug leftovers, review the diff, prove the stated goal landed, then print a PASS/FAIL report. Use when a feature, fix or refactor is finished and before opening a PR. Not for a security review. Guidance for Law 4 (Verify Before Reporting): the agent runs it because it read it. The one hook behind it is hooks/typecheck-stop.mjs, off by default."
origin: continuous-improvement
---
# Verification Loop Skill
A checklist the agent runs after a change: resolve the project's own commands, run them, read the diff, then confirm the goal landed. This skill guides the whole review. The optional turn-end check is described under Integration with Hooks.
## When to Use
Invoke this skill:
- After completing a feature or significant code change
- Before creating a PR
- When you need evidence that the build, types, lint and tests pass
- After refactoring
**When the project keeps the same state in more than one place** (a database row, a file on disk, in-memory loop state) and the session is resuming after a crash, a pause or a compaction, name which copy is the authority for each piece of state and compare the copies before Phase 0. Report a copy that is STALE, DIVERGED or MISSING under "Issues to Fix" and stop there: a ladder run against state that disagrees with itself reports green on the wrong inputs. Do not repair a difference silently, and do not count an absent copy as a match.
## Verification Phases
### Phase 0: Resolve the Ladder
Every project has its own actual invocation for build / typecheck / lint / test / security / deploy-receipt. Hardcoding `npm run build` and `npm run test` works when the project happens to use those exact scripts; for everything else (pnpm, yarn, cargo, go, mise, just, custom scripts, monorepos with workspace-scoped commands) it returns "deps not installed" or "config not found" misreads from the wrong invocation. Phase 0 runs first so Phases 1–6 never have to guess.
**Run `node "${CLAUDE_PLUGIN_ROOT}/scripts/resolve-verify-ladder.mjs"`** (source: `scripts/resolve-verify-ladder.mjs`) at the repo root. It encodes the full four-step resolution priority and emits the fenced block below. Use `--json` for machine consumption. If the script is not available (the variable is unset or the file is missing), apply the four steps under "Resolution priority" by hand and print the same block.
```
$ node "${CLAUDE_PLUGIN_ROOT}/scripts/resolve-verify-ladder.mjs"
verify-ladder (resolved):
build: npm run build (sniff:package.json:scripts.build)
typecheck: npm run typecheck (sniff:package.json:scripts.typecheck)
lint: npm run lint (sniff:package.json:scripts.lint)
test: npm test (sniff:package.json:scripts.test)
security: (ask operator — no marker found)
deploy_receipt: (ask operator — no marker found)
synthetic_checks: (ask operator — no marker found)
```
**Resolution priority** (first match wins; the script implements this — the prose is documentation):
1. **`.claude/verify-ladder.json` manifest** at the repo root. Schema:
```json
{
"build": "npm run build",
"typecheck": "tsc -p tsconfig.json --noEmit",
"lint": "npm run lint",
"test": "npm test",
"security": "npm audit --audit-level=high",
"deploy_receipt": "npx wrangler deployments list --json"
}
```
Any field omitted falls through to step 2 for that field only. A field set to the literal JSON `null` means "skip this phase for this project" — the resolver records source `manifest:null`. Underscore-prefixed keys (`_doc`, `_node_example`, etc.) are ignored as documentation/examples.
2. **Sniff `package.json` `scripts`** for `build`, `typecheck` or `tsc`, `lint`, `test`, `audit` or `security`. Tie-breaker when multiple scripts could match a phase: prefer `verify:<phase>` over `<phase>` over `<phase>:*` (wildcard tail). Do NOT pick `test` when `verify:test` exists; the operator's explicit verification surface always wins over the convenience alias.
3. **Sniff per-language toolchain files** if `package.json` is absent: `Cargo.toml` → `cargo build` / `cargo check` / `cargo clippy` / `cargo test` / `cargo audit`, `go.mod` → `go build ./...` / `go vet ./...` / `go test ./...`, `pyproject.toml` → `pyright` / `ruff check .` / `pytest`, `Gemfile` → `bundle exec rspec` / `bundle exec rubocop`.
4. **Unresolved** (source `ask-operator`): the repository has supplied no command for the field. Follow the missing-row handling below.
Each row shows the resolved command + its source (`manifest`, `sniff:<file>:<key>`, `manifest:null`, or `ask-operator`). The fenced block is the contract surface — every later phase reads from this resolved ladder, never from a hardcoded fallback.
A starter manifest is provided at `templates/verify-ladder.example.json`; copy it to `.claude/verify-ladder.json` and trim per project.
**Rows without a command.** Record an unmatched optional row as unavailable and keep running relevant checks. A manifest `null` deliberately skips its phase. Ask for missing information only when a check is essential to the requested outcome and repository evidence cannot supply it. Report such a result as unverified until the required evidence exists. Never invent a command or report a missing check as passed.
Phase 0 is done when the applicable checks and any gaps are clear.
**How Phases 1–5 use the ladder.** Each phase runs the command in its ladder row, exactly as resolved. The commands shown inside those phases are examples of what a row holds for a Node project (and one Python example); they are not defaults. Take pass or fail from the command's exit code. Shorten long output when you quote it, but do not pipe the command through `head` or `tail`, which hides the exit code.
**Before you rerun a failed phase**, say which kind of failure it was: a transient one (a timeout, a rate limit, a dropped connection) can be rerun as it is, a rejected input (a wrong flag, a missing field, a bad path) is repaired first and never resent unchanged, and a refusal by a hook or a policy is not rerun at all, so stop and ask the operator. A failure that fits none of the three is not transient: read its output and find the cause before the next run.
### Phase 1: Build Verification
Run the `build` command from the resolved ladder. Example for a default Node project:
```bash
# Resolved from package.json scripts.build:
npm run build
```
If build fails, STOP and fix before continuing. Done when the command exits 0.
### Phase 2: Type Check
Run the `typecheck` command from the resolved ladder. Examples of what that row holds:
```bash
# Node project, resolved from package.json scripts.typecheck:
npm run typecheck
# Python project, resolved from pyproject.toml:
pyright
```
Report every type error. Done when the command exits 0, or when each remaining error is listed under "Issues to Fix" in the report and the Types line says FAIL.
### Phase 3: Lint Check
Run the `lint` command from the resolved ladder. Examples of what that row holds:
```bash
# Node project, resolved from package.json scripts.lint:
npm run lint
# Python project, resolved from pyproject.toml:
ruff check .
```
Done when the command exits 0, or when the warning count is in the report and the Lint line says FAIL.
### Phase 4: Test Suite
Run the `test` command from the resolved ladder. Example for a default Node project:
```bash
# Resolved from package.json scripts.test:
npm test
```
Report:
- Total tests: X
- Passed: X
- Failed: X
- Coverage: X%, or `n/a`
This skill sets no coverage target. Report coverage only when the project's test command prints it, and compare it to a threshold only when the project defines one. Done when the command exits 0 and the counts above are copied from its output, not estimated.
### Phase 5: Secret and Debug-Leftover Scan
This phase is a quick scan, not a security review. It can catch a pasted key or a stray debug print in the lines this change added. It does not find injection, broken authentication, missing access checks or vulnerable dependencies on its own.
1. **Dependency audit, if the ladder has one.** Run the `security` command from the resolved ladder (for example `npm audit --audit-level=high`) and record its exit code. If the row has no command, handle it as "Rows without a command" in Phase 0 says.
2. **Scan the added lines.** `<base>` is the branch the PR will target, for example `origin/main`. The patterns below suit a JavaScript or TypeScript project; change them to fit the project's language.
```bash
# Added lines since the branch left <base>, committed or not
BASE=$(git merge-base <base> HEAD)
# Likely secrets: provider key shapes, private key blocks, key-like assignments
git diff "$BASE" | grep -E '^\+.*(sk-[A-Za-z0-9_-]{16,}|AKIA[0-9A-Z]{16}|BEGIN [A-Z ]*PRIVATE KEY)'
git diff "$BASE" | grep -iE '^\+.*(api[_-]?key|secret|password|token)[[:space:]]*[:=]'
# Debug leftovers
git diff "$BASE" | grep -E '^\+.*(console\.log|debugger)'
# Which file a hit came from
git diff "$BASE" -S'<matched text>' --name-only
```
Each hit is a line to read, not a verdict: a test fixture can match, and a secret in a shape these patterns do not cover will not. `git diff` does not show untracked files, so read any new untracked file yourself. Done when every hit is either removed or named in the report with its file and the reason it stays.
When the change touches authentication, input handling or secret storage, this scan is not enough. Ask for a real security review: the host's own security review command where it has one, or the `agent-skills:security-and-hardening` skill if that companion plugin is installed. If neither is available, write `Security review: not done` in the report so the scan is not read as one.
### Phase 6: Diff Review
```bash
# Everything this branch changed since it left <base> (the PR's target branch, as in Phase 5), committed or not
git diff --stat "$(git merge-base <base> HEAD)"
# New files git is not tracking yet
git status --short
```
Review each changed file for:
- Unintended changes
- Missing error handling
- Potential edge cases
Done when every file in the list is one you meant to change, or is reverted, or is named in the report as unexpected.
### Phase 7: Result + Completeness Gate
Phases 1–6 verify mechanism — build green, types clean, tests pass, no obvious secrets in the added lines, diff intentional. Phase 7 verifies outcome: did the work the operator actually asked for actually land? Mechanism passing while outcome is missing is the most expensive failure mode in this loop, because the green report invites a merge that doesn't deliver.
Two questions, both required to be `Yes`:
**1. Did the stated goal land? Yes/No + evidence.**
The stated goal is the goal as named at task start, not the goal as remembered now. If the operator asked "fix the bug where X happens", evidence is the bug no longer happening (failing test now passes, repro screenshot, manual verification). If they asked "add an admin button", evidence is the button visible and functional in the running UI. Build-green is not evidence of result — it is evidence of mechanism. Don't conflate.
**2. Did every promised step finish? Yes/No + list.**
Enumerate every step you said you would do — the recommendation list, the plan doc, the TodoWrite items, the commit-by-commit roadmap. Mark each Done or Skipped. If any are Skipped, name them and the reason. A "complete" verification with silently skipped promises is a trust violation, not a deliverable.
Both gates are independent: `Yes` on goal alone means a half-complete checklist that may break later; `Yes` on completeness alone means busywork that didn't deliver. Both must be `Yes` — even if the previous six phases all pass — or the work isn't done.
If either is `No`, the verification report goes back to the operator with the explicit gap, not on to PR. The operator decides whether the gap is acceptable to ship as-is or whether more work is required first. Never silently downgrade to "ready" because the mechanism phases looked good.
### Phase 8: Deploy Receipt (auto-deploy projects only)
For repos whose `verify-ladder.json` declares a `deploy_receipt` field — or whose sniff path detects an auto-deploy target — the verify is not complete until the deployed SHA matches the merge SHA and a healthcheck returns 200. Hand off to the `deploy-receipt` skill and treat its `Receipt status: COMPLETE` as the gate. If that skill is not installed, do the two checks yourself with the scripts below: the deployed SHA equals the merge SHA, and the project's health endpoint returns 200. Report COMPLETE only when both hold.
**Detection.** Run `bash "${CLAUDE_PLUGIN_ROOT}/scripts/detect-deploy-target.sh"` (source: `scripts/detect-deploy-target.sh`) at the repo root. Output is one of `railway` / `cloudflare` / `vercel` / `netlify` / `fly` / `appengine` / `apprunner` / `gha-deploy` / `none`. Anything except `none` triggers handoff to `deploy-receipt`; `none` means Phase 8 is skipped (no deploy seam exists).
**SHA extraction.** For the detected provider, `bash "${CLAUDE_PLUGIN_ROOT}/scripts/get-deployed-sha.sh" <provider>` (source: `scripts/get-deployed-sha.sh`) returns the currently-deployed SHA via the provider CLI; `bash "${CLAUDE_PLUGIN_ROOT}/scripts/get-deployed-sha.sh" --show-command <provider>` prints the pipeline shape without executing (useful for dry-runs and citation). `deploy-receipt` owns the receipt's other components (health endpoint, build artifact, on-incomplete modes) and Route B/C fallbacks.
INCOMPLETE receipts move to "Immediate operator action" in the close, never to "ready". Library-only / package-published repos skip this phase entirely (no deploy seam exists).
### Phase 9: Synthetic Checks (production-vs-baseline diff)
Phase 8 confirms the deploy seam. Phase 9 confirms the deployed surface matches the staging baseline on the dimensions that matter — endpoint payload shape, header presence, data freshness, routing correctness. A deploy can land with a matching SHA and a 200 healthcheck and still serve broken responses (stale data sources, dropped headers, regressed payloads). Phase 9 is the gate that catches that.
**When this rung runs:**
- ONLY after Phase 8 reports `Receipt status: COMPLETE`. An INCOMPLETE receipt blocks Phase 9 — fix the receipt gap first, then re-run.
- ONLY when the resolved ladder declares `synthetic_checks` as a non-null directory path (default: `synthetic-checks/`). A `null` field skips the rung silently. A missing field falls through to the directory sniff: if `synthetic-checks/` exists at the repo root with at least one `*.synthetic.*` file, the rung activates; otherwise it is recorded as "skipped — no synthetic-checks directory found".
**What the runner does:**
Run `node "${CLAUDE_PLUGIN_ROOT}/scripts/run-synthetic.mjs"` (source: `scripts/run-synthetic.mjs`); it encodes the lexical walk, interpreter map, env injection, and exit-code aggregation below. The prose is documentation, not the contract — when the two disagree, the script wins.
1. List every `*.synthetic.{sh,mjs,ts,py}` file in the resolved directory in lexical order.
2. For each file, set the input env vars: `BASE_URL` (production base from project config), `BASELINE_URL` (staging baseline from project config), `EXPECTED_SHA` (the merge SHA Phase 8 reported COMPLETE), `DEPLOY_BRANCH` (the deploy branch name), `RECEIPT_TIMESTAMP` (ISO-8601 of the receipt).
3. Invoke the file via the right interpreter (`bash` for `.sh`, `node` for `.mjs`, `tsx` for `.ts`, `python` for `.py`). Files with unrecognized extensions are skipped with a warning.
4. Capture stdout + stderr + exit code per file. On exit 0, the check passed. On any non-zero exit, the check failed and stdout is the operator-facing diff.
5. Aggregate: if every file exited 0, Phase 9 is `PASS`. If any file exited non-zero, Phase 9 is `FAIL — synthetic drift on <filenames>` and the captured diffs go into the verification report verbatim (no agent re-summarization). Exit code 2 with zero drift (every non-pass was a config error from the check itself) surfaces as `INCOMPLETE — config error` to distinguish "gate did not run" from "gate ran and found drift".
**Surfacing rule:**
A failed synthetic check surfaces as `INCOMPLETE — synthetic drift` at the same severity as a failed deploy receipt. The merge moves to "Immediate operator action" with the named drift and the diff payload. Do NOT downgrade synthetic drift to "warning" — the rung exists for exactly this gap (deploys that look healthy but serve broken responses).
**Anti-patterns specific to this rung:**
- **Smoke checks masquerading as synthetic checks.** A check that only verifies "endpoint returns 200" passes against a stale deploy. Synthetic checks MUST diff production against a baseline.
- **Hardcoded baseline URLs in the check.** Baseline lives in env (`BASELINE_URL`), not in the file. Hardcoding it breaks the convention and makes per-environment use impossible.
- **Re-summarizing the diff.** The captured stdout from a failed check is the operator-facing artifact. The agent does not re-write or shorten it.
- **Treating an absent directory as PASS.** No synthetic-checks directory means the rung is `skipped`, not `PASS`. The operator sees the absence in the resolved ladder.
See `synthetic-checks/README.md` for the file convention, the input/output contract, and a runnable sample (`example-version-endpoint.synthetic.sh`).
## Output Format
After running all phases, produce a verification report:
```
VERIFICATION REPORT
==================
Build: [PASS/FAIL/skipped]
Types: [PASS/FAIL/skipped] (X errors)
Lint: [PASS/FAIL/skipped] (X warnings)
Tests: [PASS/FAIL/skipped] (X/Y passed, coverage Z% or n/a)
Secret scan: [CLEAN/HITS] (X hits; dependency audit PASS/FAIL/skipped) — quick scan, not a security review
Diff: [X files changed]
Goal landed: [YES/NO] — <one-line evidence or gap>
All promised: [YES/NO] — <X of Y steps Done; list any Skipped>
Deploy: [COMPLETE/INCOMPLETE/skipped] — <SHA + health summary>
Synthetic: [PASS/FAIL/skipped] — <X of Y checks; failed: <filenames>>
Overall: [READY/NOT READY] for PR
Issues to Fix:
1. ...
2. ...
```
`Overall: READY` requires every line above to pass, including both Phase 7 gates. A `skipped` line counts as passing only when the ladder skipped it on purpose (the manifest set it to `null`) or the operator said to skip it; name each skip under "Issues to Fix" so the reader sees what did not run. Mechanism-green plus outcome-`No` is `NOT READY` — surface the gap, do not ship.
## Continuous Mode
In a long session, run the loop at checkpoints instead of once at the end:
- After each finished function or component: Phases 2 and 4 only (the resolved `typecheck` and `test` rows).
- Before moving to the next task, and before any PR: the full loop from Phase 0.
To run it, invoke this skill by name (`verification-loop`). The `/ship` command uses this loop as its verify step when fixing a single defect.
## Integration with Hooks
No hook runs this loop. The agent runs it because it read this text.
On hosts with a Stop gate, `hooks/typecheck-stop.mjs` can run one trusted project command from `CI_PROJECT_CHECK`. Choose a short test, lint or build command. A failure or timeout asks the agent to continue. When no project command is set, `CI_TYPECHECK_GATE=block` runs the project typecheck after TypeScript changes. Both checks are opt-in.