Autonomous AI coding loop v2 with phased execution, dependency graphs, browser validation, structured memory, and quality ratcheting...
Phased, skill-aware autonomous coding loop with browser validation, structured memory, and quality ratcheting. Works on any project or from scratch.
.leo/ directory (prd.json, memory.json, quality-metrics.json, screenshots)Parse from user input:
leo/<feature-slug>)CLAUDE.md if existspackage.json, Cargo.toml, pyproject.toml, go.mod, requirements.txt, Makefile, etc.techStack in PRD:language, frameworkbuildCmd, testCmd, lintCmd, typecheckCmddevServerCmd, devServerUrlquality-metrics.jsonUS-000: Initialize project scaffold)dependsOn: ["US-000"]techStack with expected commands for the chosen frameworkBreak the feature/project into stories organized by phase. Each story must be completable in ONE iteration.
Assign 1-3 skills per story based on its content:
| Skill | When to Assign |
|---|---|
code |
Always — general implementation |
database |
Schema changes, migrations, seed data |
api |
API endpoint creation or modification |
ui |
Frontend component work |
browser |
Story has visual output to validate |
test |
Test-focused or test-heavy stories |
dependsOn: ["US-XXX"] for explicit orderingpassedFor UI stories, add validation.type: "browser" with steps:
{
"validation": {
"type": "browser",
"browserSteps": [
{ "action": "open", "target": "http://localhost:3000/page" },
{ "action": "wait", "target": "--text 'Expected Text'" },
{ "action": "snapshot", "expect": "description of what should be visible" },
{ "action": "screenshot", "path": ".leo/screenshots/US-XXX.png" }
]
}
}
Initialize the following files in .leo/:
{
"version": 2,
"project": "<project name>",
"branchName": "leo/<feature-slug>",
"description": "<feature/project description>",
"techStack": {
"language": "<detected>",
"framework": "<detected>",
"buildCmd": "<detected or null>",
"testCmd": "<detected or null>",
"lintCmd": "<detected or null>",
"typecheckCmd": "<detected or null>",
"devServerCmd": "<detected or null>",
"devServerUrl": "<detected or null>"
},
"phases": [
{ "id": "phase-0", "name": "Discovery", "type": "discovery", "status": "complete" },
{ "id": "phase-1", "name": "Foundation", "status": "pending" },
{ "id": "phase-2", "name": "Features", "status": "pending" },
{ "id": "phase-3", "name": "Polish", "status": "pending" }
],
"stories": [
{
"id": "US-001",
"title": "<title>",
"description": "As a <user>, I want <goal>, so that <benefit>",
"phase": "phase-1",
"priority": 1,
"skills": ["code", "database"],
"dependsOn": [],
"status": "pending",
"failureCount": 0,
"maxRetries": 3,
"acceptanceCriteria": [
"<criterion 1>",
"<criterion 2>"
],
"validation": {
"type": "none",
"browserSteps": []
},
"notes": "",
"lastFailure": null
}
]
}
{
"patterns": [],
"decisions": [],
"failures": [],
"environment": {}
}
Run the project's quality commands and capture baseline:
{
"baseline": {
"typescriptErrors": 0,
"testCount": 0,
"testPassRate": 1.0,
"lintErrors": 0,
"buildSuccess": true
},
"snapshots": [],
"ratchetRules": {
"typescriptErrors": "no-increase",
"testCount": "no-decrease",
"testPassRate": "no-decrease",
"lintErrors": "no-increase",
"buildSuccess": "must-be-true"
}
}
For greenfield projects, set all baseline values to 0/true (baseline captured after scaffold story).
Also create .leo/screenshots/ directory.
Display to the user:
Ask user to confirm, then run:
${CLAUDE_PLUGIN_ROOT}/scripts/leo-wiggum.sh <max_iterations>
Pass --headed if user requested visible browser.
CRITICAL: After starting the script, END your response immediately. The script spawns NEW Claude Code sessions — your job is done.
.leo/prd.json: story statuses and failure info.leo/memory.json: structured learnings, patterns, decisions, failures.leo/quality-metrics.json: metric trends across iterations.leo/screenshots/: visual proof from browser validationgit log: commits per story