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

sdd-implement

Skill0 starsChanged 8 months agoMITView on GitHub

Executes the next incomplete story from prd.json using TDD with fresh context per task. Integrates with the Ralph stop hook for autonomous looping, or can be invoked manually one story at a time. Use after /sdd-plan to start building.

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. sivaprasadreddy/sdd-skills★ 32same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository13 other files it gives its agents.

The file

Show its rules and text

We split this skill into the rules it gives an agent

27 rules. About 0 are common, 12 are distinctive, and 15 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈12

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 15

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    When N > 1, the implement phase delegates to the sdd-supervisor agent, which fans out up to N stories in isolated worktrees.

    line 15
  2. Distinctive:

    If omitted, picks the highest-priority incomplete story from the runnable frontier (serial, N=1).

    line 21
  3. Very specific:

    If none found, suggest running /sdd-plan first.

    line 28
  4. Very specific:

    If $ARGUMENTS specifies a story ID, use that

    line 30
  5. Distinctive:

    If no actionable stories remain, report completion and exit

    line 33
  6. Very specific:

    Parallel dispatch (--parallel N, N > 1): When the --parallel N flag is set with N > 1, skip the single-story selection and dispatch flow …

    line 52
  7. Very specific:

    Read bindingGate from the story (default: "code" if absent).

    line 71
  8. Distinctive:

    Write a failing test that captures the acceptance criteria

    line 90
  9. Distinctive:

    Write minimal code to make the test pass

    line 91
  10. Very specific:

    Only one marker file per workspace — the file is .sdd/spec-lock (no versioning, no nesting).

    line 115
  11. Very specific:

    If the operator aborts mid-implementation (e.g., CTRL-C, session restart), the marker may be left behind.

    line 117
  12. Distinctive:

    After the implementer completes, check:

    line 122
  13. Very specific:

    If the project warrants it (complex logic, security-sensitive), optionally invoke the sdd-evaluator agent to adversarially review the …

    line 127
  14. Very specific:

    Check whether the implementer is the sole author of those gating tests.

    line 136
  15. Distinctive:

    If independently-authored outcome-assertions exist (committed prior to or by a different agent than the implementer), those are the gating …

    line 139
  16. Distinctive:

    If any check returned non-zero exit:

    line 151
  17. Distinctive:

    Do NOT mark the story done.

    line 152
  18. Distinctive:

    If all checks return zero exit, mark the story done as today.

    line 155
  19. Very specific:

    Update prd.json: set passes: true for this story, increment attempts

    line 162
  20. Distinctive:

    Commit all changes with conventional commit message and required trailers:

    line 163
  21. Very specific:

    Update context/impl/impl-{domain}.md with learnings

    line 171
  22. Very specific:

    If attempts >= maxAttempts: set notes to explain the failure, flag as escalated

    line 175
  23. Distinctive:

    Do NOT commit broken code

    line 177
  24. Distinctive:

    If the Ralph stop hook is active, it will automatically inject the next story prompt

    line 182
  25. Very specific:

    If running manually, suggest: "Run /sdd-implement again for the next story"

    line 183
  26. Very specific:

    When the Stop hook (hooks/scripts/ralph-stop-hook.sh) is active, this skill runs automatically in a loop:

    line 187
  27. Very specific:

    No modifications to context/specs/ (immutable during implementation)

    line 202

≈ “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 Implement

Execute the next story from prd.json with fresh context and TDD.

Arguments

$ARGUMENTS — optional story ID (e.g., "STORY-3") to implement a specific story, or flags:

  • --parallel N — run up to N stories concurrently on the runnable frontier (default: 1, serial). When N > 1, the implement phase delegates to the sdd-supervisor agent, which fans out up to N stories in isolated worktrees. The supervisor computes the runnable frontier — stories whose dependencies[] are all phase: "done" — and dispatches only those stories. Stories with unsatisfied dependencies are not actionable and are skipped until their deps close. Serial behavior (N=1) is unchanged from v1.1.

If omitted, picks the highest-priority incomplete story from the runnable frontier (serial, N=1).

Process

1. Locate and read prd.json

  • Find *.prd.json in spec/active/. If multiple exist, ask user which one.
  • If none found, suggest running /sdd-plan first.
  • Parse the file and identify the target story:
    • If $ARGUMENTS specifies a story ID, use that
    • Otherwise, find the highest-priority story where the story is not done and attempts < maxAttempts
    • Phase-first read (v1.1+): a story is "done" when phase == "done". Legacy PRDs without a phase field fall back to passes == true. Never read passes alone to determine done status on PRDs that carry a phase field.
    • If no actionable stories remain, report completion and exit

2. Load fresh context (critical pattern)

Load ONLY the context needed for this one story. Do NOT read unrelated specs or stories. This prevents context contamination across tasks.

