From speculator
Runs the Speculator delivery workflow (Gate 4 + close) for a completed spec — builds the evidence package, closes the beads epic and stories, releases the spec lock, delivers to main via merge or PR per close.strategy, and compacts the spec into SYSTEM-SPEC.md. Use when the user says "/sdlc close", "/spec close", "close the spec", "close out this spec", "finalize the feature and merge", "deliver this spec to main", "ship this spec", or when the sdlc-run pipeline reaches Phase 5. NOT for closing individual beads issues or generic "close this issue/PR" requests — those have nothing to do with the spec delivery pipeline.
How this skill is triggered — by the user, by Claude, or both
Slash command
/speculator:sdlc-closeThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
You are finalizing a feature and delivering it to main. This skill is the **single source of truth** for the close workflow — the `sdlc` router and the `sdlc-run` Phase 5 reference both delegate here.
/sdlc close — Deliver a Completed SpecYou are finalizing a feature and delivering it to main. This skill is the single source of truth for the close workflow — the sdlc router and the sdlc-run Phase 5 reference both delegate here.
The delivery method depends on the close.strategy setting in the project config (.claude/sdlc.local.md):
merge (default) — direct merge to main from the worktreepr — create a pull request to main (for environments with branch protection rules)Resolve the active spec (follow ${CLAUDE_PLUGIN_ROOT}/lib/spec-resolution.md). If the sdlc router or sdlc-run orchestrator already resolved a worktree base path, use it for all spec/evidence operations below.
The ordering below is deliberate: beads closure happens before Gate 4, because Gate 4's beads-cleanup check (evidence-package rubric check 9) requires all child stories closed — running Gate 4 first would deadlock on its own bookkeeping. The spec's status: closed frontmatter update and the lock release happen after Gate 4, because Gate 4's spec-status check expects approved or complete at verification time.
Close beads issues (before Gate 4 — its beads-cleanup check requires this):
epic field from YAML frontmatter to find the epic IDbeads dep list {epic-id})beads close {story-id}beads close {epic-id}Run Gate 4 (evidence package) — invoke gate-check skill with gate=evidence-package, passing the already-resolved worktree base path. This produces evidence/gate-4-summary.yml. If Gate 4 fails, stop and report the failing checks — do not proceed to delivery. (The beads-cleanup check passes because step 1 already closed the stories and epic; all other checks remain strict.)
Mark the spec closed and release the lock (only after Gate 4 passes):
status: closed.active file from the spec directory:
rm docs/specs/{spec-name}/.active
The lock signals an in-flight spec — it is deliberately the last bookkeeping artifact removed, after beads closure and Gate 4, so an interrupted close never leaves a spec that looks closed but still holds open work or unverified evidence.
Commit all evidence and close bookkeeping:
chore(sdlc): gate 4 — evidence package complete
Read close.strategy from the project config (.claude/sdlc.local.md). Default is merge if not set.
Determine the autonomy context before delivering — from the spec frontmatter's autonomy_mode when invoked from sdlc-run, or interactive by default:
sdlc-run in Full Auto mode): execute the delivery per close.strategy directly — run the merge or PR commands yourself, no approval prompt and no "guiding". Do not stop to instruct a human who isn't there./sdlc close in an interactive session to deliver (merge or PR)." Never print a raw git merge command for the user to run outside the close workflow.Note on executing the merge from a worktree: git checkout main fails inside a feature worktree (main is checked out in the main worktree). Execute the merge from the main worktree path instead: find it with git worktree list (first entry), then git -C {main-worktree-path} merge {worktree-branch}.
merge (default)Run the merge (if Gate 4 passes):
a. Check if we're in a worktree (git worktree list) and note the main worktree path
b. If in a worktree:
docs/specs/{feature-name}/), merges are typically clean."git -C {main-worktree-path} merge {worktree-branch} (Full Auto runs it immediately; Guided interactive runs it after approval; Guided headless exits with instructions instead)Compact into system spec (runs after merge lands on main):
spec-compactor agent (from ${CLAUDE_PLUGIN_ROOT}/agents/spec-compactor/AGENT.md) with:
spec_path: path to the closing specsystem_spec_path: {spec_dir}/SYSTEM-SPEC.md${CLAUDE_PLUGIN_ROOT}/lib/system-spec-layout.md) it instead routes behaviors to SYSTEM-SPEC-<domain>.md from the closing spec's domain: frontmatter and maintains the index's Domains-table row; single-file projects are unchanged.domain: declared — halt, never guess. This close workflow is the autonomous surface: compaction HALTS with nothing written, and you escalate listing the existing domains from the index's Domains table: "Compaction halted: no domain: declared in spec frontmatter — existing domains: {list}. Add domain: <name> to the spec and re-run compaction with /spec compact {spec-name}." Treat the halt as a compaction failure per the next bullet — the spec stays at status: closed and the delivered merge is not rolled back.status: closed — do not block the close flowMark spec as compacted (only if step 6 succeeded):
status: compactedcompacted_into: SYSTEM-SPECcompacted_date: {today's date in YYYY-MM-DD}Commit compaction changes (only if step 6 succeeded):
chore(sdlc): compact {spec_id} into SYSTEM-SPEC.mdRemind about shared files: "If you modified any shared files (.beads/, CLAUDE.md, sdlc.local.md) in the worktree, review those changes carefully during merge."
prCompact into system spec (runs on the feature branch, before PR creation):
spec-compactor agent (from ${CLAUDE_PLUGIN_ROOT}/agents/spec-compactor/AGENT.md) with:
spec_path: path to the closing specsystem_spec_path: {spec_dir}/SYSTEM-SPEC.md${CLAUDE_PLUGIN_ROOT}/lib/system-spec-layout.md) it instead routes behaviors to SYSTEM-SPEC-<domain>.md from the closing spec's domain: frontmatter and maintains the index's Domains-table row; single-file projects are unchanged.domain: declared — halt, never guess. This close workflow is the autonomous surface: compaction HALTS with nothing written, and you escalate listing the existing domains from the index's Domains table: "Compaction halted: no domain: declared in spec frontmatter — existing domains: {list}. Add domain: <name> to the spec and re-run compaction with /spec compact {spec-name}." Treat the halt as a compaction failure per the next bullet — the spec stays at status: closed and the PR flow continues.status: closed — do not block the close flowMark spec as compacted (only if step 5 succeeded):
status: compactedcompacted_into: SYSTEM-SPECcompacted_date: {today's date in YYYY-MM-DD}Commit compaction changes (only if step 5 succeeded):
chore(sdlc): compact {spec_id} into SYSTEM-SPEC.mdCreate a pull request:
a. Check if we're in a worktree (git worktree list)
b. Verify gh CLI is available:
which gh
If gh is not found, stop and tell the user: "gh CLI is required for PR creation. Install it: https://cli.github.com/ — then re-run /sdlc close."
c. Push the branch to the remote:
git push -u origin {worktree-branch}
If the push fails, surface the error and suggest: "Check your remote with git remote -v. Ensure the remote exists and you have push access."
d. Build the PR body from the gate evidence:
gate-4-summary.yml for the pipeline resultgate-1-scorecard.yml for the spec quality scoregates.*.enabled from .claude/sdlc.local.md to determine which opt-in gates rangates.eval-intent.enabled: true, a Gate 2b (eval-quality) row if gates.eval-quality.enabled: true, and a Gate 2c (comprehension) row if gates.comprehension.enabled: true. Do not list disabled opt-in gates.🔬 Quality pipeline: Speculator | Spec: {spec_id} | Score: {overall_score}
e. Create the PR:gh pr create --title "{spec_title}" --body "{composed body}" --base main
If gh pr create fails, surface the error and suggest: "Run gh auth status to verify authentication. Ensure you have repo access."
f. Report the PR URL to the user.
Remind about shared files: "If you modified any shared files (.beads/, CLAUDE.md, sdlc.local.md) in the worktree, review those changes carefully — they'll be part of the PR diff."
Worktree note: "The worktree stays active until the PR merges. After merge, clean up with git worktree remove {worktree-path}."
Provides a checklist for code reviews covering functionality, security, performance, maintainability, tests, and quality. Use for pull requests, audits, team standards, and developer training.
npx claudepluginhub dmokong/claude-plugins --plugin speculator