Refinement Loop (Claude Opus 4.8) for Openclaw

An iterative generation, evaluation, and revision workflow optimized for Claude Opus 4.8 to achieve high-quality outputs via structured self-critique and cost-efficient model routing.

prometheus-prime
v1.0.0
Jun 14, 2026
0
478
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install refinement-loop

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install refinement-loop using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Refinement Loop (Claude Opus 4.8)?

The refinement-loop workflow is a cornerstone of building robust agentic systems using Openclaw Skills. Unlike traditional single-prompt architectures, this skill structures an autonomous loop that progressively improves an output through candidate generation, multi-agent critique, and targeted revision passes. Optimized heavily for Claude Opus 4.8, it maximizes the benefits of extended thinking blocks, resolving complex logical goals that a single-pass prompt cannot handle.

By integrating this pattern into Openclaw Skills, developers gain a production-ready framework for managing multi-call iterations. It provides out-of-the-box model routing to split tasks between Opus and Sonnet, robust token-budget controls, and advanced convergence criteria to prevent costly infinite loops, delivering highly polished results at minimal cost.

Refinement Loop (Claude Opus 4.8) Use Cases

  • High-stakes writing tasks that require multi-stage styling, rubric adherence, or specialized domain guidelines.
  • Automatic prompt engineering pipelines that systematically evaluate, benchmark, and optimize LLM prompts.
  • Structured text formatting and schema validation where JSON outputs require strict adherence to deterministic shapes.
  • Multi-pass source code generation where outputs must be progressively refined based on syntax, test results, and runtime errors.

How Refinement Loop (Claude Opus 4.8) Works

  1. Initialize State: Define the baseline requirements, set up temperature controls, and configure target constraints including a token budget cap.
  2. Generate First Draft: Invoke Claude Opus 4.8 with thinking enabled to leverage internal self-critique mechanisms for a high-quality initial draft.
  3. Isolate Critique: Send the draft and the explicit scoring rubric to a separate Claude Sonnet instance to act as a cheaper, objective critic.
  4. Evaluate Convergence: Apply triple-signal convergence checks (similarity threshold, score variance, and critic-provided JSON convergence flags).
  5. Revise & Progress: If thresholds are not met, the revision model uses the feedback history to generate an upgraded candidate.
  6. Return Best and Polish: Halt when stopping conditions are met, tracking the absolute highest-scoring output rather than blindly returning the final loop iteration.

Refinement Loop (Claude Opus 4.8) Setup

To deploy this model refinement mechanism using Openclaw Skills, configure your environment with the correct model endpoints and budget tracking. Follow these steps to set up your workflow environment:

# Install the necessary Openclaw development dependencies
npm install @openclaw/sdk-core

# Export your Anthropic credentials
export ANTHROPIC_API_KEY="your-api-key-here"
export MAX_REFINEMENT_TOKENS=50000

Now, define your orchestration logic using the core configuration schema. This initializes the loop using high-performance Claude presets tailored for Openclaw Skills.

Refinement Loop (Claude Opus 4.8) Data Schema & Taxonomy

This workflow schema structures operational state and execution metadata across all passes. It uses a clean JSON state schema to keep the model anchored to original specifications:

State Parameter Data Type Description Optimization Strategy
original_requirements String Core prompt and constraints Sent every loop iteration to prevent drift
current_best String Highest-scoring candidate Tracked dynamically as the active reference
latest_critique String Structured evaluation object Evaluated against the strict rubric
token_budget Integer Running token count Monitored to execute a hard stop if exceeded

Evaluation Output Structure

When the critic runs under Pattern 3, it outputs a deterministic JSON object to prevent soft praise:

{
  "score": 8.5,
  "failures": ["Paragraph 3 exceeds word limit", "Missing call-to-action"],
  "converged": false
}

Refinement Loop (Claude Opus 4.8) Advanced Features

  • Adversarial Role Separation: Splits execution so the critic and generator prompts operate independently, preventing sychophantic feedback loops.
  • Triple-Signal Convergence Tracking: Mitigates loop churn by combining semantic cosine similarity checks, score delta caps, and model flags.
  • Cost-Optimized Model Routing: Routes first-draft and final-polish tasks to Opus while executing intermediate revisions on cost-effective Sonnet engines.
  • Thinking-Block Extraction: Captures raw reasoning sequences from Claude's thinking blocks to isolate high-fidelity structural criticisms.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*