一键导入
auto
Autonomous build loop with Karpathy ratcheting, GAN evaluator, and session chaining. Iterates story groups until all features pass or stopping criteria met.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Autonomous build loop with Karpathy ratcheting, GAN evaluator, and session chaining. Iterates story groups until all features pass or stopping criteria met.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Socratic interview to create a Business Requirements Document. First step in the SDLC pipeline.
Generate system architecture, machine-readable schemas, and UI mockups. Spawns planner + ui-designer concurrently.
Evaluation patterns — sprint contract format, three-layer verification, scoring rubric references.
Standard GitHub issue workflow. Branch, reproduce, fix, test, PR.
Generate production code and tests for a story group using agent teams for parallel execution.
Refactor existing code for quality, performance, or maintainability. Enforces six quality principles with ratchet gate.
| name | auto |
| description | Autonomous build loop with Karpathy ratcheting, GAN evaluator, and session chaining. Iterates story groups until all features pass or stopping criteria met. |
| argument-hint | [--mode full|lean|solo|turbo] [--group GROUP_ID] |
| context | fork |
Autonomous build loop implementing Karpathy's ratcheting pattern with GAN-style generator-evaluator separation, agent teams for parallel execution, sprint contracts for verifiable done-criteria, self-healing with failure-driven learning, and session chaining for multi-context-window builds.
/auto
/auto --mode lean
/auto --mode solo
/auto --group D
--mode controls which ratchet gates are enforced. Default: full. Options: full, lean, solo, turbo.--group resumes or targets a specific dependency group. If omitted, picks the next unfinished group from the dependency graph.Before /auto can run, the following must exist:
specs/stories/ — approved story files with acceptance criteria.specs/design/ — approved architecture artifacts including api-contracts.md and component-map.md..claude/program.md — project constraints and conventions.features.json — feature tracking file (created by /spec).specs/stories/dependency-graph.md — group ordering and dependencies.claude-progress.txt — session tracking file (created by /build phase 4).If any prerequisite is missing, stop and report what is absent. Do not proceed with partial context.
Critical rule: /auto orchestrates but NEVER implements code directly.
/auto is the orchestrator. It reads state, makes decisions, spawns agents, and manages the loop./implement or direct agent spawn)./evaluate or direct agent spawn)./auto never writes application code, tests, or configuration files itself.At the start of EVERY iteration — including the first — read these files in order:
.claude/program.md — Constraints may have changed mid-run. Re-read every iteration. Never cache..claude/state/learned-rules.md — Accumulated project rules. Inject verbatim into ALL agent prompts spawned this iteration.claude-progress.txt — Read the LAST session block (the block after the final === Session marker). Extract: current_group, groups_completed, groups_remaining, last_commit, next_action.features.json — Current pass/fail state for all features. Determines what work remains.specs/stories/dependency-graph.md — Pick the next unfinished group. A group is "unfinished" if any of its stories' features are not passing in features.json. Respect dependency ordering: do not start a group whose upstream dependencies have failing features.If claude-progress.txt indicates a current_group that is not yet complete, resume that group. Otherwise, select the next unfinished group in dependency order.
Sprint contracts define the verifiable done-criteria for a group. Two-step propose-approve process using generator and evaluator agents.
Spawn generator as a subagent with this prompt:
Read stories [list IDs for this group],
specs/design/api-contracts.md,specs/design/component-map.md. Propose a sprint contract for group {ID}. Include: api_checks, playwright_checks, design_checks, architecture_checks, features list. Write the contract tosprint-contracts/{group}.json.
The generator produces a draft contract based on the story acceptance criteria and the architecture design.
Spawn evaluator as a subagent with this prompt:
Read the proposed sprint contract at
sprint-contracts/{group}.json. Review each check against the story acceptance criteria and API contracts. Add any missing checks. Remove any checks that do not trace to an acceptance criterion. Write the final contract to the same path.
Rules:
Spawn the generator agent to create and manage a Claude Code agent team for the current group.
Before spawning teammates, the generator analyzes the component map:
Produces: / Consumes: in component map)Log the micro-DAG to iteration-log.md.
If no cross-dependencies exist, all teammates spawn in parallel (legacy behavior).
| Phase | Who | Starts When | Must Do |
|---|---|---|---|
| 1 | Teammates with no upstream deps | Immediately | Implement + commit typed interface contracts |
| 2 | Teammates consuming Phase 1 outputs | All Phase 1 teammates complete | Code against committed interface contracts |
| 3 | Integrators for shared files | All Phase 2 teammates complete | Collect declared additions, write to shared files |
Max 5 concurrent teammates per phase. Batch in groups of 5 if more.
Every teammate receives:
specs/stories/story-NNN.md)specs/design/component-map.md).claude/state/learned-rules.md — inject verbatim).claude/skills/code-gen/SKILL.md).claude/skills/code-gen/references/api-integration-patterns.mdIn Solo mode, the generator works alone sequentially. No team spawning, no phases. Read stories in dependency order and implement one at a time.
| Role | Model | Rationale |
|---|---|---|
/auto orchestrator | Opus | Judgment, architectural decisions |
| Evaluator | Opus | Skeptical verification |
| Design critic | Opus | Subjective visual judgment |
| Generator lead | Sonnet | Coordination, lower cost |
| Generator teammates | Sonnet | Mechanical implementation |
| Security reviewer | Sonnet | Pattern matching |
Configure via project-manifest.json field execution.model_tier.
After the agent team completes, run the ratchet gate. The ratchet is monotonic: progress never regresses. Six sub-gates, mode-dependent:
| Gate | Full | Lean | Solo | Turbo |
|---|---|---|---|---|
| 1. Unit tests (pytest, vitest) | Yes | Yes | Yes | Yes (per commit) |
| 2. Lint + types (ruff, mypy, tsc) | Yes | Yes | Yes | Yes (per commit) |
| 3. Coverage >= baseline | Yes | Yes | Yes | Yes (per commit) |
| 4. Architecture (files exist, schema validation) | Yes | Yes | No | Once at end |
| 5. Evaluator (API + Playwright vs running Docker) | Yes | Yes | No | Once at end |
| 6. Design critic (vision scoring, GAN loop) | Yes | No | No | Once at end |
For builds using Opus 4.6+ where the model can sustain coherence across long tasks:
Use when: Model is highly capable AND project is well-specified AND you trust the generator to self-correct. Do NOT use when: External API integrations, complex multi-service architecture, or first time using the harness.
Skip gates 4-6 (architecture, evaluator, design critic) for commits that ONLY contain:
Detection: If git diff --name-only shows only .md files, or if the commit message starts with fix: lint or docs:, skip the evaluator. Gates 1-3 (tests + lint + coverage) always run.
This prevents the expensive evaluator from blocking trivial housekeeping changes.
cd backend && uv run pytest -x -q && cd ..
cd frontend && npm test && cd ..
Both must pass with zero failures. The -x flag stops at first failure for fast feedback.
# Backend
uv run ruff check . && uv run mypy src/
# Frontend
npm run lint && npm run typecheck
All four commands must exit with code 0.
uv run pytest --cov=src --cov-report=term-missing -q | grep "^TOTAL" | awk '{print $NF}'
Compare the result with .claude/state/coverage-baseline.txt. The new coverage percentage must be greater than or equal to the baseline AND >= 80% (hard floor). If it drops below either threshold, the gate FAILS — even if all tests pass.
Coverage policy (ref: "AI is forcing us to write good code" by Steve Krenzel):
Spawn evaluator to verify architecture_checks from the sprint contract:
files_must_exist must be present on disk.specs/design/api-contracts.schema.json if specified.Spawn evaluator with the full sprint contract. The evaluator runs:
api_checks against the live Docker stack.playwright_checks against the running UI.The evaluator writes its report to specs/reviews/evaluator-report.md.
Spawn design-critic on every page listed in the sprint contract's design_checks. The critic screenshots each page, scores visual fidelity, and returns PASS/FAIL per check. See SECTION 9 for the full GAN loop if scores are below threshold.
Execute these steps in order:
git add -A && git commit -m "feat: implement group {group}"passes: true for all features in this group's sprint contract.Do not immediately revert. Attempt targeted self-healing first.
Attempt 1-3:
Diagnose: Invoke superpowers:systematic-debugging to analyze the failure before attempting a fix. This prevents jumping to conclusions and ensures the root cause is identified. Read the evaluator report (specs/reviews/evaluator-report.md) for specific failure details. Identify the exact check that failed and the error output.
Classify the failure into one of 10 categories:
| Category | Signal | Auto-Fix Strategy |
|---|---|---|
| Lint/format | ruff/eslint error output | ruff check --fix && ruff format |
| Type error | mypy/tsc error with file:line | Fix the type annotation at the specified location |
| Test failure | pytest/vitest assertion error | Fix the production code, NOT the test |
| Import error | ImportError / ModuleNotFoundError | Fix the import path or __init__.py |
| Coverage drop | Coverage % below baseline | Add tests for the specific uncovered lines |
| API check fail | HTTP 500/404/wrong schema | Read docker compose logs backend --tail=50, identify root cause from stack trace, fix service/router |
| Playwright fail | Element not found / assertion error | Read the selector, fix the component |
| Design score low | Score below threshold | Apply the critique text, regenerate the UI |
| Docker fail | Container exit code / won't start | Read docker compose logs, fix config or deps |
| Architecture drift | Schema mismatch / missing file | Read the schema, fix the response or create the file |
Spawn generator to apply the targeted fix. The generator prompt must include:
specs/reviews/eval-failures-NNN.json (see evaluator agent for schema).prior_attempts: On attempt 2, include attempt 1's fix description and result. On attempt 3, include both. This prevents the generator from re-trying the same fix.Error type to fix strategy mapping:
| error_type | Strategy |
|---|---|
lint_format | Run auto-fix tools (ruff check --fix, eslint --fix) |
type_error | Fix annotation at file:line from stack trace |
import_error | Check module path, fix import statement |
key_error | Check data shape at source — log incoming data, fix accessor |
timeout | Check if service is started, increase timeout, add retry |
connection_refused | Verify service URL in config, check port mapping |
validation_error | Compare request/response against schema, fix model |
assertion_error | Read test assertion, compare expected vs actual, fix logic |
api_transient | Retry evaluator check once (code may be correct, API was flaky). If retry passes, do not count as a self-heal attempt. |
api_permanent | Fix wrapper error handling or request format |
Re-run the failed gate (not all gates — just the one that failed).
3rd failure — hard stop for this group:
git checkout -- ..claude/state/failures.md with group ID, failure category, all three attempt summaries.claude-progress.txt./auto is responsible for starting and stopping the application. The evaluator does NOT manage the app lifecycle.
Read verification.mode from project-manifest.json. Default: docker.
Startup:
bash init.sh before first evaluator checkBetween Groups:
docker compose up -d --build
Wait for health check before handing off to evaluator.
Teardown:
docker compose down -v
Error Context: docker compose logs --tail=50 {service_name}
Startup:
verification.local.start_commands from manifest.claude/state/process-{name}.logBetween Groups: Kill and restart processes (re-run start commands).
Teardown: Kill all background processes started by the orchestrator.
Error Context: Read from .claude/state/process-{name}.log
Startup:
verification.stub.schema_source from manifestBetween Groups: Regenerate mock server if schema has been amended (check specs/design/amendments/).
Teardown: Kill mock server process.
Error Context: Stub mismatch reports — when a request doesn't match any endpoint in the schema, log the requested path and method.
Stub mode limitations: Layer 1 checks validate request/response shapes but cannot verify business logic. Layer 2 (Playwright) skipped unless a separate frontend URL is configured.
When using --worktree flag, each worktree gets its own app instance:
project-manifest.json)After each agent team completes (before the ratchet gate):
specs/design/amendments/ for new files that were not present at the start of this iteration.api-contracts.md, component-map.md, schema files).git add specs/design/ && git commit -m "refactor: update api-contracts for {change description}"Amendments are a signal that the implementation discovered a design gap. They must be incorporated before evaluation, not deferred.
Read calibration-profile.json for all scoring and iteration parameters. Fall back to defaults if file does not exist.
| Parameter | Source | Default |
|---|---|---|
| Scoring weights | calibration-profile.json → scoring.weights | DQ=1.5, O=1.5, C=0.75, F=0.75 |
| Pass threshold | calibration-profile.json → scoring.threshold | 7 |
| Per-criterion minimum | calibration-profile.json → scoring.per_criterion_minimum | 5 |
| Max iterations | calibration-profile.json → iteration.max_iterations | 10 |
| Plateau window | calibration-profile.json → iteration.plateau_window | 3 |
| Plateau delta | calibration-profile.json → iteration.plateau_delta | 0.3 |
| Pivot on plateau | calibration-profile.json → iteration.pivot_after_plateau | true |
For each frontend page in the current group:
specs/reviews/eval-scores.json, continue to next pageAfter each iteration, check the last plateau_window weighted scores:
max(recent) - min(recent) < plateau_delta: scores have plateauedpivot_after_plateau is true: instruct generator to make a fundamental change (different palette, layout, or typography) — not incremental tweaksmax_iterations reached → log to failures.md, extract learned rule, escalate to user. Do NOT revert (ratchet gate already passed for functional checks).claude-progress.txt is the memory bridge between context windows. Each iteration appends a new session block.
=== Session {N} ===
date: {ISO 8601}
mode: {full|lean|solo}
groups_completed: [A, B, C]
groups_remaining: [D, E, F]
current_group: D (extraction)
current_stories: [E4-S1, E4-S2]
sprint_contract: sprint-contracts/group-D.json
last_commit: {hash} "{message}"
features_passing: 47 / 203
coverage: 82%
learned_rules: 6
blocked_stories: none
next_action: Run evaluator against group D
next_action is critical. This field tells a fresh context window exactly what to do first. Be specific: "Run evaluator against group D" is good. "Continue" is not.blocked_stories if any stories failed 3 consecutive self-heal attempts. Format: [E4-S3 (import error), E5-S1 (docker fail)].OR logic with priority (check in order):
Hard stop: An architecture violation that self-healing cannot fix, OR the total iteration count exceeds 50. Stop the entire /auto run. Report status and hand off to the user.
Escalate (per-story): A story fails 3 consecutive self-heal iterations. Mark it BLOCKED. Log to failures.md. Extract learned rule. Skip to the next group. Do NOT stop the entire run.
Coverage gate: Coverage drops below the baseline AFTER a successful commit. This overrides the pass — revert the commit (git revert HEAD --no-edit), log the regression, and re-enter self-healing for coverage.
Success: All features in features.json have passes: true AND coverage >= baseline threshold. Before claiming completion, invoke superpowers:verification-before-completion to run all verification commands and confirm output. Evidence before assertions. Print:
=== BUILD COMPLETE ===
Features passing: {N}/{N}
Coverage: {X}%
Groups completed: [list]
Blocked stories: [list or "none"]
Learned rules: {count}
Total iterations: {count}
Then:
docker compose down -vREADME.md for the built application (see below)git add README.md && git commit -m "docs: add README with architecture, setup, and API reference"After the build completes, generate a README.md that describes the GENERATED APP (not the harness).
Read these files for content:
specs/brd/brd.md — project descriptionspecs/design/architecture.md — system architecturespecs/design/api-contracts.md or api-contracts.schema.json — API surfacespecs/design/component-map.md — module structureproject-manifest.json — tech stackinit.sh — setup stepsdocker-compose.yml (if exists) — services.env.example (if exists) — required environment variablesRequired sections: Project description, Architecture (diagram/layers), Tech Stack (table), Prerequisites, Quick Start (copy-paste commands), API Endpoints (table), Project Structure (directory tree), Running Tests, Environment Variables (table from .env.example), Development notes.
Rules:
/auto, agents, or the GAN loop. This is a developer README for the app..env.example exactly.Learned rules are the harness's long-term memory. They prevent the same mistake from recurring across iterations and context windows.
Extract a new rule when the same error type (by category from SECTION 6) appears 2 or more times in .claude/state/failures.md. Check after every failure entry.
Append to .claude/state/learned-rules.md:
## Rule {N}: {descriptive title}
- **Source:** Group {group}, Story {story}, Iteration {iter}
- **Impact:** {quantified damage — e.g., "test coverage dropped 18%", "deployment failed", "3 iterations wasted"}
- **Pattern:** {what went wrong — the repeated error signature}
### Mistake
{description of what happened and why it failed}
### Anti-Pattern (Avoid This)
\`\`\`{language}
{code example showing the bad pattern — actual code from the failure}
\`\`\`
### Better Approach
\`\`\`{language}
{code example showing the correct pattern — the fix that resolved it}
\`\`\`
- **Rule:** {the concrete instruction to prevent recurrence}
- **Applied in:** {list of agents/skills that must follow this rule}
Include code examples whenever the mistake involves a code pattern. For non-code mistakes (e.g., wrong deployment sequence), describe the steps instead of code blocks. Always quantify impact — agents prioritize rules with higher impact.
learned-rules.md does not exist yet, create it with a header: # Learned Rules\n\nRules extracted from failure patterns during autonomous build.\nprogram.md each iteration: Constraints can change mid-run (e.g., a human updates program.md while /auto is running). Always re-read at the start of every iteration.git checkout -- . reverts everything. After the 3rd failure, only the current group's files should be reverted. Use the file ownership list from component-map.md to scope the revert: git checkout -- {file1} {file2} ...failures.md for recurring patterns BEFORE spawning the generator. If the same error has appeared before, inject the relevant learned rule into the generator prompt proactively.