| name | wiki-close-loop |
| description | Closes the SDD loop after a PR merges by consolidating review findings, post-review commits, and user-stated lessons into the repo-scoped wiki. Locates the preliminary wiki page by PR number, gathers post-merge context via gh CLI, then delegates to /sdd:wiki-ingest --final with cross-references back to the preliminary. Use when user says "close loop", "wiki close-loop", "post-merge ingest", "archive lessons", or after merging a PR that has a preliminary wiki entry. Do NOT use before the PR is merged — the lessons are not yet final. Do NOT use for spec/plan/tasks ingestion (that is /ship Step 9).
|
| allowed-tools | Read, Glob, Grep, Bash |
| argument-hint | [pr-number] |
| metadata | {"author":"roberto-ramirez","version":"1.0.0","category":"sdd","tags":["wiki","sdd","close-loop","post-merge","lessons"]} |
/sdd:wiki-close-loop
You are closing the SDD loop: Consolidate what happened after /ship into the wiki.
Between /ship and merge, a PR accumulates real information: review comments, CI failures, post-review commits, architectural changes the reviewer forced. This skill captures that signal as lessons-* and review-findings-* pages cross-linked to the preliminary entries.
Step 1 — Identify the PR
If the user passed a PR number as argument, use it. Otherwise infer from the current branch:
gh pr view --json number,headRefName,state,mergedAt,url,title,body
If no PR is associated with the current branch, ask the user for the PR number or a branch name to inspect.
Validate the state:
- Merged: proceed.
- Closed without merge: warn the user. Offer to skip or to write a
lessons-* page about why the PR was abandoned.
- Open: warn — this skill is intended for post-merge. Ask whether to continue anyway (the user may be archiving a long-lived PR).
Step 2 — Locate the preliminary page
Search .wiki/ for a page with matching pr_number: in frontmatter:
grep -lE "^pr_number: <PR_NUMBER>$" .wiki/*.md 2>/dev/null
You may find 0-3 preliminary pages (spec, plan, tasks-summary). Record their filenames — they become related: targets for the final pages.
If no preliminary page exists, ask the user whether to continue with a standalone final ingest (no cross-links) or to abort.
If .wiki/ does not exist, run bash "${CLAUDE_PLUGIN_ROOT}/skills/wiki-ingest/scripts/wiki-init.sh" first.
Step 3 — Gather post-merge context
Pull everything that tells the story of what changed between /ship and merge:
gh pr view <N> --json reviews,comments,reviewRequests
gh pr view <N> --json commits
gh pr diff <N> --name-only 2>/dev/null || true
Summarize for the user before writing:
- Review findings: concrete issues the reviewer flagged and how they were resolved.
- Post-review changes: commits added after the initial
/ship (fixes, refactors triggered by review).
- Open follow-ups: anything the reviewer flagged that was deferred to a future PR.
Ask the user to state the lessons — 2-5 bullets about what to remember next time. Do not fabricate these. If the user has none, skip the lessons-* page and write only review-findings-*.
Step 4 — Confirm with the user
Preview what will be written:
review-findings-YYYY-MM-DD-<slug>.md — with summary of review + post-review changes
lessons-YYYY-MM-DD-<slug>.md — only if the user provided lessons
- Cross-link via
related: to each preliminary page found in Step 2
Ask: "Proceed with final ingestion?" Wait for explicit yes. Decline = clean exit, nothing written.
Step 5 — Delegate to /sdd:wiki-ingest --final
Hand off the gathered artifacts to /sdd:wiki-ingest --final, passing:
- PR number and branch
- Preliminary page filenames (for
related:)
- Review-findings body and lessons body
- Slug derived from the preliminary page title (keeps naming consistent across the loop)
wiki-ingest handles: frontmatter, collision checks, index update, log append.
Step 6 — Offer cleanup for abandoned PRs
If Step 1 found the PR was closed-not-merged and preliminary pages exist:
Ask the user:
"PR #N was closed without merging. Delete the preliminary wiki pages (), or keep them as historical record?"
Act only on explicit confirmation. Never auto-delete.
Step 7 — Confirm
Report:
✓ Close-loop complete for PR #<N>
Final pages: <list>
Cross-linked to preliminary: <list>
Log entry appended.
Remind the user to commit the wiki changes when ready.
Gotchas
- Running before merge. A
final page implies the change is done and the lessons are settled. If the PR is still open, the lessons may change. Warn the user and let them decide.
- Fabricating lessons. The
lessons-* page must come from the user. Do not invent bullets to pad the page.
- Skipping the preliminary lookup. Always try to find the preliminary by
pr_number. Silent standalone writes break the cross-reference graph.
- Deleting preliminary pages silently. Cleanup in Step 6 is user-driven. Never auto-delete.
- Writing without confirmation. Step 4 is the checkpoint. Decline must be a clean no-op.
- Ingesting from the wrong branch. If the current branch is
main and no PR number was passed, you cannot infer which PR to close. Ask the user.
Important constraints
- Post-merge only by default. Open/closed PRs require explicit user acknowledgement.
- Delegates writes to
/sdd:wiki-ingest. This skill does not edit .wiki/ files directly.
- English content only, consistent with
.claude/rules/git-conventions.md.
- Absence of
.wiki/ is not an error — init it via wiki-init.sh before delegating.
References
- Conventions:
.claude/rules/wiki-conventions.md
- Writer:
/sdd:wiki-ingest --final
- Caller: user (manual), typically after PR merges