refine-loop
Skill9 starsChanged 3 months agoMITView on GitHub
Use when the user wants iterative self-improvement on a deliverable (document, implementation, prompt, design) until completion criteria are met.
4 other projects use a version of this.
Adopted by
Most recently taken up by
- GeiserX/sstacktheir own version, first seen Nov 8, 2026
- GeiserX/agent-skillstheir own version, first seen Nov 6, 2026
- GeiserX/claude-skillstheir own version, first seen Nov 6, 2026
- divlook/skillstheir own version, first seen Aug 23, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- GeiserX/agent-skills★ 5same name
- GeiserX/claude-skills★ 5same name
- GeiserX/sstack★ 5same name
- divlook/skills★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository56 other files it gives its agents.
- .claude/agents/CLAUDE.mdCLAUDE.md
- .claude/hooks/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- .claude/prompts/CLAUDE.mdCLAUDE.md
- .claude/rules/CLAUDE.mdCLAUDE.md
- .claude/skills/CLAUDE.mdCLAUDE.md
- docs/CLAUDE.mdCLAUDE.md
- vision/CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- scaffold/llms.txtllms.txt
- architecture-checkSkill
- backlog-reviewSkill
- bootstrapSkill
- brainstormSkill
- buildSkill
- claude-sense-checkSkill
- code-qualitySkill
- commitSkill
- continueSkill
- custom-hooksSkill
- dashboardSkill
- debug-sessionSkill
- deploySkill
- discoverSkill
- doctorSkill
- fix-issueSkill
- framework-upgradeSkill
- handoffSkill
- help-meSkill
- ideateSkill
- lanesSkill
- manual-testSkill
- merge-downSkill
- merge-upSkill
- optimizeSkill
- parallel-workSkill
- performance-checkSkill
- phase-reviewSkill
- pr-statusSkill
- quality-checkSkill
- quickstartSkill
- researchSkill
- retrospectiveSkill
- security-auditSkill
- skill-createSkill
- skill-evalSkill
- sprint-endSkill
- sprint-startSkill
- story-cycleSkill
- testing-cycleSkill
- test-validatorSkill
- UAT-cycleSkill
- undo-workSkill
- uninstallSkill
- weekly-maintenanceSkill
- wrap-upSkill
The file
We split this skill into the rules it gives an agent
10 rules. 0 are common, 4 are distinctive, and 6 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 54
At each iteration: Update phase to the iteration number, phase_name to "Iteration N", next_action to the specific improvement being …
- Very specific: line 56
When criteria are met (or max iterations reached): Delete .failure-state.md — clean state means no failure to recover from.
- Distinctive: line 87
Autonomous mode additional check: Before continuing to next iteration, check for diminishing returns (see Diminishing Returns Detection …
- Distinctive: line 95
Re-evaluate: Check ALL criteria again (not just the one fixed)
- Very specific: line 101
If
--autonomous: After each iteration, append to docs/sessions/.refine-log.tsv: - Very specific: line 128
When --autonomous is active, track progress across iterations:
- Distinctive: line 135
If the next iteration ALSO shows no progress: stop the loop early
- Very specific: line 142
Default --max 5 prevents runaway loops (raised to 50 only with explicit --autonomous)
- Distinctive: line 144
If the same gap persists after 2 attempts, flag it as potentially unresolvable and move on
- Very specific: line 161
--autonomousspecifically: When each iteration requires human judgment or approval
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
refine-loop
Refining: $ARGUMENTS
Argument Parsing
| Argument | Required | Default | Description |
<task> | Yes | - | What to produce or improve |
--until "<criteria>" | Yes | - | Completion condition (must be verifiable) |
--max <N> | No | 5 (50 if --autonomous) | Maximum iterations before stopping |
--autonomous | No | false | Extended unattended mode: higher iteration cap, TSV logging, diminishing-returns auto-stop |
Failure State Persistence
At loop entry, write docs/sessions/.failure-state.md with YAML frontmatter so the Stop hook and /continue can programmatically detect incomplete workflows.
At loop entry (before first execution):
---
status: active
skill: refine-loop
phase: "1"
phase_name: "Initial Execution"
started_at: "[ISO-8601 timestamp from date -u +%Y-%m-%dT%H:%M:%SZ]"
story: "[from $ARGUMENTS — the task description]"
branch: "[from git branch --show-current]"
next_action: "Execute task and produce first draft"
autonomous: [true|false]
files_modified: []
---
## Context
Task: [task description]
Criteria: [completion criteria]
Iteration: 1 of [max]
Mode: [standard | autonomous]At each iteration: Update phase to the iteration number, phase_name to "Iteration N", next_action to the specific improvement being applied, and append to files_modified. Update the Context section with iteration progress and remaining gaps.
When criteria are met (or max iterations reached): Delete .failure-state.md — clean state means no failure to recover from.
Process
1. Initial Execution
Execute the task to produce the first draft/version.
If --autonomous: Initialize the iteration log file:
docs/sessions/.refine-log.tsv:
iteration criteria_met criteria_total gap_description action_taken timestamp
0 0 <total> Initial execution Produced first draft <ISO-8601>2. Self-Review Against Criteria
Evaluate the current output against the completion criteria. For each criterion:
- MET: Criterion is satisfied with evidence
- NOT MET: Criterion fails — identify the specific gap
3. Decision Point
[All criteria MET?]
→ YES: Output final result → DONE
→ NO: [iterations < max?]
→ YES: Identify SPECIFIC improvements → Apply → Go to step 2
→ NO: Output best result + remaining gaps → DONEAutonomous mode additional check: Before continuing to next iteration, check for diminishing returns (see Diminishing Returns Detection below).
4. Iteration (if continuing)
Each iteration MUST:
- Name the gap: What specific criterion is not met?
- Describe the fix: What concrete change will address it?
- Apply the fix: Make the change
- Re-evaluate: Check ALL criteria again (not just the one fixed)
<HARD-GATE>
Each iteration must identify SPECIFIC improvements with concrete descriptions. "Make it better" or "improve quality" are NOT valid improvement descriptions. If you cannot name a specific gap, the loop is done — output the current result.
</HARD-GATE>If --autonomous: After each iteration, append to docs/sessions/.refine-log.tsv:
<iteration> <criteria_met_count> <criteria_total> <gap_addressed> <action_taken> <ISO-8601>5. Completion Report
### Refinement Complete
**Task:** [description]
**Completion criteria:** [criteria]
**Iterations:** X of Y max
**Mode:** [standard | autonomous]
**Status:** [All criteria met / Stopped at max / No further improvements identified / Stopped: diminishing returns]
**Iteration log:**
1. [What was changed and why]
2. [What was changed and why]
...
**Remaining gaps (if any):**
- [Gap]: [Why it couldn't be resolved]Diminishing Returns Detection (Autonomous Mode)
When --autonomous is active, track progress across iterations:
Trigger: 3 consecutive iterations where criteria_met count does not increase.
Action:
- Print: "Diminishing returns: 3 consecutive iterations with no criteria progress."
- Attempt ONE strategy shift — try a fundamentally different approach to the remaining gaps
- If the next iteration ALSO shows no progress: stop the loop early
- Report: "Stopped early: diminishing returns after [N] iterations"
Why this exists: In autonomous mode, the iteration cap is high (50). Without diminishing-returns detection, the loop could spend 40+ iterations making no meaningful progress. This auto-stop preserves context budget for productive work.
Safety
- Default
--max 5prevents runaway loops (raised to 50 only with explicit--autonomous) - Each iteration must make measurable progress — if an iteration doesn't change anything, stop
- If the same gap persists after 2 attempts, flag it as potentially unresolvable and move on
- The loop produces a completion report regardless of how it ends
- Autonomous mode: Diminishing-returns detection auto-stops after 3+ consecutive no-progress iterations
When to Use
- Polishing documentation (architecture docs, READMEs, ADRs)
- Iterating on prompt/skill content
- Refining complex implementations with multi-faceted quality criteria
- Any task where "good enough on first try" is unlikely
- With
--autonomous: Long-running refinement tasks (test suite generation, comprehensive documentation, prompt optimization) where extended unattended iteration is acceptable
When NOT to Use
- Simple one-shot tasks (just do them directly)
- Tasks without clear completion criteria
- During story-cycle execution (use the story-cycle's own phases instead)
--autonomousspecifically: When each iteration requires human judgment or approval
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

