loop

A tool for repeating an action a limited number of times during the current session, with a check after each attempt. It stops when the check passes or when the declared attempt limit is reached.

In plain words
What is it for?
Use it for jobs such as changing code until linting or tests pass. It can create a loop plan, run the action with a verifier, show loop status, inspect results, and stop a loop.
Why use it?
It removes manual repetition for tasks that need several try-and-check cycles. The limit ensures the agent does not continue retrying indefinitely.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/sethgammon/citadel/loop
Any agent
npx skills add SethGammon/Citadel --skill loop
Clone the repo
git clone --depth 1 https://github.com/SethGammon/Citadel

Made for: Claude Code, Codex.

Per session 58 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,400 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00058 $0.01400
Opus 5 $0.00029 $0.00700
Sonnet 5 $0.00012 $0.00280
Haiku 4.5 $0.00006 $0.00140

Measured 2d ago against content hash 635f89ede743, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

loop scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/loop/SKILL.md · 189 lines

How it starts

The opening of the file, as written. The whole thing — 189 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/loop -- Bounded Foreground Loop

Orientation

Use when: the user wants a visible repeat-until-pass cycle inside the current session, such as "loop until lint passes" or "try this up to three times and stop if tests still fail."

Don't use when: the work should run unattended across sessions (/daemon), on a clock (/schedule), on file changes (/watch), or as a metric-driven optimization experiment (/experiment).

Commands

Command Behavior
/loop status Show all known Citadel loops with active/stopped grouping.
/loop inspect {id} Show one loop's contract, verifier, budget, runs, and stop reason.
/loop templates List built-in loop templates.
/loop plan --template {name} Create a loop contract from a template.
/loop run "{action}" --verify "{command}" --max {N} Run a bounded foreground loop.
/loop stop {id} Mark a loop stopped.

Protocol

Step 1: Classify the loop

Determine which kind of loop the user requested:

User intent Route
Repeat within this active session /loop
Continue campaign across sessions /daemon
Run on a schedule /schedule
Watch PR checks/reviews /pr-watch
Watch files or marker comments /watch
Optimize a numeric metric /experiment

If another route is clearly better, say so and route there.

Step 2: Require a verifier

A /loop run must have an explicit verifier. Explicit means the user supplied --verify "<command>" or an equally concrete verifier command in plain language. Do not infer a verifier from words like "lint", "test", "until it works", or "fix until passing." If the verifier is missing, ask for it before executing and do not run loop-runner.js, shell commands, or manual repair steps.

Accept examples like:

--verify "npm run lint"
--verify "npm run test"
--verify "node scripts/operating-proof.js --write"

If missing, respond in this shape:

/loop needs an explicit verifier before it can run. Please provide one, for example:
--verify "npm run lint"

I will not run the loop until the verifier is explicit.

Read the full file on GitHub · 189 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 189 lines · 58 tokens per session scan A 635f89ede743

Subscribe to this mod's changes

loop is a skill published in the GitHub repository SethGammon/Citadel (912 stars, last pushed 5d ago), licensed MIT. It adds 58 tokens to every session and 1,400 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

debrief

This skill should be used when the user asks to "debrief", "record what happened", "session summary", "write a debrief", or wants to capture session activity (commits, task state changes, decisions, issues) into a structured record for the next session.

spacedock-dev/spacedock · 59 tokens

refit

This skill should be used when the user asks to "refit a workflow", "upgrade a workflow", "update workflow scaffolding", or wants to bring an existing workflow's scaffolding files up to date with the current Spacedock version.

spacedock-dev/spacedock · 52 tokens

fo-dispatch-recovery

Claude dispatch failure recovery — Break-Glass Manual Dispatch (the manual Agent() template) and Context Budget Failure/Dead Ensign Handling (the budget-unavailable stderr conditions, the recovery clause, dead-ensign bookkeeping). Read ONLY at its resident triggers inside claude-fo-dispatch.md — a non-zero or…

spacedock-dev/spacedock · 137 tokens

present-gate

First-officer gate-presentation rendering — the captain-facing gate-review template and assembly rules, including workflow-owned finding labels. Invoke at the gate point after the FO has decided a stage must be presented.

spacedock-dev/spacedock · 44 tokens

fo-status-viewer

First-officer status query/mutate/display surface — the status command flag docs, --set field docs, canonical captain-facing invocations, the Captain-Facing State Display rendering, and the GitHub-issue-filing approval gate. Invoke at the first ad-hoc status question, --set mutation, --next-id/--resolve lookup, or…

spacedock-dev/spacedock · 87 tokens

agent-workflow-playbook

AI Agent Workflow & Skill Architecture Guide — turn expert work into measurable, reusable agent systems. Covers workflow discovery, skill decomposition, harness design, evaluation, human escalation, observability, cost control, and multi-agent orchestration. Includes a measured marketing-delivery case: 15 people × 3–4…

Gingiris-1031/gingiris-skills · 83 tokens