loop-discipline

loop-discipline is a skill for Claude Code from catpilotai/catpilot-ai-guardrails. It costs 45 tokens per session (1,199 once invoked), scanned A, original, MIT.

A set of rules for making software agents' tool-calling loops safer and more predictable. An agent loop is the repeated process of choosing a tool, observing the result, and trying the next step.

In plain words
What is it for?
Use it when building or reviewing retry logic, state managers, tool-health checks, multi-step agent workflows, or agent evaluations.
Why use it?
It limits endless retries, stale state, and false claims that an action worked. It also gives scheduled or nested workflows shared limits for calls, time, and cost.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: mentions subagents; mentions Codex; built for openclaw.

Part of the catpilot-guardrails plugin — 25 skills shipped together

Good fit Use it when building or reviewing retry logic, state managers, tool-health checks, multi-step agent workflows, or agent evaluations.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/catpilotai/catpilot-ai-guardrails/loop-discipline
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.

Any agent
npx skills add catpilotai/catpilot-ai-guardrails --skill loop-discipline
Clone the repo
git clone --depth 1 https://github.com/catpilotai/catpilot-ai-guardrails

Made for: Claude Code.

Or install catpilot-guardrails, the plugin that ships this one along with the rest of its 25 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for loop-discipline

README.md
[![agentmods](https://agentmods.dev/badge/skills/catpilotai/catpilot-ai-guardrails/loop-discipline/github.svg)](https://agentmods.dev/skills/catpilotai/catpilot-ai-guardrails/loop-discipline)
Your own site
<a href="https://agentmods.dev/skills/catpilotai/catpilot-ai-guardrails/loop-discipline"><img src="https://agentmods.dev/badge/skills/catpilotai/catpilot-ai-guardrails/loop-discipline/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for loop-discipline

Your own site · 80×15
<a href="https://agentmods.dev/skills/catpilotai/catpilot-ai-guardrails/loop-discipline"><img src="https://agentmods.dev/badge/skills/catpilotai/catpilot-ai-guardrails/loop-discipline.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 45 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,199 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00045 $0.01199
Opus 5.5 $0.00018 $0.00480
Sonnet 5.5 $0.00009 $0.00240
Haiku 4.5 $0.00005 $0.00120

Measured 10d ago against content hash 9825d361ffa6, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

loop-discipline 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 10d 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.

src/skills/agentic/loop-discipline/SKILL.md · 127 lines

How it starts

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

Baseline

Applies when: Building, debugging, or evaluating agent tool-calling loops, retry wrappers, state/context managers, tool-health circuit breakers, or agent benchmark suites.

Always:

  • Cap per-tool retries (max_attempts = 3) and require an external-state verifier (checking file diff hash, schema version, ticket state, or DOM snapshot—never the model's self-report) to prove the world changed before granting another retry.
  • Enforce a shared, workflow-scoped retry budget across nested sub-agents, crons, and step wrappers, plus jittered exponential backoff (max_calls, max_cost_usd, max_duration_sec).
  • Invalidate cached context and force a fresh state re-read after every state-changing tool call (file_write, git_commit, package_install, db_migrate, browser_click).
  • Probe failing tools with capped exponential backoff (min(2 ** failures, 3600)) and reset failure counts on recovery rather than permanently blacklisting a tool for the life of the process.
  • Evaluate and report agent loop quality using pass@1 alongside verifier evidence traces; reserve pass@k (k > 1) strictly for research diagnostics.

Never:

  • Retry a tool call up to an arbitrary loop limit based solely on the model claiming "trying again" without verifying external state progress.
  • Continue executing subsequent steps of a plan against a pre-mutation context snapshot after a mutating tool call has run.
  • Permanently cache a "tool is broken" verdict with no re-probe mechanism, or headline pass@100 as evidence of production reliability.

Open the full component before acting: it has the examples, the remediation steps, and the detection patterns.

Why

Uncapped retries launder one bug into seven partial writes and orphaned resources. Meanwhile, nested retry layers (cron retry × sub-agent retry × tool retry) multiply into retry storms unless governed by a single workflow-wide budget. Finally, acting on stale context after a file write or migration is the single most common cause of cascading edits in long-horizon coding and ops loops.

Read the full file on GitHub · 127 lines

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. 10d ago First seen · 127 lines · 45 tokens per session scan A 9825d361ffa6

Subscribe to this mod's changes

loop-discipline is a skill published in the GitHub repository catpilotai/catpilot-ai-guardrails (2 stars, last pushed 8d ago), licensed MIT. It adds 45 tokens to every session and 1,199 once invoked, about $0.0002 per session on Opus 5.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-10-29.

Related

loop-discipline compared with skills from other repositories

loop-discipline next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
loop-disciplinecatpilotai/catpilot-ai-guardrailsSkill28d agoMITA45Claude Code
dcf-modelNousResearch/hermes-agentSkill262ktodayMITA14Claude Code, Codex
baoyu-article-illustratorNousResearch/hermes-agentSkill262ktodayMITA18Claude Code, Codex
flash-attentionNousResearch/hermes-agentSkill262ktodayMITA14Claude Code, Codex
subagent-driven-developmentNousResearch/hermes-agentSkill262ktodayMITA17Claude Code, Codex
mcporterNousResearch/hermes-agentSkill262ktodayMITA16Claude Code, Codex
mem0-vercel-ai-sdkmem0ai/mem0Skill69kyesterdayApache-2.0A146Claude Code, Codex