aif-loop

Runs iterative generate-evaluate-critique-refine loops with quality gates and persistent state.

31|2|Updated Mar 21, 2026
One-click install
npx skills add https://github.com/letuhao/lore-weave --skill aif-loop-letuhao
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: aif-loop
Source: https://github.com/letuhao/lore-weave/tree/main/.cursor/skills/aif-loop
Command: npx skills add https://github.com/letuhao/lore-weave --skill aif-loop-letuhao

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Single-pass AI generation often produces artifacts that miss requirements, and manual review cycles are slow and inconsistent. This Skill automates a structured refinement loop that plans, produces, evaluates against explicit rules, critiques failures, and refines until quality thresholds are met or iteration limits are reached. ## Core Features & Use Cases - Phased Iteration Loop: Executes PLAN, PRODUCE, PREPARE, EVALUATE, CRITIQUE, and REFINE phases with parallel Task agents, two-tier quality gates (Phase A then stricter Phase B), and stagnation detection. - Persistent Resumable State: Stores loop state in run.json, history.jsonl, and artifact.md so loops can be stopped, resumed, listed, and cleaned across sessions. - Rule-Based Evaluation: Ships criteria templates for API specs, code, documentation, and configuration, with weighted scoring, severity levels, and materialized executable/content checks. - Use Case: Ask for an OpenAPI 3.1 spec for a courses API; the loop drafts it, runs schema and completeness checks, critiques missing endpoints, and refines until the spec passes the 0.9 threshold. ## Quick Start Start a new refinement loop by asking to run /aif-loop new followed by your task, such as generating an OpenAPI spec with DDD notes and JSON examples.

Frequently Asked Questions about aif-loop

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run an iterative generate-critique-refine loop on an AI artifact?

Start a loop with /aif-loop new followed by your task description. The skill confirms success criteria and max iterations, then cycles through PLAN, PRODUCE, EVALUATE, CRITIQUE, and REFINE phases until the score threshold is met or limits are reached.

How do I resume an interrupted refinement loop?

Use /aif-loop resume to continue the active loop, or /aif-loop resume <alias> for a specific task. All state is persisted in run.json and history.jsonl, so the loop re-executes from the interrupted phase without losing progress.

What artifact types does the evaluation criteria support?

Built-in templates cover API specifications, code generation, documentation, and configuration files. Each template defines weighted rules with fail, warn, and info severities, plus recommended Phase A and Phase B thresholds.

Can the loop run without parallel Task agents?

Yes. If the Task tool is unavailable or errors, the loop falls back to sequential execution of PLAN, PRODUCE, PREPARE, EVALUATE, CRITIQUE, and REFINE. Parallelism is an optimization, not a requirement.

When does the loop stop before reaching the quality threshold?

The loop stops on iteration limit, explicit user stop, stagnation (score delta under 0.02 twice with no fail-severity blockers), or when no fail-severity rules remain failing. Iteration-limit stops include a distance-to-success summary.