agentleFS
teltringhamteltringham/sdd-plugin/skills/sdd-run/SKILL.md

sdd-run

Skill0 starsChanged 8 months agoMITView on GitHub

Orchestrates the full SPIIM lifecycle end-to-end. Auto-detects greenfield vs brownfield, runs Research → Spec → Design → Plan → Implement → Iterate → Monitor as a continuous cycle. The user kicks this off and walks away. Use to run the complete SDD process for a feature.

The file

Show its rules and text

We split this skill into the rules it gives an agent

25 rules. About 0 are common, 14 are distinctive, and 11 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈14

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 11

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run the entire Spec-Driven Development lifecycle for a feature.

    line 8
  2. Very specific:

    If no spec/active/*.prd.json files exist: skip this sub-step (greenfield run, PRD not yet created).

    line 76
  3. Very specific:

    Before loading the handoff and continuing, invoke scripts/resume-handler.sh to detect stale-handoff / pending-PRD mismatches (ASSERT-010 — …

    line 80
  4. Very specific:

    Check if /sdd-init has been run.

    line 127
  5. Distinctive:

    If found beyond config/boilerplate: brownfield (existing codebase)

    line 130
  6. Distinctive:

    If empty or config-only: greenfield (fresh project)

    line 131
  7. Very specific:

    Write initial .sdd/handoff.json with phase: "starting"

    line 134
  8. Distinctive:

    If brownfield: include research findings as context

    line 157
  9. Distinctive:

    Ask: "Does this spec look right?

    line 162
  10. Distinctive:

    Read the spec. Generate a ~200-line design discussion that covers:

    line 169
  11. Distinctive:

    Ask: "Does this architecture make sense?

    line 180
  12. Distinctive:

    Before dispatching any agent (implementer or evaluator), invoke:

    line 197
  13. Very specific:

    This field is mandatory on every agent invocation context: If the field is absent, the sdd-evaluator agent will refuse to issue a verdict …

    line 207
  14. Distinctive:

    If any stories escalate (maxAttempts exceeded):

    line 221
  15. Very specific:

    Update handoff: phase: "implement-complete" with story pass/fail counts

    line 228
  16. Distinctive:

    If manual-fix candidates found:

    line 236
  17. Very specific:

    If spec amendments were applied and --loop is active:

    line 248
  18. Very specific:

    Run convergence check (sdd_convergence_check MCP tool):

    line 256
  19. Very specific:

    If --loop and issues found (drift, uncovered requirements, non-convergent stories):

    line 268
  20. Distinctive:

    If cycle < 3: loop back to Phase 5 (or Phase 2 if spec issues detected)

    line 270
  21. Distinctive:

    If cycle >= 3: stop and report — non-convergence after 3 cycles needs human intervention

    line 271
  22. Very specific:

    Update handoff: phase: "complete" (or phase: "looping-back")

    line 273
  23. Distinctive:

    If approaching context limit: summarize prior phase results before starting next phase

    line 310
  24. Very specific:

    All artifacts created (spec, design discussion, plan, prd.json)

    line 316
  25. Distinctive:

    All stories attempted via Ralph loop

    line 317

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

SDD Run — Full SPIIM Orchestrator

Run the entire Spec-Driven Development lifecycle for a feature. One command, full autonomy.

Arguments

$ARGUMENTS — feature description + optional flags:

/sdd-run "user authentication with JWT"
/sdd-run "add rate limiting to existing API" --brownfield
/sdd-run "new CLI tool" --greenfield --auto
/sdd-run --resume

Flags:

  • --greenfield — skip research phase (no existing code)
  • --brownfield — force research phase (existing codebase)
  • --auto — skip human gates except escalations (overnight mode)
  • --yolo — skip ALL human gates (prototyping only)
  • --loop — after monitor, loop back if issues found (max 3 cycles)
  • --resume — pick up from .sdd/handoff.json

Phase Flow

BROWNFIELD?
    │
    yes ──> RESEARCH (opinion-free codebase exploration)
    │           │
    no ─────────┘
                │
                v
            SPEC (generate spec with traceability IDs)
                │
                v
            DESIGN DISCUSSION (~200-line architecture sense-check)
                │
                v
            PLAN (decompose into prd.json task DAG)
                │
                v
            IMPLEMENT (Ralph loop — one story at a time, fresh context, TDD)
                │
                v
            ITERATE (auto-scan for backprop candidates)
                │
            [human gate in standard mode — approve spec amendments]
                │
                v
            MONITOR (convergence, gaps, drift)
                │
            ┌───┴───┐
            │       │
         CLEAN    ISSUES ──> loop back to IMPLEMENT (if --loop)
            │
           DONE

Process

Phase 0: Initialize

  1. PRD validation gate (runs before all other steps):
    • Invoke sdd_validate_prd against every file matching spec/active/*.prd.json.
    • Evaluate the result:
      • No issues (empty errors + empty warnings): proceed.
      • Warnings only: proceed but log each warning to progress.txt with the [WARN] prefix.
      • Errors present: HALT. Print each error. Operator must fix the PRD or re-run with --yolo to bypass.
      • --strict flag set: warnings are promoted to errors — halt on any unknown field.
    • If no spec/active/*.prd.json files exist: skip this sub-step (greenfield run, PRD not yet created).
  2. --resume cross-check (only when --resume flag is present):

    Before loading the handoff and continuing, invoke scripts/resume-handler.sh to detect stale-handoff / pending-PRD mismatches (ASSERT-010 — closes smoke #16):

    bash scripts/resume-handler.sh .sdd/handoff.json spec/active/ [--auto|--yolo]

    The handler loads .sdd/handoff.json, extracts the feature name and target PRD path, then scans all spec/active/*.prd.json files. It determines:

    • Is the handoff feature's PRD all passes:true?
    • Does any OTHER PRD in spec/active/ have actionable pending stories?

    Decision matrix:

    Handoff-PRD stateOther PRDs have pendingFlagResult
    Still activeAny state(any)Exits 0 — safe to resume; no action needed
    All doneNone pending(any)Exits 0 — all done; clean state
    All doneYes(none)Exits 1 — ERROR citing feature name AND pending PRD filenames; operator must choose
    All doneYes--autoExits 0 — auto-resolves to highest-priority pending story across all PRDs; prints dispatch info
    All doneYes--yoloExits 0 — bypasses check; proceeds against named handoff regardless

    Error format (default mode, exit 1):

    ERROR: Resume mismatch detected.
    
      Handoff feature '<feature-name>' is complete — all stories pass.
      But the following PRD(s) in spec/active/ still have pending work:
        - <pending-prd-filename.prd.json>
        ...
    
      To proceed, choose one of:
        --auto   Auto-resolve to the highest-priority pending story across all PRDs
        --yolo   Bypass this check and proceed against the named handoff (<feature-name>)

    If the handler exits non-zero and neither --auto nor --yolo is set: HALT. Print the error verbatim and ask the operator which path to take.

    --auto resolution: The handler emits a dispatch message identifying the highest-priority pending story (lowest priority integer, tie-break: PRD filename alphabetical). Use that story as the next dispatch target — equivalent to the Ralph loop's normal dispatch logic.

    --yolo bypass: The handler proceeds without cross-checking. Use only in prototyping or when the operator has explicitly confirmed stale-handoff is intentional.

  3. Check if /sdd-init has been run. If not, run it automatically.
  4. Auto-detect project type:
    • Scan for source code directories (src/, lib/, app/, pkg/) and language-specific files (.ts, .py, .go, .rs, .java, .rb)
    • If found beyond config/boilerplate: brownfield (existing codebase)
    • If empty or config-only: greenfield (fresh project)
    • Override with --greenfield or --brownfield flag
  5. Initialize session log: scripts/session-log.sh init
  6. Write initial .sdd/handoff.json with phase: "starting"
  7. Append to progress.txt: [START] SDD run: "{feature}" (mode: {greenfield|brownfield}, tier: {standard|auto|yolo})

Phase 1: Research (brownfield only)

Skip this phase if greenfield.

  1. Derive 3-5 research questions from the feature description. These are WHAT questions about the existing codebase, NOT questions about what to build:
    • "How does the current auth system work?"
    • "What HTTP clients/frameworks are used?"
    • "Where are API routes defined?"
    • "What test patterns exist?"
    • "What database/ORM is used?"
  2. Invoke sdd-researcher agent via Task tool with these questions. The researcher gets NO knowledge of what we're building — this prevents implementation bias (QRISPY pattern).
  3. Capture research findings. These will be passed to the spec phase.
  4. Update handoff: phase: "research-complete"

Phase 2: Spec

  1. Invoke /sdd-spec with the feature description.
    • If brownfield: include research findings as context
    • The spec skill handles clarifying questions, template generation, traceability IDs
  2. Human gate (standard mode only):
    • Present the generated spec summary
    • Ask: "Does this spec look right? Proceed to design discussion?"
    • In --auto or --yolo mode: skip this gate
  3. Update handoff: phase: "spec-complete", spec_path: "context/specs/spec-{slug}.md"

Phase 3: Design Discussion

  1. Read the spec. Generate a ~200-line design discussion that covers:
    • Architecture approach: How does this feature fit into the existing system?
    • Key technical decisions: What patterns, libraries, or approaches to use?
    • Risk assessment: What could go wrong? What's the hardest part?
    • Integration points: How does this feature connect to existing code?
    • Non-obvious constraints: What did the researcher find that affects design?
  2. Save to context/design/design-discussion-{slug}.md
  3. Human gate (standard mode only):
    • Present the design discussion summary
    • Ask: "Does this architecture make sense? Proceed to planning?"
    • In --auto or --yolo mode: skip this gate
  4. Update handoff: phase: "design-complete"

Phase 4: Plan

  1. Invoke /sdd-plan which reads the spec and generates:
    • context/plans/plan-{slug}.md (human-readable)
    • spec/active/{slug}.prd.json (machine-readable)
    • Traceability cross-check (every spec req covered)
  2. Update handoff: phase: "plan-complete", prd_path: "spec/active/{slug}.prd.json"

Phase 5: Implement (Ralph Loop)

  1. Compute same_family_warning for every agent invocation (ASSERT-009 — mandatory). Before dispatching any agent (implementer or evaluator), invoke:

    same_family_warning=$(bash scripts/dispatcher/family-detect.sh "<implementer-model-id>" "<evaluator-model-id>")

    This must happen BEFORE the agent is dispatched. The result — one of true | false | unknown — is injected into the agent's input context under the key same_family_warning.

    • true — both agents are from the same model family (e.g., both claude-sonnet-*). Structural diversity is NOT active; evaluator will emit a diversity-warning annotation.
    • false — different families. Structural diversity IS active; evaluator proceeds normally.
    • unknown — dispatcher could not determine the relationship. Evaluator proceeds but emits an unknown-diversity annotation.

    This field is mandatory on every agent invocation context. If the field is absent, the sdd-evaluator agent will refuse to issue a verdict (fail-closed). Do not dispatch the evaluator without this field.

    The model identifiers come from .sdd/config.json via sdd_resolve_provider. If identifiers are unavailable, pass empty strings — family-detect.sh will return unknown, which is the safe default.

  2. Invoke /sdd-implement which runs the Ralph loop:
    • Picks highest-priority incomplete story
    • Loads fresh context (only this story's spec + plan sections)
    • Invokes sdd-implementer agent (TDD mandatory)
    • Runs quality gates
    • Updates prd.json (passes/attempts)
    • Commits with Spec-Ref + Attempt trailers
  3. The stop hook keeps the loop running until all stories pass or escalate.
  4. If any stories escalate (maxAttempts exceeded):
    • Generate decision-request.md for each escalated story.
    • Tier behavior (per state-machine.json approval_gates.escalated_stories):
      • --auto mode (defer_and_continue): Park (defer) the escalated story — do NOT halt the loop. Continue draining independent stories from the runnable frontier. The loop is not interrupted mid-run. Collect all decision-request.md files. At end-of-run (Phase 8), batch all deferred decision-requests and present them once: "N stories escalated — review decision-request.md files and re-run." This is the walk-away-safe behavior — a single hard story does not stall the whole run.
      • --standard mode (ask): Halt. Present escalated stories and decision requests. Ask: "How should we handle these? Fix spec / increase attempts / skip?"
      • --yolo mode (skip_and_mark): Mark as skipped, continue.
  5. Update handoff: phase: "implement-complete" with story pass/fail counts

Phase 6: Iterate (Backpropagation Auto-Scan)

  1. Automatically run sdd_backprop_analyze MCP tool to scan commits since implementation started.
  2. Classify commits: ralph-generated vs manual-fix vs infrastructure.
  3. If manual-fix candidates found:

    • For each: invoke sdd-backpropagator agent to trace to spec
    • Generate backpropagation report with suggested spec amendments

    Human gate (standard mode):

    • Present each amendment: "This spec is missing constraint X. Apply? [yes/modify/skip]"
    • Apply approved amendments, commit with Backprop-From trailers
    • Update backprop-log.json

    In --auto mode: Skip backprop amendments (log candidates for later review) In --yolo mode: Auto-apply all suggested amendments (dangerous but fast)

  4. If spec amendments were applied and --loop is active:
    • Reset affected stories in prd.json (passes=false, attempts=0)
    • Go back to Phase 5 (Implement) for re-run verification
  5. Update handoff: phase: "iterate-complete"

Phase 7: Monitor

  1. Run convergence check (sdd_convergence_check MCP tool):
    • Files changed per iteration trend (should be decreasing)
    • Per-story attempt counts
    • Estimated remaining iterations
  2. Run gap analysis:
    • Spec coverage: every requirement covered by a passing story?
    • Traceability: every commit has Spec-Ref trailer?
    • Drift: any code changes not linked to specs?
  3. Generate health report.
  4. If --loop and issues found (drift, uncovered requirements, non-convergent stories):
    • Increment cycle counter
    • If cycle < 3: loop back to Phase 5 (or Phase 2 if spec issues detected)
    • If cycle >= 3: stop and report — non-convergence after 3 cycles needs human intervention
  5. Update handoff: phase: "complete" (or phase: "looping-back")

Phase 8: Completion

  1. Generate final summary:
    ## SDD Run Complete: {feature}
    
    ### Results
    - Stories: {passed}/{total} complete
    - Escalated: {N} (see decision-request.md)
    - Backpropagation: {N} spec amendments applied
    - Convergence: {trend}
    - Traceability: {N}/{total} commits traced
    
    ### Artifacts Created
    - Spec: context/specs/spec-{slug}.md ({N} requirements)
    - Plan: context/plans/plan-{slug}.md
    - Tasks: spec/active/{slug}.prd.json
    - Design: context/design/design-discussion-{slug}.md
    - ADRs: {list if any}
    
    ### Next Steps
    - Run /sdd-review before shipping
    - Run /sdd-iterate if bugs are found later
    - Run /sdd-monitor periodically
  2. End session log: scripts/session-log.sh end
  3. Final handoff update: phase: "complete"
  4. Append to progress.txt: [PASS] SDD run complete: "{feature}" — {passed}/{total} stories, {N} backprop amendments

Context Management

Between phase transitions:

  • Evict tool outputs from prior phases (microcompaction)
  • Carry forward only: spec path, prd.json path, progress.txt last 20 lines
  • If approaching context limit: summarize prior phase results before starting next phase
  • On crash: resume from .sdd/handoff.json via /sdd-run --resume

Output contract

  • Full SPIIM lifecycle executed
  • All artifacts created (spec, design discussion, plan, prd.json)
  • All stories attempted via Ralph loop
  • Backpropagation scan run automatically
  • Human gates respected per approval tier
  • .sdd/handoff.json maintained throughout for crash recovery
  • Session log captures all phase transitions
  • progress.txt updated with typed symbols

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.