claude-loop

claude-loop is a command for Claude Code from runnithan/claudex-setup. It costs 72 tokens per session (7,897 once invoked), scanned B, original, MIT.

An automated code-review loop that asks a separate headless Claude session to review a repository or branch diff, fixes real findings with regression tests, and repeats the review. It stops after every area in scope has been reported clean twice in succession.

In plain words
What is it for?
Use it to review a whole codebase, selected paths, or a branch compared with a base branch, then apply fixes and regression tests without pausing between rounds.
Why use it?
It reduces the chance of stopping after one review pass or overlooking problems introduced by a fix. It also provides an independent review perspective and keeps checking until the specified clean condition is met.

Command for Claude Code

Written for Claude Code: argument-hint in frontmatter. Also seen: reads .claude/ paths; mentions CLAUDE.md; mentions subagents.

Part of the claudex-setup plugin — 3 skills, 24 commands, 6 agents, 1 hook shipped together

Good fit Use it to review a whole codebase, selected paths, or a branch compared with a base branch, then apply fixes and regression tests without pausing between rounds.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/runnithan/claudex-setup/claude-loop
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.

Clone the repo
git clone --depth 1 https://github.com/runnithan/claudex-setup

Made for: Claude Code.

Or install claudex-setup, the plugin that ships this one along with the rest of its 3 skills, 24 commands, 6 agents, 1 hook.

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 claude-loop

README.md
[![agentmods](https://agentmods.dev/badge/commands/runnithan/claudex-setup/claude-loop/github.svg)](https://agentmods.dev/commands/runnithan/claudex-setup/claude-loop)
Your own site
<a href="https://agentmods.dev/commands/runnithan/claudex-setup/claude-loop"><img src="https://agentmods.dev/badge/commands/runnithan/claudex-setup/claude-loop/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 claude-loop

Your own site · 80×15
<a href="https://agentmods.dev/commands/runnithan/claudex-setup/claude-loop"><img src="https://agentmods.dev/badge/commands/runnithan/claudex-setup/claude-loop.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 72 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 7,897 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. 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.00072 $0.07897
Opus 5.5 $0.00029 $0.03159
Sonnet 5.5 $0.00014 $0.01579
Haiku 4.5 $0.00007 $0.00790

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

Security

Grade B, and why

claude-loop scanned grade B with 1 finding 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 6d 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.

Unrestricted tool accessmediumExcessive agency

A wildcard tool grant or "run any command" leaves no least-privilege boundary at all.

or run any command that writes. Use Read, Grep, Glob and read-only git
.claude/commands/claude-loop.md · 519 lines

How it starts

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

/claude-loop: review, fix, repeat until clean

Review the codebase with an independent Claude reviewer, fix what it finds, and keep looping until the reviewer comes back clean twice in a row on everything in scope. Run autonomously. Do not report back between rounds and do not ask permission to continue; the owner starts it and walks away. This overrides any session protocol that asks for per-step approval or a per-task report (keep its evidence habits). Questions for the owner are collected as you go and asked once, in the §7 report.

After any compaction, re-read this whole file (a user-scope install lives at ~/.claude/commands/claude-loop.md) and STATE.md before continuing. Compaction keeps only the start of a long command.

This is /codex-loop with the reviewer swapped for a headless claude -p session. It costs Anthropic usage instead of Codex usage. What it gives up is the differently-trained reviewer, so every rule below about reviewer independence exists to win back as much of that as possible.

Scope

  • Repo mode, the default. The whole codebase as it stands at HEAD, one area per round; --scope PATH... limits it to those paths. In §0, split the tracked source into areas along directory lines, each roughly 3,000 to 8,000 lines of non-test source, ordered by risk (auth, payments, personal data and retention, migrations first). Tests are reviewed with the code they cover. Skip generated, vendored and lock files, fixtures, binary assets and docs. Stay on an area until it has two consecutive clean reviews, then move on. When every area is done, run the closing review: diff mode over the loop's own commits (<started>...HEAD) until two consecutive clean rounds, which catches a fix in one area that broke another. Skip it if the loop committed nothing.
  • Diff mode, --base REF. Only what the current branch adds on top of REF (a branch or a SHA), the right check before merging. REF is the comparison point, not the branch under review: run it from the feature branch.

Read the full file on GitHub · 519 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. 6d ago Changed · +29 lines 8e67f0c6db2d
  2. 7d ago First seen · 490 lines · 72 tokens per session scan B 5de29eb7dff0

Subscribe to this mod's changes

claude-loop is a command published in the GitHub repository runnithan/claudex-setup (1 stars, last pushed 6d ago), licensed MIT. It adds 72 tokens to every session and 7,897 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it B with 1 finding (unrestricted tool access). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-10-04.