Auto review loop llm

From wanshuiyin/Auto-claude-code-research-in-sleep · View interactive version

Auto review loop llm is an AI agent skill from the GitHub repository wanshuiyin/Auto-claude-code-research-in-sleep. Autonomous research review loop using any OpenAI-compatible LLM API. Configure via llm-chat MCP server or environment variables. Trigger with "auto review loop llm" or "llm review".

How to use this skill

Skill file

Auto Review Loop (Generic LLM): Autonomous Research Improvement

πŸ”’ Do not wrap this skill in /loop, /schedule, or CronCreate. Like

/auto-review-loop, it already loops internally (review β†’ fix β†’ re-review),

feeding each round's prior-round summary into the next review prompt (the

backend is a stateless per-round API/MCP call, not a shared thread). An

external timer re-enters from the top each tick, dropping that accumulated

context and firing the verdict on wall-clock time instead of on artifact

change β€” zero new signal, full token cost. Schedule the *external wait that

precedes it*, not the verdict. See

CODE0.

Autonomously iterate: review β†’ implement fixes β†’ re-review, until the external reviewer gives a positive assessment or MAX_ROUNDS is reached.

Context: $ARGUMENTS

Constants

LLM Configuration

This skill uses any OpenAI-compatible API for external review via the llm-chat MCP server.

Configuration via MCP Server (Recommended)

Add to ~/.claude/settings.json:

{
  "mcpServers": {
    "llm-chat": {
      "command": "/usr/bin/python3",
      "args": ["/Users/yourname/.claude/mcp-servers/llm-chat/server.py"],
      "env": {
        "LLM_API_KEY": "your-api-key",
        "LLM_BASE_URL": "https://api.deepseek.com/v1",
        "LLM_MODEL": "deepseek-chat"
      }
    }
  }
}

Supported Providers

| Provider | LLM_BASE_URL | LLM_MODEL |

|----------|--------------|-----------|

| OpenAI | https://api.openai.com/v1 | gpt-6.1-sol, gpt-6-astra |

| DeepSeek | https://api.deepseek.com/v1 | deepseek-chat, deepseek-reasoner |

| MiniMax | https://api.minimax.io/v1 | MiniMax-M3 |

| Kimi (Moonshot) | https://api.moonshot.cn/v1 | moonshot-v1-8k, moonshot-v1-32k |

| ZhiPu (GLM) | https://open.bigmodel.cn/api/paas/v4 | glm-4, glm-4-plus |

| SiliconFlow | https://api.siliconflow.cn/v1 | Qwen/Qwen2.5-72B-Instruct |

| ι˜Ώι‡ŒδΊ‘η™Ύη‚Ό | https://dashscope.aliyuncs.com/compatible-mode/v1 | qwen-max |

| 離一万物 | https://api.lingyiwanwu.com/v1 | yi-large |

The llm-chat server defaults to gpt-6.1-sol. When LLM_FALLBACK_MODEL is

unset, the 504-timeout fallback inherits LLM_MODEL (so it is not a fixed,

different model). Calls to api.openai.com automatically use

max_completion_tokens; third-party OpenAI-compatible endpoints use

max_tokens. Set LLM_MAX_TOKENS_FIELD=max_tokens or

LLM_MAX_TOKENS_FIELD=max_completion_tokens to override that automatic choice.

API Call Method

Primary: MCP Tool

mcp__llm-chat__chat:
  prompt: |
    [Review prompt content]
  model: "deepseek-chat"
  system: "You are a senior ML reviewer..."

Fallback: curl

For third-party OpenAI-compatible endpoints, use max_tokens:

curl -s "${LLM_BASE_URL}/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${LLM_API_KEY}" \
  -d '{
    "model": "${LLM_MODEL}",
    "messages": [
      {"role": "system", "content": "You are a senior ML reviewer..."},
      {"role": "user", "content": "[review prompt]"}
    ],
    "max_tokens": 4096
  }'

For a direct OpenAI call, use max_completion_tokens instead:

curl -s "https://api.openai.com/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${LLM_API_KEY}" \
  -d '{
    "model": "gpt-6.1-sol",
    "messages": [
      {"role": "system", "content": "You are a senior ML reviewer..."},
      {"role": "user", "content": "[review prompt]"}
    ],
    "max_completion_tokens": 4096
  }'

