codex-loop

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

An automated review loop that checks the changes on a feature branch against a base branch, fixes real problems, and repeats until two reviews find nothing.

In plain words
What is it for?
Use it to run repeated Codex code reviews, repair findings with regression tests, and stop after two consecutive clean reviews.
Why use it?
It reduces the chance that code issues remain after one review and keeps applying fixes without requiring the developer to supervise each round.

Command for Claude Code

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

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

Good fit Use it to run repeated Codex code reviews, repair findings with regression tests, and stop after two consecutive clean reviews.

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

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

Your own site · 80×15
<a href="https://agentmods.dev/commands/runnithan/claudex-setup/codex-loop"><img src="https://agentmods.dev/badge/commands/runnithan/claudex-setup/codex-loop.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 54 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,114 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.00054 $0.07114
Opus 5.5 $0.00022 $0.02846
Sonnet 5.5 $0.00011 $0.01423
Haiku 4.5 $0.00005 $0.00711

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

Security

Grade B, and why

codex-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 15d 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. Do not read `.planning/codex-loop/`. If a
.claude/commands/codex-loop.md · 500 lines

How it starts

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

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

Review the codebase with Codex, fix what it finds, and keep looping until Codex 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/codex-loop.md) and STATE.md before continuing. Compaction keeps only the start of a long command.

/claude-loop is the same loop with a headless Claude reviewer. Keep the two in step: a fix to the loop's logic belongs in both.

Requires the Codex CLI, authenticated, with codex review available (codex review --help).

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.

It runs on a budget and pauses at a healthy point. A repo sweep costs at least two reviews per area at 10 to 15 minutes each, so a whole repo is several invocations, not one. One invocation runs at most --max-rounds N rounds (default 10). The check runs only between rounds, after the round's fixes are committed and its bookkeeping written, so a pause never leaves work half done. Invoking the command again resumes from the state file with a fresh budget.

Read the full file on GitHub · 500 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. 15d ago Changed · +29 lines 1b32646620e8
  2. 16d ago Changed · +246 lines · +18 tokens per session scan A → B 338a9354d5be
  3. 26d ago Changed · -1 lines d32604c94043
  4. 1mo ago Changed · +3 lines ec42c4ce014d
  5. 1mo ago First seen · 223 lines · 36 tokens per session scan A d3de77076962

Subscribe to this mod's changes

codex-loop is a command published in the GitHub repository runnithan/claudex-setup (1 stars, last pushed yesterday), licensed MIT. It adds 54 tokens to every session and 7,114 once invoked, about $0.0002 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-08-31.