Back to search
hamel-review
MarketplaceWorks with Claude CodeGitHub
Claude Code plugin: automated code review loop with Codex
Safety scan
A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.
Checked today
Badge for your README
Markdown
[](/listings/hamelsmu-claude-review-loop)HTML
<a href="/listings/hamelsmu-claude-review-loop"><img src="/api/listings/hamelsmu-claude-review-loop/badge.svg" alt="findsafeskills safety rating" /></a>Install
Install instructions from the README
As written by the repo's author. findsafeskills has not verified these steps.
From the CLI:
claude plugin marketplace add hamelsmu/claude-review-loop claude plugin install review-loop@hamel-review
Or from within a Claude Code session:
/plugin marketplace add hamelsmu/claude-review-loop /plugin install review-loop@hamel-review
What was scanned
The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.
.claude-plugin/marketplace.json · Manifest · 22 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
- {
- "name": "hamel-review",
- "owner": {
- "name": "Hamel Husain"
- },
- "metadata": {
- "description": "Automated code review loop plugin for Claude Code"
- },
- "plugins": [
- {
- "name": "review-loop",
- "source": "./plugins/review-loop",
- "description": "Automated code review loop: Claude implements, Codex reviews independently, Claude addresses feedback",
- "author": {
- "name": "Hamel Husain"
- },
- "repository": "https://github.com/hamelsmu/claude-review-loop",
- "license": "MIT",
- "keywords": ["code-review", "codex", "quality", "automation"]
- }
- ]
- }
README.md · README · 138 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
- # review-loop
- A Claude Code plugin that adds an automated code review loop to your workflow.
- ## What it does
- When you use `/review-loop`, the plugin creates a two-phase lifecycle:
- 1. **Task phase**: You describe a task, Claude implements it
- 2. **Review phase**: When Claude finishes, the stop hook prepares a [Codex](https://github.com/openai/codex) runner script and blocks exit. Claude then runs Codex directly (with output streaming to the user) and addresses the review feedback.
- The result: every task gets an independent second opinion before you accept the changes, and you can watch the review happen in real time.
- <img width="2284" height="1959" alt="memelord_meme_2026-02-22 (3)" src="https://github.com/user-attachments/assets/75af1351-47e6-4b70-a50a-9b3311773be7" />
- ## Review coverage
- The plugin spawns up to 4 parallel Codex sub-agents, depending on project type:
- | Agent | Always runs? | Focus |
- |-------|-------------|-------|
- | **Diff Review** | Yes | `git diff` — code quality, test coverage, security (OWASP top 10) |
- | **Holistic Review** | Yes | Project structure, documentation, AGENTS.md, agent harness, architecture |
- | **Next.js Review** | If `next.config.*` or `"next"` in `package.json` | App Router, Server Components, caching, Server Actions, React performance |
- | **UX Review** | If `app/`, `pages/`, `public/`, or `index.html` exists | Browser E2E via [agent-browser](https://agent-browser.dev/), accessibility, responsive design |
- After all agents finish, Codex deduplicates findings and writes a single consolidated review to `reviews/review-<id>.md`.
- ## Requirements
- - [Claude Code](https://claude.ai/code) (CLI)
- - `jq` — `brew install jq` (macOS) / `apt install jq` (Linux)
- - [Codex CLI](https://github.com/openai/codex) — `npm install -g @openai/codex`
- ### Codex multi-agent
- This plugin uses Codex [multi-agent](https://developers.openai.com/codex/multi-agent/) to run parallel review agents. The `/review-loop` command automatically enables it in `~/.codex/config.toml` on first use.
- To set it up manually instead:
- ```toml
- # ~/.codex/config.toml
- [features]
- multi_agent = true
- ```
- ## Installation
- From the CLI:
- ```bash
- claude plugin marketplace add hamelsmu/claude-review-loop
- claude plugin install review-loop@hamel-review
- ```
- Or from within a Claude Code session:
- ```
- /plugin marketplace add hamelsmu/claude-review-loop
- /plugin install review-loop@hamel-review
- ```
- ## Updating
- ```bash
- claude plugin marketplace update hamel-review
- claude plugin update review-loop@hamel-review
- ```
- ## Usage
- ### Start a review loop
- ```
- /review-loop Add user authentication with JWT tokens and test coverage
- ```
- Claude will implement the task. When it finishes, the stop hook:
- 1. Prepares a Codex runner script and prompt file
- 2. Blocks Claude's exit with instructions to run the review
- 3. Claude runs `bash .claude/review-loop-run-codex.sh` — Codex output streams to the user
- 4. Codex writes findings to `reviews/review-<id>.md`
- 5. Claude reads the review, addresses items it agrees with, then stops
- ### Cancel a review loop
- ```
- /cancel-review
- ```
- ## How it works
- The plugin uses a **Stop hook** — Claude Code's mechanism for intercepting agent exit. When Claude tries to stop:
- 1. The hook reads the state file (`.claude/review-loop.local.md`)
- 2. If in `task` phase: writes a runner script and prompt file, transitions to `addressing`, blocks exit with instructions for Claude to run Codex
- 3. If in `addressing` phase: allows exit and cleans up
- State is tracked in `.claude/review-loop.local.md` (add to `.gitignore`). Reviews are written to `reviews/review-<id>.md`.
- ## File structure
- ```
- claude-review-loop/
- ├── .claude-plugin/
- │ └── plugin.json # Plugin manifest
- ├── commands/
- │ ├── review-loop.md # /review-loop slash command
- │ └── cancel-review.md # /cancel-review slash command
- ├── hooks/
- │ ├── hooks.json # Stop hook registration (30s timeout)
- │ └── stop-hook.sh # Core lifecycle engine
- ├── scripts/
- │ └── setup-review-loop.sh # Argument parsing, state file creation
- ├── AGENTS.md # Agent operating guidelines
- ├── CLAUDE.md # Symlink to AGENTS.md
- └── README.md
- ```
- ## Configuration
- The stop hook timeout is set to 30 seconds in `hooks/hooks.json`. The hook itself is fast (it only writes files and returns a block decision); Codex runs separately via Claude's Bash tool.
- ### Environment variables
- | Variable | Default | Description |
- |----------|---------|-------------|
- | `REVIEW_LOOP_CODEX_FLAGS` | `--dangerously-bypass-approvals-and-sandbox` | Flags passed to `codex`. Set to `--sandbox workspace-write` for safer sandboxed reviews. |
- ### Telemetry
- Execution logs are written to `.claude/review-loop.log` with timestamps, codex exit codes, and elapsed times. This file is gitignored.
- ## Credits
- Inspired by the [Ralph Wiggum plugin](https://github.com/anthropics/claude-code/tree/main/plugins/ralph-wiggum) and [Ryan Carson's compound engineering loop](https://x.com/ryancarson/article/2016520542723924279).
plugins/review-loop/hooks/stop-hook.sh · Bundled script · 444 lines · 1 finding marked
- #!/usr/bin/env bash
- # Review Loop — Stop Hook
- #
- # Two-phase lifecycle:
- # Phase 1 (task): Claude finishes work → hook prepares Codex runner script → blocks exit
- # Phase 2 (addressing): Claude runs Codex, addresses review → hook verifies review exists → allows exit
- #
- # On any error, default to allowing exit (never trap the user in a broken loop).
- #
- # Environment variables:
- # REVIEW_LOOP_CODEX_FLAGS Override codex flags (default: --dangerously-bypass-approvals-and-sandbox)
- Note: Starts a coding agent with its permission prompts off
- Line 11 on GitHub
- LOG_FILE=".claude/review-loop.log"
- log() {
- mkdir -p "$(dirname "$LOG_FILE")"
- echo "[$(date -u +"%Y-%m-%dT%H:%M:%SZ")] $*" >> "$LOG_FILE"
- }
- trap 'log "ERROR: hook exited via ERR trap (line $LINENO)"; rm -f .claude/review-loop.lock .claude/review-loop-run-codex.sh .claude/review-loop-codex-prompt.txt .claude/review-loop-retries; printf "{\"decision\":\"approve\"}\n"; exit 0' ERR
- # Consume stdin (hook input JSON) — must read to avoid broken pipe
- HOOK_INPUT=$(cat)
- STATE_FILE=".claude/review-loop.local.md"
- # No active loop → allow exit
- if [ ! -f "$STATE_FILE" ]; then
- printf '{"decision":"approve"}\n'
- exit 0
- fi
- # Parse a field from the YAML frontmatter
- parse_field() {
- sed -n "s/^${1}: *//p" "$STATE_FILE" | head -1
- }
- ACTIVE=$(parse_field "active")
- PHASE=$(parse_field "phase")
- REVIEW_ID=$(parse_field "review_id")
- # Not active → clean up and exit
- if [ "$ACTIVE" != "true" ]; then
- rm -f "$STATE_FILE"
- printf '{"decision":"approve"}\n'
- exit 0
- fi
- # Validate review_id format to prevent path traversal
- if ! echo "$REVIEW_ID" | grep -qE '^[0-9]{8}-[0-9]{6}-[0-9a-f]{6}$'; then
- log "ERROR: invalid review_id format: $REVIEW_ID"
- rm -f "$STATE_FILE"
- printf '{"decision":"approve"}\n'
- exit 0
- fi
- # ── Project type detection ────────────────────────────────────────────────
- detect_nextjs() {
- [ -f "next.config.js" ] || [ -f "next.config.mjs" ] || [ -f "next.config.ts" ] || \
- ([ -f "package.json" ] && grep -q '"next"' package.json 2>/dev/null)
- }
- detect_browser_ui() {
- # Has HTML/JSX/TSX files in app/ or pages/ or src/ directories, or has a public/ dir
- [ -d "app" ] || [ -d "pages" ] || [ -d "src/app" ] || [ -d "src/pages" ] || \
- [ -d "public" ] || [ -f "index.html" ]
- }
- # ── Build the multi-agent review prompt ───────────────────────────────────
- build_review_prompt() {
- local REVIEW_FILE="$1"
- local IS_NEXTJS=false
- local HAS_UI=false
- detect_nextjs && IS_NEXTJS=true
- detect_browser_ui && HAS_UI=true
- log "Project detection: nextjs=$IS_NEXTJS, browser_ui=$HAS_UI"
- # ── Preamble ──
- cat << PREAMBLE_EOF
- You are orchestrating a thorough, independent code review of recent changes in this repository.
- Use multi-agent to run the following review agents IN PARALLEL. Each agent should return its findings as structured text (not write to files). After ALL agents complete, consolidate their findings into a single deduplicated review file.
- IMPORTANT: Spawn one agent per review path below. Wait for all agents to finish. Then deduplicate overlapping findings and write the consolidated review to: ${REVIEW_FILE}
- PREAMBLE_EOF
- # ── Agent 1: Diff Review ──
- cat << 'DIFF_EOF'
- ---
- AGENT 1: Diff Review (focus on uncommitted and recently committed changes ONLY)
- Run `git diff` and `git diff --cached` to see all uncommitted changes. Also run `git log --oneline -5` and `git diff HEAD~5` for recently committed work. Focus your review EXCLUSIVELY on this changed code.
- Review criteria for changed code:
- Code Quality:
- - Is the changed code well-organized, modular, and readable?
- - Does it follow DRY principles — no copy-pasted blocks that should be abstracted?
- - Are names (variables, functions, files) clear and consistent with the codebase?
- - Are abstractions at the right level — not over-engineered, not under-abstracted?
- - Is there unnecessary complexity that could be simplified?
- Test Coverage:
- - Does every new function/endpoint/component have corresponding tests?
- - Are edge cases covered: empty inputs, nulls, boundary values, error paths?
- - Are tests isolated, deterministic, and fast?
- - Do tests verify behavior (not implementation details)?
- - For bug fixes: is there a regression test that would have caught the original bug?
- Security:
- - Input validation: are all user inputs validated and sanitized before use?
- - Authentication/authorization: are auth checks present on all protected routes/actions?
- - Injection: any risk of SQL injection, XSS, command injection, path traversal?
- - Secrets: are any credentials, API keys, or tokens hardcoded or logged?
- - OWASP Top 10: check for broken access control, cryptographic failures, insecure design, security misconfiguration, vulnerable dependencies, SSRF
- - Are error messages safe (no stack traces or internal details leaked to users)?
- For each issue: return file path, line number, severity (critical/high/medium/low), category, description, and suggested fix.
- DIFF_EOF
- # ── Agent 2: Holistic Review ──
- cat << 'HOLISTIC_EOF'
- ---
- AGENT 2: Holistic Review (evaluate overall project structure and agent readiness)
- Read the full project directory structure, key config files, README, and any AGENTS.md / CLAUDE.md files. This is NOT about individual line changes — it's about whether the project is well-structured for maintainability and agent-driven development.
- Review criteria for the whole project:
- Code Organization & Modularity:
- - Is the project structure logical and navigable? Can a new developer (or agent) find things?
- - Are concerns properly separated (data access, business logic, presentation, config)?
- - Are there god files/functions that do too much and should be split?
- - Is shared code properly extracted into reusable modules?
- - Are import paths clean (absolute imports, no deep relative paths)?
- Documentation & Agent Harness:
- - Does every major directory have an AGENTS.md with operating guidelines for agents?
- - Is there a CLAUDE.md symlinked to each AGENTS.md for Claude Code compatibility?
- - Do AGENTS.md files document: conventions, file purposes, testing patterns, common pitfalls?
- - Is there telemetry/observability instrumentation (logging, metrics, tracing)?
- - Is there a type system in use (TypeScript, Python type hints, etc.) with proper coverage?
- - Are there proper constraints and guardrails so agents working on the code are set up for success?
- - Are environment variables documented and validated at startup?
- - Are there clear boundaries between server-only and client-safe code?
- Architecture:
- - Is the dependency graph clean (no circular dependencies)?
- - Are external integrations properly abstracted behind interfaces?
- - Is configuration centralized rather than scattered?
- - Is error handling consistent across the codebase?
- For each issue: return file path (or directory), severity (critical/high/medium/low), category, description, and suggested fix.
- HOLISTIC_EOF
- # ── Agent 3: Next.js Best Practices (conditional) ──
- if [ "$IS_NEXTJS" = "true" ]; then
- cat << 'NEXTJS_EOF'
- ---
- AGENT 3: Next.js & React Best Practices Review
- This is a Next.js project. Review the codebase against these specific patterns:
- App Router & Server Components:
- - Are Server Components used by default? Is 'use client' only added when interactivity is needed?
- - Is data fetched in Server Components, not Client Components?
- - Are Suspense boundaries used for streaming slow data sources?
- - Are file conventions correct: layout.tsx, page.tsx, loading.tsx, error.tsx, not-found.tsx?
- - Are searchParams and params handled as Promises (await searchParams / await params)?
- - Is generateStaticParams() used to pre-render known dynamic routes?
- - Is generateMetadata() used for SEO-critical pages?
- - Is notFound() called for missing resources instead of returning null?
- Data Fetching & Caching:
- - Are parallel data fetches used (Promise.all) instead of sequential waterfalls?
- - Is cache strategy appropriate: no-store for fresh data, force-cache for static, revalidate for ISR?
- - Are cache tags used for fine-grained invalidation after mutations?
- - Is React.cache() used to deduplicate queries within a single request?
- Server Actions & Mutations:
- - Are Server Actions validated and auth-checked as if they were public API endpoints?
- - Is revalidateTag/revalidatePath called after mutations to invalidate cache?
- - Is after() used for non-blocking post-response work (logging, analytics)?
- Performance & Bundle Size:
- - No barrel file imports — import directly from source paths?
- - Is next/dynamic with { ssr: false } used for heavy client-only components?
- - Are non-critical libraries (analytics, error tracking) deferred until after hydration?
- - Are heavy bundles preloaded on user intent (hover/focus)?
- - Is data minimized across the RSC boundary (only pass fields client needs)?
- React Performance:
- - Is derived state calculated during render, not in effects?
- - Are expensive computations memoized appropriately?
- - Is useTransition used for non-urgent updates?
- - No unnecessary useEffect for things that belong in event handlers?
- - Are stable callback references used (functional setState, refs) to avoid re-render churn?
- - Is content-visibility: auto used for long lists?
- - Are inline scripts used to set client data before hydration (prevent FOUC)?
- For each issue: return file path, line number, severity (critical/high/medium/low), category, description, and suggested fix.
- NEXTJS_EOF
- fi
- # ── Agent 4: UX & Browser Testing (conditional) ──
- if [ "$HAS_UI" = "true" ]; then
- cat << 'UX_EOF'
- ---
- AGENT (UX): Browser-Based UX Review (SKIP if you cannot access a running dev server)
- If the project has a running dev server, use agent-browser to test the UI.
- Install agent-browser if needed: npm install -g agent-browser (or: brew install agent-browser)
- Testing checklist:
- - Navigate to all major routes/pages
- - Test key user workflows end-to-end (signup, login, CRUD operations, etc.)
- - Take screenshots at desktop (1280x720) and mobile (375x812) viewports
- - Check for: broken layouts, missing error states, loading states, empty states
- - Verify accessibility: keyboard navigation, focus indicators, color contrast
- - Check responsive design at multiple breakpoints
- - Verify forms have proper validation feedback
- - Check that error messages are user-friendly
- If the dev server is not running or you cannot access it, skip this agent and note that UX testing was not performed.
- For each issue: return screenshot description, severity, category, description, and suggested fix.
- UX_EOF
- fi
- # ── Consolidation instructions ──
- cat << CONSOLIDATION_EOF
- ---
- CONSOLIDATION INSTRUCTIONS (after all agents complete):
- 1. Collect all findings from all agents
- 2. Deduplicate: if multiple agents flagged the same issue, keep the most detailed version
- 3. Organize all findings by severity (critical first, then high, medium, low)
- 4. For each finding, include:
- - File path and line number (or directory for structural issues)
- - Severity: critical / high / medium / low
- - Category: which review path found it (Diff, Holistic, Next.js, UX)
- - Description: clear explanation
- - Suggested fix: concrete, actionable recommendation
- 5. End with a summary: total issues, breakdown by severity, agents that ran, overall assessment
- 6. Write the COMPLETE consolidated review to: ${REVIEW_FILE}
- IMPORTANT: You MUST create the file ${REVIEW_FILE} with the full review.
- CONSOLIDATION_EOF
- }
- # ── Rewrite state file to update phase (atomic, no fragile sed regex) ──────
- transition_phase() {
- local new_phase="$1"
- local TEMP_FILE="${STATE_FILE}.tmp.$$"
- # Rewrite: replace 'phase: <anything>' with 'phase: <new_phase>'
- # Use awk for robustness — handles whitespace variants, no anchoring issues
- awk -v np="$new_phase" '{
- if ($0 ~ /^phase:/) { print "phase: " np }
- else { print }
- }' "$STATE_FILE" > "$TEMP_FILE"
- mv "$TEMP_FILE" "$STATE_FILE"
- # Verify the transition succeeded
- local CHECK
- CHECK=$(parse_field "phase")
- if [ "$CHECK" != "$new_phase" ]; then
- log "ERROR: phase transition failed (expected=$new_phase, got=$CHECK)"
- return 1
- fi
- log "Phase transitioned to: $new_phase"
- return 0
- }
- case "$PHASE" in
- task)
- # ── Phase 1 → 2: Prepare Codex review for Claude to run directly ────
- # Instead of running Codex inside this hook (which blocks Claude and
- # hides all output), we write the prompt and a runner script, then tell
- # Claude to execute it via Bash so Codex output streams to the user.
- REVIEW_FILE="reviews/review-${REVIEW_ID}.md"
- mkdir -p reviews
- CODEX_PROMPT=$(build_review_prompt "$REVIEW_FILE")
- CODEX_FLAGS="${REVIEW_LOOP_CODEX_FLAGS:---dangerously-bypass-approvals-and-sandbox}"
- if ! command -v codex &> /dev/null; then
- log "ERROR: codex not found on PATH"
- rm -f "$STATE_FILE"
- REASON="ERROR: Codex CLI is not installed. The review loop requires Codex for independent code review.
- Install it: npm install -g @openai/codex
- Then run /review-loop again. Multi-agent will be auto-configured."
- jq -n --arg r "$REASON" '{decision:"block", reason:$r}' 2>/dev/null \
- || printf '{"decision":"block","reason":"Codex CLI is not installed. Install it: npm install -g @openai/codex"}\n'
- exit 0
- fi
- # Validate multi-agent is enabled (should have been set up by /review-loop command)
- CODEX_CONFIG="${HOME}/.codex/config.toml"
- if [ ! -f "$CODEX_CONFIG" ] || ! grep -qE '^\s*multi_agent\s*=\s*true' "$CODEX_CONFIG"; then
- log "ERROR: multi_agent not enabled in $CODEX_CONFIG"
- rm -f "$STATE_FILE"
- REASON="ERROR: Codex multi-agent is not enabled in ~/.codex/config.toml. This should have been configured by /review-loop but may have been changed.
- Add to ~/.codex/config.toml:
- [features]
- multi_agent = true
- Then run /review-loop again."
- jq -n --arg r "$REASON" '{decision:"block", reason:$r}' 2>/dev/null \
- || printf '{"decision":"block","reason":"Codex multi-agent is not enabled in ~/.codex/config.toml"}\n'
- exit 0
- fi
- # Write prompt to file for the runner script to read
- PROMPT_FILE=".claude/review-loop-codex-prompt.txt"
- printf '%s' "$CODEX_PROMPT" > "$PROMPT_FILE"
- # Generate runner script that Claude will execute via Bash tool.
- # ${CODEX_FLAGS} expands at write time to bake in the flags value.
- # All other $ are escaped so they stay literal in the generated script.
- RUNNER_SCRIPT=".claude/review-loop-run-codex.sh"
- cat > "$RUNNER_SCRIPT" << RUNNER_EOF
- #!/usr/bin/env bash
- LOG_FILE=".claude/review-loop.log"
- log() { echo "[\$(date -u +"%Y-%m-%dT%H:%M:%SZ")] \$*" >> "\$LOG_FILE"; }
- PROMPT_FILE=".claude/review-loop-codex-prompt.txt"
- if [ ! -f "\$PROMPT_FILE" ]; then
- echo "ERROR: prompt file missing: \$PROMPT_FILE" >&2
- exit 1
- fi
- log "Starting Codex multi-agent review"
- START_TIME=\$(date +%s)
- # shellcheck disable=SC2086
- codex ${CODEX_FLAGS} exec "\$(cat "\$PROMPT_FILE")" || CODEX_EXIT=\$?
- CODEX_EXIT=\${CODEX_EXIT:-0}
- ELAPSED=\$(( \$(date +%s) - START_TIME ))
- log "Codex finished (exit=\$CODEX_EXIT, elapsed=\${ELAPSED}s)"
- exit \$CODEX_EXIT
- RUNNER_EOF
- chmod +x "$RUNNER_SCRIPT"
- # Transition to addressing phase — fail-open if this breaks, otherwise
- # a failed transition leaves phase=task and the next stop re-runs everything.
- if ! transition_phase "addressing"; then
- log "ERROR: phase transition failed, cleaning up"
- rm -f "$STATE_FILE" "$RUNNER_SCRIPT" "$PROMPT_FILE"
- printf '{"decision":"approve"}\n'
- exit 0
- fi
- log "Prepared Codex review for Claude to execute (review_id=$REVIEW_ID)"
- REASON="Phase 1 complete. Now run the Codex multi-agent review so you can see its progress.
- Execute this command (use a 600000ms timeout since reviews can take several minutes):
- \`\`\`
- bash .claude/review-loop-run-codex.sh
- \`\`\`
- After the review completes, read ${REVIEW_FILE} and address the findings:
- 1. Read the review carefully
- 2. For each item, independently decide if you agree
- 3. For items you AGREE with: implement the fix
- 4. For items you DISAGREE with: briefly note why you are skipping them
- 5. Focus on critical and high severity items first
- 6. When done addressing all relevant items, you may stop
- Use your own judgment. Do not blindly accept every suggestion."
- SYS_MSG="Review Loop [${REVIEW_ID}] — Phase 2/2: Run Codex review and address feedback"
- jq -n --arg r "$REASON" --arg s "$SYS_MSG" \
- '{decision:"block", reason:$r, systemMessage:$s}' 2>/dev/null \
- || printf '{"decision":"block","reason":"Phase 1 complete. Run: bash .claude/review-loop-run-codex.sh then address the review.","systemMessage":"%s"}\n' "$SYS_MSG"
- ;;
- addressing)
- # ── Phase 2: verify review was actually produced before allowing exit ──
- REVIEW_FILE="reviews/review-${REVIEW_ID}.md"
- if [ -f "$REVIEW_FILE" ]; then
- # Review exists — success
- log "Review loop complete (review_id=$REVIEW_ID)"
- rm -f "$STATE_FILE" .claude/review-loop.lock .claude/review-loop-run-codex.sh .claude/review-loop-codex-prompt.txt .claude/review-loop-retries
- printf '{"decision":"approve"}\n'
- elif [ -f ".claude/review-loop-run-codex.sh" ]; then
- # Runner script exists but review doesn't — check retry limit
- RETRY_FILE=".claude/review-loop-retries"
- RETRY_COUNT=0
- if [ -f "$RETRY_FILE" ]; then
- RETRY_COUNT=$(cat "$RETRY_FILE" 2>/dev/null || echo 0)
- fi
- RETRY_COUNT=$(( RETRY_COUNT + 1 ))
- if [ "$RETRY_COUNT" -ge 2 ]; then
- # Already told Claude to run the script once — Codex failed, don't retry
- log "ERROR: Codex failed to produce review, failing open (review_id=$REVIEW_ID)"
- rm -f "$STATE_FILE" .claude/review-loop.lock .claude/review-loop-run-codex.sh .claude/review-loop-codex-prompt.txt "$RETRY_FILE"
- printf '{"decision":"approve"}\n'
- else
- echo "$RETRY_COUNT" > "$RETRY_FILE"
- log "Review file not found ($REVIEW_FILE), prompting Claude to run Codex"
- REASON="The Codex review has not been completed yet. Please run the review script (use a 600000ms timeout since reviews can take several minutes):
- \`\`\`
- bash .claude/review-loop-run-codex.sh
- \`\`\`
- Then read ${REVIEW_FILE} and address the findings."
- SYS_MSG="Review Loop [${REVIEW_ID}] — Codex review not yet complete"
- jq -n --arg r "$REASON" --arg s "$SYS_MSG" \
- '{decision:"block", reason:$r, systemMessage:$s}' 2>/dev/null \
- || printf '{"decision":"block","reason":"Codex review not yet complete. Run: bash .claude/review-loop-run-codex.sh","systemMessage":"%s"}\n' "$SYS_MSG"
- fi
- else
- # Neither review nor runner script — orphaned state, fail-open
- log "ERROR: review file and runner script both missing, cleaning up (review_id=$REVIEW_ID)"
- rm -f "$STATE_FILE" .claude/review-loop.lock .claude/review-loop-codex-prompt.txt .claude/review-loop-retries
- printf '{"decision":"approve"}\n'
- fi
- ;;
- *)
- # Unknown phase — clean up and allow exit
- log "WARN: unknown phase '$PHASE', cleaning up"
- rm -f "$STATE_FILE" .claude/review-loop.lock .claude/review-loop-run-codex.sh .claude/review-loop-codex-prompt.txt
- printf '{"decision":"approve"}\n'
- ;;
- esac
plugins/review-loop/scripts/setup-review-loop.sh · Bundled script · 103 lines · 1 finding marked
- #!/usr/bin/env bash
- set -euo pipefail
- # Review Loop — Setup Script
- # Creates state file and prepares the review loop lifecycle.
- ARGS=()
- while [[ $# -gt 0 ]]; do
- case $1 in
- --help|-h)
- cat << 'HELP'
- Usage: /review-loop <task description>
- Starts a review loop:
- 1. Claude implements your task
- 2. Codex performs an independent code review
- 3. Claude addresses the feedback
- Environment variables:
- REVIEW_LOOP_CODEX_FLAGS Override codex flags (default: --dangerously-bypass-approvals-and-sandbox)
- Note: Starts a coding agent with its permission prompts off
- Line 21 on GitHub
- Example:
- /review-loop Add user authentication with JWT tokens and proper test coverage
- HELP
- exit 0
- ;;
- *)
- ARGS+=("$1")
- shift
- ;;
- esac
- done
- PROMPT="${ARGS[*]:-}"
- if [ -z "$PROMPT" ]; then
- echo "Error: No task description provided."
- echo "Usage: /review-loop <task description>"
- exit 1
- fi
- # Check dependencies
- if ! command -v codex &> /dev/null; then
- echo "Warning: 'codex' CLI not found. The review phase will fall back to self-review."
- echo "Install Codex CLI to enable independent code reviews."
- fi
- if ! command -v jq &> /dev/null; then
- echo "Error: 'jq' is required but not found."
- echo " macOS: brew install jq"
- echo " Linux: apt install jq / yum install jq"
- echo " Docs: https://jqlang.github.io/jq/download/"
- exit 1
- fi
- # Check for existing loop
- if [ -f ".claude/review-loop.local.md" ]; then
- echo "Error: A review loop is already active. Use /cancel-review to abort it first."
- exit 1
- fi
- # Generate unique ID: timestamp + random hex
- # Prefer openssl, fallback to /dev/urandom
- if command -v openssl &> /dev/null; then
- RAND_HEX=$(openssl rand -hex 3)
- else
- RAND_HEX=$(head -c 3 /dev/urandom | od -An -tx1 | tr -d ' \n')
- fi
- REVIEW_ID="$(date +%Y%m%d-%H%M%S)-${RAND_HEX}"
- # Clean up stale lock from previous runs
- rm -f .claude/review-loop.lock
- # Create state file
- mkdir -p .claude
- cat > .claude/review-loop.local.md << STATE_EOF
- ---
- active: true
- phase: task
- review_id: ${REVIEW_ID}
- started_at: $(date -u +"%Y-%m-%dT%H:%M:%SZ")
- ---
- ${PROMPT}
- STATE_EOF
- # Ensure reviews directory exists
- mkdir -p reviews
- echo ""
- echo "Review Loop activated"
- echo " ID: ${REVIEW_ID}"
- echo " Phase: 1/2 — Task implementation"
- echo " Review: reviews/review-${REVIEW_ID}.md"
- echo ""
- echo " Lifecycle:"
- echo " 1. You implement the task"
- echo " 2. Stop hook runs Codex for independent review"
- echo " 3. You address the feedback"
- echo ""
- echo " Use /cancel-review to abort."
- echo ""
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.