State Persistence (Compact Recovery)

Persist state to review-stage/REVIEW_STATE.json after each round:

{
  "round": 2,
  "status": "in_progress",
  "last_score": 5.0,
  "last_verdict": "not ready",
  "pending_experiments": [],
  "timestamp": "2026-03-15T10:00:00"
}

Write this file at the end of every Phase E (after documenting the round).

On completion, set "status": "completed".

Workflow

Initialization

  1. Check review-stage/REVIEW_STATE.json for recovery (fall back to ./REVIEW_STATE.json if not found β€” legacy path)
  2. Read project context and prior reviews
  3. Initialize round counter

Loop (up to MAX_ROUNDS)

Phase A: Review

If MCP available:

mcp__llm-chat__chat:
  system: "You are a senior ML reviewer (NeurIPS/ICML level)."
  prompt: |
    [Round N/MAX_ROUNDS of autonomous review loop]

    [Full research context: claims, methods, results, known weaknesses]
    [Changes since last round, if any]

    1. Score this work 1-10 for a top venue
    2. List remaining critical weaknesses (ranked by severity)
    3. For each weakness, specify the MINIMUM fix
    4. State clearly: is this READY for submission? Yes/No/Almost

    Be brutally honest. If the work is ready, say so clearly.

If MCP NOT available: For third-party OpenAI-compatible endpoints use

max_tokens; for direct OpenAI calls use max_completion_tokens instead.

curl -s "${LLM_BASE_URL}/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${LLM_API_KEY}" \
  -d '{
    "model": "${LLM_MODEL}",
    "messages": [
      {"role": "system", "content": "You are a senior ML reviewer (NeurIPS/ICML level)."},
      {"role": "user", "content": "[Full review prompt]"}
    ],
    "max_tokens": 4096
  }'
Phase B: Parse Assessment

CRITICAL: Save the FULL raw response verbatim. Then extract:

STOP: If score >= 6 AND verdict ∈ {"ready", "almost"} (exact β€” "not ready" does NOT qualify)

Phase C: Implement Fixes

Add a metric when it resolves a specific review concern that the existing results cannot settle. Use existing measurements when they already answer it.

Phase D: Wait for Results

Monitor remote experiments

Phase E: Document Round

Append to review-stage/AUTO_REVIEW.md:

## Round N (timestamp)

### Assessment (Summary)
- Score: X/10
- Verdict: [ready/almost/not ready]
- Key criticisms: [bullet list]

### Reviewer Raw Response

<details>
<summary>Click to expand full reviewer response</summary>

[Paste the COMPLETE raw response here β€” verbatim, unedited.]

</details>

### Actions Taken
- [what was implemented/changed]

### Results
- [experiment outcomes, if any]

### Status
- [continuing to round N+1 / stopping]

Write review-stage/REVIEW_STATE.json with current state.

Termination

  1. Set review-stage/REVIEW_STATE.json status to "completed"
  2. Write final summary

Key Rules

Prompt Template for Round 2+

mcp__llm-chat__chat:
  system: "You are a senior ML reviewer (NeurIPS/ICML level)."
  prompt: |
    [Round N/MAX_ROUNDS of autonomous review loop]

    ## Previous Review Summary (Round N-1)
    - Previous Score: X/10
    - Previous Verdict: [ready/almost/not ready]
    - Previous Key Weaknesses: [list]

    ## Changes Since Last Review
    1. [Action 1]: [result]
    2. [Action 2]: [result]

    ## Updated Results
    [paste updated metrics/tables]

    Please re-score and re-assess:
    1. Score this work 1-10 for a top venue
    2. List remaining critical weaknesses (ranked by severity)
    3. For each weakness, specify the MINIMUM fix
    4. State clearly: is this READY for submission? Yes/No/Almost

    Be brutally honest. If the work is ready, say so clearly.

Output Protocols

Follow these shared protocols for all output files:

- Output Versioning Protocol β€” write timestamped file first, then copy to fixed name

- Output Manifest Protocol β€” log every output to MANIFEST.md

- Output Language Protocol β€” respect the project's language setting

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.