sdd-iterate
Skill0 starsChanged 8 months agoMITView on GitHub
Runs the backpropagation workflow — traces bugs and manual fixes back to specs, suggests spec amendments, and optionally re-runs implementation from updated specs. The killer feature of SDD. Use when bugs are found, after manual code fixes, or when specs need hardening.
In this repository13 other files it gives its agents.
- AGENTS.mdAGENTS.md
- sdd-adrSkill
- sdd-implementSkill
- sdd-initSkill
- sdd-monitorSkill
- sdd-planSkill
- sdd-reviewSkill
- sdd-runSkill
- sdd-specSkill
- sdd-standupSkill
- sdd-statusSkill
- sdd-triageSkill
- sdd-ux-validateSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
23 rules. About 0 are common, 10 are distinctive, and 13 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
13
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 18
Use the MCP tool sdd_backprop_analyze to scan recent git history:
- Very specific: line 19
If $ARGUMENTS is a specific commit hash, analyze just that commit
- Very specific: line 20
If $ARGUMENTS is "all", analyze all commits since the last spec-update commit
- Very specific: line 21
If omitted, analyze commits since the most recent commit with an Attempt: trailer (last Ralph run)
- Distinctive: line 29
If no candidates found, report "No backpropagation candidates.
- Distinctive: line 50
Before drafting any new amendments, replay the existing regression corpus to confirm prior amendments still hold.
- Very specific: line 53
Run the entry's minimal_repro.test_command
- Very specific: line 55
If ANY entry fails, halt iterate: "Regression corpus is broken — entry bp-NNN no longer passes.
- Very specific: line 63
Use MCP tool sdd_trace_artifact to walk the traceability chain:
- Distinctive: line 65
Read the relevant spec sections
- Very specific: line 94
Before presenting to user, optionally invoke the sdd-skeptic agent on the proposed amendment:
- Very specific: line 98
Default: ON for omission and under-specification (most prone to over-fitting).
- Distinctive: line 123
Critical: backpropagation is human-gated: Never auto-modify specs. Constitutional Article 2.
- Distinctive: line 128
Add the new/modified requirement to the spec file
- Distinctive: line 130
Add an entry to the spec's backpropagation log table
- Very specific: line 138
Update context/impl/backprop-log.json (schema at ${CLAUDE_PLUGIN_ROOT}/templates/backprop/backprop-log.schema.json):
- Distinctive: line 183
If the backpropagator recommended re-running implementation:
- Distinctive: line 185
Ask the user: "Re-run implementation from updated spec to verify the fix emerges from specs alone?
- Very specific: line 189
Run /sdd-implement on those stories
- Very specific: line 208
If status == "complete", write the populated verification record and the derived verified_via_ralph: true to the entry.
- Very specific: line 209
If implementation does not produce the fix from specs alone (regression corpus regresses or the trigger reproducer still fails), close with …
- Distinctive: line 221
Every amendment carries a minimal reproducer and test command
- Distinctive: line 228
Stop-the-line triggers if ≥3 amendments to one spec in one session
≈ “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.
Files
SDD Iterate (Backpropagation)
Trace bugs to specs. Fix specs. Regenerate.
Arguments
$ARGUMENTS — optional commit hash or "all" to analyze all recent manual fixes. If omitted, analyzes commits since the last Ralph run.
Process
1. Find backpropagation candidates
Use the MCP tool sdd_backprop_analyze to scan recent git history:
- If
$ARGUMENTSis a specific commit hash, analyze just that commit - If
$ARGUMENTSis "all", analyze all commits since the lastspec-updatecommit - If omitted, analyze commits since the most recent commit with an
Attempt:trailer (last Ralph run)
The tool classifies each commit as:
ralph-generated— created by the Ralph loop (hasAttempt:trailer) — skipmanual-fix— human or ad-hoc fix (message matches fix/bug/patch) — backprop candidatespec-update— edits tocontext/specs/— skipinfrastructure— everything else — skip
If no candidates found, report "No backpropagation candidates. All recent changes are spec-driven." and exit.
1.5 Cluster check (cumulative cross-session)
Before replaying the regression corpus or drafting any amendments, invoke the MCP tool sdd_cluster_check with default arguments. This is the cumulative methodology gate (per Phase 2.1 of spec-plugin-v1.md) — counts amendments by spec_updated across all time, not just this session, and is a strict superset of the per-session Step 7 gate below.
Read the response:
threshold_breach == "none": continue to Step 2.threshold_breach == "warn": emit a methodology warning citing the breaching spec(s) and current count, then continue to Step 2. Recommended phrasing: "⚠ Methodology signal: spec{spec_updated}has accumulated{count}cumulative amendments. Consider whether further iteration is productive or whether a step-back to characterization is warranted."threshold_breach == "hard-stop"ANDoverride_active == false: HALT iterate. Refuse to proceed. Recommended phrasing: "⛔ Halted by cluster check: spec{spec_updated}has accumulated{count}cumulative amendments (threshold 5). Iteration cannot proceed without a recorded characterization plan. Seespec-plugin-v1.md§2.6 (characterization story tag in sdd-plan) for plan creation; or §2.5 (interface-maturity gate in sdd-spec) for upstream context."threshold_breach == "hard-stop"ANDoverride_active == true: emit override notice — "Cluster check hard-stop overridden by characterization plan recorded for{spec_updated}" — and continue to Step 2.
Constitutional Article 2 still applies — never auto-modify specs. The hard-stop is a refusal to proceed with iteration, not a code-level exception.
A characterization plan is considered "recorded" for a spec if EITHER context/plans/characterization-{spec-slug}.md exists (where {spec-slug} is the spec_updated path's basename without extension), OR any prd.json story in spec/active/ has a tags array containing "characterization" and a parent_spec matching spec_updated. (§2.6 will codify a tighter convention later; this is a permissive OR for v1.0.0.)
Follow-up stories are not exempt (W2 interaction). Amendments triggered by follow-up stories (those with a non-null parent_story_id, generated by the orchestrator when sdd-evaluator or sdd-ux-validator failed on a specific criterion) DO count toward the parent spec's cumulative cluster count. sdd_cluster_check already counts cumulatively across all entries keyed by spec_updated; this note simply records that follow-up-derived amendments are not special-cased out. Do not modify the threshold logic — the cluster check correctly treats follow-up amendments the same as any other amendment to the same spec.
2. Replay the regression corpus FIRST
Before drafting any new amendments, replay the existing regression corpus to confirm prior amendments still hold. This is the held-out eval set discipline (Anthropic Demystifying Evals).
The log's root key is entries as of v1.0.0. Older projects may still have backpropagation_log as the root key — accept both during the migration window, prefer entries. For each entry in context/impl/backprop-log.json (with a minimal_repro block):
- Run the entry's
minimal_repro.test_command - Set
regression_corpus_pass: true | falseon that entry - If ANY entry fails, halt iterate: "Regression corpus is broken — entry
bp-NNNno longer passes. Fix that before introducing new amendments."
The simpler rule: every prior amendment's minimal-repro must continue to pass before any new amendment can land.
3. Trace each candidate
For each manual-fix commit:
- Use MCP tool
sdd_trace_artifactto walk the traceability chain:- Changed files -> which STORY owns these files -> which SPEC requirements
- Read the relevant spec sections
- Construct the minimal reproducer — before invoking the backpropagator, identify the smallest input/state that reproduces the failure. This is iterate's first artifact, before any amendment. (Borrowed from property-based shrinking.)
- Invoke the
sdd-backpropagatoragent with:- The commit diff (
git show {hash}) - The minimal reproducer description and test command
- The traced spec requirements
- The spec file content
- The commit diff (
The backpropagator will produce:
- Root cause classification (one of:
ambiguity|omission|contradiction|under-specification|implementation-error|plan-gap|test-gap|infrastructure) - Action category:
prevent(tighten AC) |detect(add observability/test) |mitigate(add recovery requirement) — borrowed from AWS COE - The missing constraint
- A draft spec amendment
Framing discipline. Backpropagator must use "how, not why" framing (Allspaw, The Infinite Hows). Frame amendments as "what would have made this detectable" rather than "what should the spec have said". Counterfactual reasoning ("the spec should have said X") is hindsight bias dressed as analysis — it makes us feel productive without actually improving future detection.
3.5 Failed assertion → spec amendment (§2.9 / W10 discipline)
When a validator (sdd-evaluator, sdd-ux-validator, or the checks_result runner) fails on a story, identify which outcome-assertion(s) the failure invalidates by reading the PRD's assertions corpus and the failing story's assertion_ids. The asymmetry below is non-negotiable — it is the entire point of the §2.9 coverage gate:
- Failed assertion → SPEC AMENDMENT (NOT assertion edit, NOT test edit). The assertion was outcome-shaped at planning time; if it failed at runtime, the spec under-specified the outcome contract. Backprop tightens the spec. The assertion's
descriptionmay be revised IF AND ONLY IF the spec amendment changes the outcome contract that produced it; the assertion is never edited in isolation to make a passing implementation look correct. New assertions may be added if the failure surfaced a previously-unstated invariant. - Failed implementation against a passing assertion → IMPL FIX (NOT assertion edit). The assertion was right; the code was wrong. Generate a follow-up story per the orchestrator's W2 loop and let it converge.
Never edit an assertion to match what the code does. That collapse is exactly the failure mode §2.9 was added to prevent — once assertions become tests-fitted-to-the-code, the validation contract is meaningless and every prior assertion failure becomes deniable. Surface any ambiguous case to the operator before touching the corpus. (See spec-plugin-v1.md §2.9 motivation; cross-references missions-parity-handoff.md W10 and the production-data target language "validation never passes first try → expect follow-up features".)
This rule interlocks with §2.2 — the verification record's notes field SHOULD cite the specific assertion ID(s) the verification satisfied when the closing entry corresponds to an assertion-driven failure. It also interlocks with §2.7 — repeated assertion failures on the same surface count as methodology risk via sdd_cluster_check, not just drift.
4. Optional adversarial review of the amendment
Before presenting to user, optionally invoke the sdd-skeptic agent on the proposed amendment:
- Skeptic asks: does this amendment over-fit to the failing case? Would it block legitimate uses? Does it cite a concrete reproducer or speculate about a "class of bug"? Does it mix prevent/detect/mitigate (it should be tagged exactly one)?
- Output: list of concrete weaknesses; backpropagator revises.
Default: ON for omission and under-specification (most prone to over-fitting). OFF for implementation-error (no amendment needed).
5. Present suggestions to user
For each candidate, present the backpropagation report:
## Backpropagation: {commit hash}
**Commit:** {message}
**Classification:** {gap type}
**Category:** prevent | detect | mitigate
**Affected spec:** {spec file} — {requirement IDs}
**Minimal reproducer:** {description} — `{test command}`
**Missing constraint:** {description}
### Suggested amendment:
{Given/When/Then requirement}
### Skeptic findings (if run):
{list or "none"}
Apply this spec update? [yes / modify / skip]Critical: backpropagation is human-gated. Never auto-modify specs. Constitutional Article 2.
6. Apply approved amendments
For each approved amendment:
- Add the new/modified requirement to the spec file
- Assign the next sequential traceability ID (
SPEC-{slug}-{next_number}) - Add an entry to the spec's backpropagation log table
- Commit with:
docs: backprop spec-{slug} — add {requirement title} Spec-Ref: context/specs/spec-{slug}.md Backprop-From: {original-fix-commit-hash} Update
context/impl/backprop-log.json(schema at${CLAUDE_PLUGIN_ROOT}/templates/backprop/backprop-log.schema.json):{ "id": "bp-{NNN}", "trigger_commit": "{hash}", "trigger_type": "manual-fix", "classification": "{gap type}", "category": "{prevent|detect|mitigate}", "spec_updated": "{spec path}", "requirement_added": "SPEC-{slug}-{NNN}", "minimal_repro": { "description": "{the minimal reproducer from step 3}", "test_command": "{shell command that fails before fix, passes after}" }, "verification": null, "verified_via_ralph": false, "regression_corpus_pass": true, "date": "{ISO timestamp}" }verificationisnullat creation time — the entry has been amended but not yet verified. Step 8 populates the structured record and gates closure onsdd_verification_check.verified_via_ralphis now a derived summary computed from record completeness +wiring_audit_pass; do not set it independently.
7. Stop-the-line gate
If iterate produces 3+ amendments to the same spec slug in a single run, halt rather than amending unboundedly. Report: "Spec {slug} has accumulated N amendments this session. This is a Toyota-Andon signal — the spec may need a holistic rewrite, not more bolt-ons. Recommend manual review before continuing."
7.5 Wiring audit gate (§2.4)
Before any verification record construction in Step 8, invoke sdd_wiring_audit_check with the proposed amendment's entry_id to determine whether this entry's classification or category triggers the cross-family wiring-audit requirement (per spec-plugin-v1.md §2.4 + A1 amendment + Codex audit recommendation #5). The five trigger categories are pinned in the predicate: detect, quantitative_gate, abort_rate_threshold, subprocess_protocol, runtime_callback_wiring.
Branch on status:
not_required— entry's classification/category does not match a trigger. Proceed directly to Step 8 verification record construction.gate_required_missing— entry's category requires a wiring audit but the verification record is absent (expected at this point, since the entry was created at Step 6 withverification: null) orwiring_audit_passis not true, OR the project has no.sdd/config.jsonto resolve providers against. HALT closure. Surface to operator: this amendment must route to a cross-family validator per the per-project provider config. The auditor (an agent whose name starts withsdd-, or a human liketyler/matt) populateswiring_audit_pass: true,auditor, and the implicitauditor_provider(resolved from the auditor's agent name viasdd_resolve_provider) into the verification record at Step 8 sub-step 4. Re-attempt close after the audit runs and the record is populated.cross_family_violation— wiring audit ran but the auditor's provider is same-family as the worker (eitherproviderstrings match orsame_family_warning=truein the config). HALT closure (per A1 spec amendment + locked decision #5 — wiring audits MUST route cross-family). Surface to operator and re-run with a cross-family auditor. Recommended phrasing: "⛔ Wiring audit ran same-family. Per §2.4 A1 + locked decision #5, cross-family routing is required. Re-dispatch the audit to an agent whose resolved provider differs fromworker.providerper.sdd/config.json."complete— gate satisfied. Proceed to Step 8.no_log— backprop log or entry not found at the resolved path. HALT with the predicate'serrorcited.
This gate is the programmatic enforcement of the cross-family discipline previously operator-enforced in Step 8 sub-step 4 prose ("Cross-family wiring audit (per locked decision #5)"). The prose remains as backup guidance for the operator constructing the record, but the gate is now authoritative — Step 8 sub-step 5 (sdd_verification_check) confirms structural completeness; this gate confirms cross-family routing. Both must pass before Step 8 sub-step 6 writes the populated record.
For amendments whose category is not in the trigger list (e.g. pure prevent amendments to documented-internal interfaces), this gate is a no-op (not_required); the operator-enforced cross-family prose in Step 8 sub-step 4 still applies as guidance, but the predicate does not block.
8. Optionally verify via regeneration AND close the entry
If the backpropagator recommended re-running implementation:
Ask the user: "Re-run implementation from updated spec to verify the fix emerges from specs alone? This will re-attempt the affected stories."
If approved:
- Reset the affected stories in prd.json: set
passes: false, resetattemptsto 0, setphase: "pending". Phase-first read (v1.1+): when checking which stories need re-run, a story is "done" whenphase == "done". Legacy PRDs without aphasefield fall back topasses == true. Never readpassesalone to determine done status on PRDs that carry aphasefield. - Run
/sdd-implementon those stories - Replay the full regression corpus — every prior
minimal_repromust still pass. Construct the verification record (per Phase 2.2 of
spec-plugin-v1.md). Populate the entry'sverificationfield with all seven sub-fields:command— exact command run to verify (e.g. the entry'sminimal_repro.test_command, or a pytest invocation)artifact_path— path to test output, screenshot, or log demonstrating verification (ornull)production_entrypoint— code path the verification exercised (e.g.src/foo.py:run_pipeline)calibration_lineage— required field encoding how this verification's calibration relates to prior calibrations on the same spec. Must take exactly one of three forms:- (a) Extension — cite a prior
bp-NNNentry ID whose calibration this extends, AND name what was PRESERVED from that calibration AND what was CHANGED. Example:"extends bp-007: preserved threshold=0.85, changed window from 5m to 15m". - (b) Scratch — the literal string
"scratch"PLUS an explicit retirement reason citing every priorbp-NNNentry on the samespec_updatedwhose calibration is being abandoned. Example:"scratch — retires bp-003 and bp-007: prior calibration coupled to deprecated input shape". If no prior calibrations exist on this spec, scratch is permitted with the reason"no prior calibration on this spec". - (c) Null —
nullis acceptable ONLY when the change genuinely has no calibration surface (e.g. a docs-only requirement, a pure rename). This determination must be explicit, not a default: if you populatenull, thenotesfield MUST state why no calibration surface exists. Any change that tunes thresholds, windows, prompts, weights, ranking, or numeric guardrails has a calibration surface and MUST use form (a) or (b).
- (a) Extension — cite a prior
wiring_audit_pass— boolean — explicit cross-family wiring-audit verdict (per §2.4 / locked decision #5)auditor— agent or human that performed the audit (e.g."sdd-evaluator","sdd-skeptic","tyler")notes— free-form context (ornull)
Calibration discipline (per §2.3).
calibration_lineageis never a free-text afterthought. You MUST pick form (a) extension, (b) scratch with retirement reason, or (c) null with explicit no-surface justification — and you MUST NOT default tonullto silence the field. If a priorbp-NNNentry exists on the samespec_updatedand you choose (a) or (c), be prepared to defend why retirement (form b) is not warranted. Until programmatic enforcement lands inverification-check.ts, this constraint is operator-enforced — surface any ambiguous lineage call to the user before closing.Cross-family wiring audit (per locked decision #5). If you implemented the change, you MUST NOT also fill
wiring_audit_pass— route the wiring audit to a cross-family validator (e.g. hosted Anthropic if the implementer ran on a local model, or vice versa) per the project's per-project provider config. Until §2.4 ships full programmatic enforcement, this constraint is operator-enforced — surface any same-family verification path explicitly to the user before populatingwiring_audit_pass.- Invoke
sdd_verification_checkon the proposed entry. Ifstatus != "complete", refuse to close — report themissing_fieldsto the user and ask them to populate or revise. Do not write the entry until the predicate returns"complete". - If
status == "complete", write the populatedverificationrecord and the derivedverified_via_ralph: trueto the entry. The boolean is computed from record completeness +wiring_audit_pass; never set it independently. - If implementation does not produce the fix from specs alone (regression corpus regresses or the trigger reproducer still fails), close with
verification: nullandverified_via_ralph: false, and flag the spec amendment as needing further refinement.
9. Update progress
Append to progress.txt:
[{timestamp}] Backpropagation: analyzed {N} candidates, {M} spec amendments applied, {K} corpus regressions- For each amendment:
- {spec file}: added {requirement ID} from commit {hash} (category={prevent|detect|mitigate})
Output contract
- Regression corpus replayed BEFORE any new amendment is drafted
- Each manual-fix commit is analyzed, classified, and assigned a category (prevent/detect/mitigate)
- Every amendment carries a minimal reproducer and test command
- "How, not why" framing in all amendment proposals
- User approves all spec amendments (never auto-modified)
- Approved amendments are committed with
Backprop-Fromtrailers backprop-log.jsonis updated with the extended schema, including the structuredverificationfield (null at creation, populated at closure)- Closure of an entry requires
sdd_verification_checkstatus"complete";verified_via_ralphis derived from record completeness +wiring_audit_pass, never set independently - Cross-family wiring-audit constraint enforced operator-side until §2.4 ships full programmatic enforcement
- Stop-the-line triggers if ≥3 amendments to one spec in one session
progress.txtis updated
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.