Read these files:

  • The spec file at the path in prd.json.specPath — but only the sections matching this story's specRequirements IDs
  • The plan file at context/plans/plan-{slug}.md — but only the section for this story
  • The implementation tracking at context/impl/impl-{domain}.md if it exists — for learnings from previous iterations
  • progress.txt — last 20 lines only, for recent context

Do NOT read:

  • Other stories' code or implementation details
  • Unrelated specs
  • The full plan (only this story's section)

3. Delegate to sdd-implementer agent (serial) or sdd-supervisor (parallel)

Parallel dispatch (--parallel N, N > 1): When the --parallel N flag is set with N > 1, skip the single-story selection and dispatch flow below. Instead, invoke the sdd-supervisor agent with:

  • The PRD file path
  • The --parallel N value as the concurrency cap (overrides the PRD's maxConcurrency for this run)
  • The same_family_warning computed before dispatch

The supervisor reads the PRD, computes the runnable frontier (stories whose dependencies[] are all phase: "done" and attempts < maxAttempts), and fans out up to min(N, maxConcurrency) stories into isolated worktrees. After the supervisor batch completes, update prd.json and progress.txt as described in step 5. Then return — the stop hook (if active) will re-invoke for the next frontier.

Serial dispatch (N=1, default): proceed with the single-story path below.

First, compute the iteration phase from the story. Let N = story.attempts + 1 (the upcoming try, 1-indexed) and M = story.maxAttempts (default 3):

  • N == 1 → EXPLORE
  • N == M → ESCALATE
  • otherwise → REFINE

Read bindingGate from the story (default: "code" if absent). Route as follows:

  • "code" → TDD pipeline + sdd-evaluator only. The story closes when all code-gate tests pass and sdd-evaluator issues a PASS verdict. No UX gate invoked.
  • "ux" → sdd-ux-validate only. The story closes when the ux-validator manifest reports all assertions passing (pass or fail_expected). No TDD pipeline required for story close.
  • "mixed" → both gates required. The story does not close until the TDD pipeline passes AND sdd-ux-validate issues a passing manifest. Either gate failing alone is insufficient for story close.

Then extract the target repo root from the PRD: read repoRoot at the top level. If present, it's an absolute filesystem path; include it verbatim in the implementer prompt as "cd here before any Write/Edit; all story writes paths resolve relative to this directory." If absent and the story's writes paths contain a sibling-repo-looking prefix (e.g., <repo-name>/src/...), STOP and report "PRD missing repoRoot — implementer cannot disambiguate writes target" rather than proceeding. The prd.json schema documents this field; see also context/decisions/sdd-reporoot-convention-2026-04-22.md for the incident that motivated it.

Invoke the sdd-implementer agent via the Task tool with a focused prompt containing:

  • The story block from prd.json (id, title, acceptanceCriteria, specRequirements)
  • The relevant spec requirements (Given/When/Then criteria)
  • The relevant plan section (files to create/modify, complexity budget)
  • The repoRoot path (from the PRD, if set) with the instruction to cd there before any Write/Edit
  • Quality gate commands (from AGENTS.md, templates/quality-gates.yml, or auto-detected)
  • An iteration-phase directive — include exactly one of these, substituting N and M:
    • EXPLORE (N=1): "Attempt 1 of M. First try — consider multiple approaches before committing to one. Err broader here; later attempts can narrow."
    • REFINE (middle): "Attempt N of M. A previous attempt did not pass gates. Read context/impl/impl-{domain}.md and the last 20 lines of progress.txt for what was tried — narrow toward the path that got furthest. Fix what broke; do not restart from scratch."
    • ESCALATE (N=M): "FINAL attempt (N of M). Make the smallest possible change that could pass gates. Do not start a new approach. If no clear path is visible, STOP and report what is blocking — flag the story for escalation by writing to notes rather than committing speculative code."

The implementer works in the current worktree. It implements using TDD:

  1. Write a failing test that captures the acceptance criteria
  2. Write minimal code to make the test pass
  3. Refactor if needed (without changing behavior)
  4. Run quality gates

3b. Spec lock lifecycle

The spec-immutability hook (hooks/scripts/prevent-spec-edit.py) gates on the .sdd/spec-lock marker file. This skill owns the lifecycle of that marker.

On first story dispatch (when N == 1 and the feature is starting): write .sdd/spec-lock with the feature slug (or PRD project name) as its contents. This signals that /sdd-implement is active and specs must not be edited mid-flight.

# Example: write the marker when starting a feature
mkdir -p .sdd
echo "plugin-v1.1" > .sdd/spec-lock

On phase-complete (all stories are passes: true OR all remaining stories have attempts >= maxAttempts and are escalated): remove .sdd/spec-lock.

# Example: remove the marker when the feature is done
rm -f .sdd/spec-lock

Invariants:

  • Only one marker file per workspace — the file is .sdd/spec-lock (no versioning, no nesting).
  • Contents are the feature slug for human readability; the hook only checks presence, not contents.
  • If the operator aborts mid-implementation (e.g., CTRL-C, session restart), the marker may be left behind. Remove it manually to re-enable spec editing: rm .sdd/spec-lock.
  • The marker is specific to /sdd-implement. Other skills (/sdd-spec, /sdd-plan, /sdd-iterate) do not write or remove it.

4. Evaluate results

After the implementer completes, check:

  • Did quality gates pass? (Run them yourself to verify — don't trust self-reporting)
  • Were all acceptance criteria addressed?
  • Is the implementation within the complexity budget?

If the project warrants it (complex logic, security-sensitive), optionally invoke the sdd-evaluator agent to adversarially review the implementation against the spec. Cap at 2 evaluate-fix cycles.

Author–Verifier Independence at story close (C2 / Article 14)

The gating contract for story close is the plan-time outcome-assertion set (authored at /sdd-plan time, per §2.9, by an agent that is not the implementer). The implementer's own TDD tests are scaffolding only — they drive the TDD sequence but do NOT by themselves constitute the gating contract for story closure.

Before marking a story done, verify:

  1. Identify the gating test(s) — the outcome-assertions from prd.json assertions[] that this story covers (via covered_by or assertion_ids).
  2. Check whether the implementer is the sole author of those gating tests. If the gating tests were committed in the implementer's own test: commit and no independently-authored assertion file pre-exists:
    • Reject story close. Emit: "Story cannot close — gating test not independently authored. The outcome-assertion set must be authored at plan time by a non-implementer agent. The implementer's TDD scaffolding tests do not satisfy the gating contract."
    • The story remains open; escalate to the operator to supply an independently-authored assertion set.
  3. If independently-authored outcome-assertions exist (committed prior to or by a different agent than the implementer), those are the gating contract. The implementer's own TDD tests still run and must pass, but story close requires the independently-authored gate.

This rule implements Article 14 (Author–Verifier Independence) at the story-close gate: the runner/grader of the gating test must not be the sole author of it.

Story-close checks (W1.5 / goose retry.checks lift)

At story close, before marking the story done:

  1. For each command in story.checks (if any): a. Run the command in the project root. b. Capture exit code and last 200 chars of combined stdout/stderr. c. Append to story.checks_result as {cmd, exit_code, output_snippet}.
  2. If any check returned non-zero exit:
    • Do NOT mark the story done.
    • Emit: "Story cannot close — checks failed: [cmd_1: exit_X, cmd_2: exit_Y]. Fix the underlying issue or remove the check from the story (operator decision) and re-attempt close."
    • Story remains open until all checks pass or the failing check is removed.
  3. If all checks return zero exit, mark the story done as today.

Stories without checks (or with checks: []) skip this step entirely — zero regression vs. pre-W1.5 behavior. Programmatic harness enforcement (running checks outside the agent loop) is deferred; until then this is operator-enforced via skill discipline.

5. Update state

If gates pass:

  • Update prd.json: set passes: true for this story, increment attempts
  • Commit all changes with conventional commit message and required trailers:
    feat: {story title}
    
    Spec-Ref: {specPath}
    Attempt: {attempt number}
  • Append to progress.txt: [{timestamp}] Completed {story_id}: {title} (attempt {N})
  • Update context/impl/impl-{domain}.md with learnings

If gates fail:

  • Increment attempts in prd.json
  • If attempts >= maxAttempts: set notes to explain the failure, flag as escalated
  • Append to progress.txt: [{timestamp}] Failed {story_id}: {title} (attempt {N}) — {reason}
  • Do NOT commit broken code

6. Report and continue

  • Report what was accomplished (or what failed and why)
  • If the Ralph stop hook is active, it will automatically inject the next story prompt
  • If running manually, suggest: "Run /sdd-implement again for the next story"

Ralph Loop Integration

When the Stop hook (hooks/scripts/ralph-stop-hook.sh) is active, this skill runs automatically in a loop:

  1. Claude implements a story and tries to exit
  2. The stop hook detects incomplete stories in prd.json
  3. The hook blocks the exit and injects the next story prompt
  4. Claude implements the next story
  5. Repeat until all stories pass or are escalated

To activate the stop hook, install the plugin. To deactivate, remove or rename spec/active/*.prd.json.

Output contract

  • One story implemented per invocation (never multiple)
  • prd.json updated (passes/attempts)
  • Git commit with Spec-Ref and Attempt trailers (only if gates pass)
  • progress.txt updated
  • No modifications to context/specs/ (immutable during implementation)
  • Stories declaring a checks array have all checks pass before close (non-zero exit blocks) and story.checks_result records each command's outcome.

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.