Skill v1.0.0
currentAutomated scan100/100name: loop-build description: "Self-correcting build loop: spec -> build -> adversarial review -> fix -> repeat until review passes clean. Combines spec-driven-development with adversarial verification in an automated cycle. Threshold: 95%." triggers:
- "loop build"
- "петля сборки"
- "зацикль билд"
- "build until clean"
- "собери и проверь"
- "build loop"
- "loop-build"
id: loop-build runtime: claude-only canonical_path: ~/.claude/skills/loop-build/SKILL.md updated: 2026-06-23 tags: [loop, build, review, spec, adversarial, quality] group: development metadata: version: "1.0.0"
Loop Build - Self-Correcting Build Cycle
Inspired by: MAMA MOZG "Petlya" methodology, adapted for adversarial multi-agent architecture.
Core Idea
Build from spec, review against spec with a SEPARATE agent (blind review), fix failures, repeat. Stop when review passes clean or diminishing returns detected.
When to Use
- Building features from a spec (spec-driven-development output)
- Any build task with >3 requirements to verify
- Multi-file implementations where drift is likely
- When you want to "fire and forget" - launch and get clean result
Skip for: single-file fixes, typos, config changes, tasks under 10 min.
Prerequisites
A spec file must exist at specs/<name>.md (created by spec-driven-development or manually). If no spec exists, prompt user to run /spec-driven-development first or provide requirements inline.
The Loop Protocol
PHASE 1: BUILDRead specs/<name>.mdBuild exactly what it describesOutput: checklist of covered requirementsPHASE 2: REVIEW (adversarial, separate agent)Spawn review agent with ONLY:- The spec file- The current code/output- NO access to build reasoningReview agent checks requirement-by-requirementOutput: PASS (all met) or FAIL (list of gaps with spec item references)PHASE 3: FIX (if FAIL)Read review agent's gap listFix each gap, referencing specific spec itemReturn to PHASE 2STOP CONDITIONS (any triggers exit):- Review returns PASS (all requirements met)- Score >= 95% of spec items satisfied AND remaining are cosmetic- 5 iterations reached (hard cap - report what's left)- Score delta < 3% between iterations (diminishing returns)
Implementation
Step 1: Read Spec
spec_file = specs/<name>.mdParse into discrete, checkable requirementsNumber each requirement: R1, R2, R3...
Step 2: Build
Build strictly from spec.NO features beyond spec.NO refactoring of unrelated code.After build, self-report:COVERED: R1, R2, R3, R5SKIPPED: R4 (reason)ADDED: nothing (if anything added - flag as scope creep)
Step 3: Adversarial Review (SEPARATE AGENT)
Spawn Agent with:description: "Blind spec review - iteration N"prompt: |You are a strict QA reviewer. You have never seen the build reasoning.SPEC (source of truth):<paste spec content>CURRENT BUILD (what to review):<paste code/files/output>For each requirement in the spec:1. State the requirement (quote it)2. Check if the build satisfies it: PASS / PARTIAL / FAIL3. If not PASS: describe exactly what's missing or wrongFinal verdict:- SCORE: X/Y requirements passed (percentage)- VERDICT: PASS (all met) or FAIL (list gaps)- FIXES NEEDED: numbered list of specific changes
Step 4: Fix or Finish
IF verdict == PASS or score >= 95%:Report to user:LOOP COMPLETE after N iterationsScore trajectory: 60% -> 80% -> 95%Final state: <summary>IF verdict == FAIL and iterations < 5:Apply fixes from reviewGo to Step 3IF iterations == 5:Report to user:LOOP STOPPED at iteration 5Current score: X%Remaining gaps: <list>Recommendation: manual review needed for <specific items>
Output Format
After loop completion, always report:
LOOP-BUILD COMPLETESpec: specs/<name>.mdIterations: N/5Score trajectory: X% -> Y% -> Z%Final score: Z%Status: PASSED / STOPPED (max iterations) / STOPPED (diminishing returns)Gaps remaining: none / <list>
Integration Points
| Skill | How it connects | |
|---|---|---|
spec-driven-development | Produces the spec that loop-build consumes | |
code-review | Review agent uses code-review checklist as additional layer | |
doubt-driven-development | Applied inside review agent for architectural decisions | |
verification-before-completion | Final check after loop exits | |
test-driven-development | Tests serve as additional PASS/FAIL signal in the loop |
Anti-Patterns
- Don't self-review: always use a SEPARATE agent for review. Self-review has confirmation bias.
- Don't exceed spec: if build adds features not in spec, that's a FAIL even if the feature is good.
- Don't skip diminishing returns check: if score goes 92% -> 93% -> 93%, stop. The last 2% isn't worth another iteration.
- Don't run on trivial tasks: the overhead of 2-5 iterations is only justified for substantial builds.