Skill v1.0.0
currentAutomated scan100/100name: sdd-archive description: Archive a completed change by moving its folder into $CONTEXT_ROOT/archive/ and stamping change.md with archived status metadata: version: "1.0.0"
/sdd-archive — Close a Change
Move a completed change folder from $CONTEXT_ROOT/changes/<change-id>/ to $CONTEXT_ROOT/archive/<created-date>-<change-id>/ (the same root's archive), stamp change.md with status: archived + archived_at, use git mv so file history follows, and — if a per-project roadmap $CONTEXT_ROOT/foundation/<project-slug>/roadmap.md under that root carries a roadmap item whose Change ID equals <change-id> — close that item too: flip its Status to done and append an entry to the roadmap's ## Done section.
CONTEXT_ROOT is resolved per ../sdd-shape/references/context-resolution.md (see "Resolution" below): discover every context/.sdd.yml in the repo, and — when more than one is found — let the user pick which root to archive under. A flat root resolves CONTEXT_ROOT straight to that context/ directory. A legacy (app-partitioned) root additionally resolves <app> (e.g. assets, campaigns, crm) and folds it into CONTEXT_ROOT (context/<app>) — legacy roots stay fully readable and writable by this skill; only new roots are flat.
The gate is lenient warn-only — /sdd-archive only hard-blocks on uncommitted changes inside the change folder. Everything else (incomplete Progress, missing impl-review, status not in {implemented, impl_reviewed}) is surfaced as a warning followed by a confirmation prompt; the user can still archive.
After archiving, every other sdd skill refuses to write inside $CONTEXT_ROOT/archive/… (each guarded skill checks the resolved path and aborts with a fixed message). Archived folders are read-only by convention.
Initial Response
When this command is invoked:
- Check if any argument was provided:
- If an argument was provided, parse it (see "Argument Parsing" below) and proceed to "Resolution".
- If NO argument was provided, respond with the following message and STOP:
I'll archive a completed change. Please provide a change-id (kebab-case slug) or path:Examples:/sdd-archive context-dir-restructure/sdd-archive @context/assets/changes/oauth-login/ (legacy root: CONTEXT_ROOT = context/assets)/sdd-archive @posting/context/oauth-login-change-folder/ (flat root: CONTEXT_ROOT = posting/context)You can list active changes once a root is resolved with: `ls -d "$CONTEXT_ROOT"/changes/*/`
Then wait for the user to provide an argument.
Argument Parsing
Take the first whitespace-delimited token. Normalize:
- Strip a leading
@if present. - Strip a trailing
/if present. - If the result contains
/, take the last non-empty path segment.
The result is <change-id>.
Resolution
- If the argument was a full path (e.g. a legacy-root path like
@context/assets/changes/oauth-login/, or a flat-root path like@posting/context/oauth-login-change-folder/), inheritCONTEXT_ROOTdirectly from that path — the path itself reveals which root (and, for a legacy root, which<app>) the change lives under. Use the resolved change folder directly and skip to step 2.
- Otherwise (a bare `<change-id>`),
CONTEXT_ROOTisn't known yet — resolve it per../sdd-shape/references/context-resolution.md:
- Discover every context root:
find . -name .sdd.yml -not -path '*/node_modules/*' -not -path '*/.git/*' -not -path '*/dist/*' -not -path '*/build/*' -not -path '*/.next/*' -not -path '*/coverage/*' 2>/dev/null. Each match's directory is a candidate rootR. - None found → no context root exists in the repo. Offer to run
/sdd-init, then re-run discovery. If still none, this is effectively "zero matches" below. - Search every discovered root for a
changes/<change-id>/subfolder: a flat rootRchecksR/changes/<change-id>/; a legacy rootRchecks eachR/<app>/changes/<change-id>/across its<app>subdirectories. - Exactly one match across all roots → use it. Set
CONTEXT_ROOTto that root (R, orR/<app>for a legacy match). - More than one match → the same change-id exists under multiple roots (this subsumes the old "multiple apps" case — a legacy root's several
<app>s are just more roots to pick from). Ask the user which root to archive under (use the skill's interactive prompt mechanism, showing each candidate's full path), then setCONTEXT_ROOTto the chosen one. - Zero matches → it may already be archived. Check every discovered root's
archive/*-<change-id>(flat:R/archive/*-<change-id>; legacy:R/<app>/archive/*-<change-id>) for a directory whose name ends with-<change-id>. If found, print:error: change "<change-id>" is already archived at <path>.and STOP. Otherwise print:error: no change folder named <change-id> found under any discovered context root. Runls -d "$CONTEXT_ROOT"/changes/*/(per root) to list active changes.and STOP.
Every path in the rest of this skill is $CONTEXT_ROOT/changes/<change-id>/, $CONTEXT_ROOT/archive/…, etc. — flat, with no further <app> segment, because a legacy match already folded <app> into CONTEXT_ROOT above.
- Read
$CONTEXT_ROOT/changes/<change-id>/change.mdfrontmatter (status,created).
- If
status: archived, print:error: change "<change-id>" is already archived in change.md but its folder is still under $CONTEXT_ROOT/changes/. Inspect manually before re-running.and STOP. - If
createdis missing or notYYYY-MM-DD, print:error: change.md.created is missing or malformed; cannot derive archive folder name.and STOP.
Hard refusal: uncommitted changes
Two pre-flight checks. Either failing blocks the archive.
1. Uncommitted edits inside the change folder. Run a bash command to check git status --porcelain "$CONTEXT_ROOT/changes/<change-id>/".
If the output is non-empty, block and print:
✗ Cannot archive: $CONTEXT_ROOT/changes/<change-id>/ has uncommitted changes.<one line per offending path from git status --porcelain>Commit or stash them first, then re-run /sdd-archive.
2. Pre-existing staged changes anywhere. The archive commit step (see "Move and stamp" below) bundles whatever is staged at commit time. If the user has unrelated staged changes from earlier work, they'd silently land in the archive commit (see "Commit the archive" below for the exact scope). Run a bash command to check git diff --cached --quiet.
If the exit code is non-zero, block and print:
✗ Cannot archive: pre-existing staged changes would be bundled into the archive commit.<output of `git diff --cached --name-only`>Either commit them first or `git reset` to unstage, then re-run /sdd-archive.
Either failure → STOP. Do not proceed to the warn prompt; these are hard blocks.
If git is not available or the repo is not a git repo, print: warning: not a git repository — skipping uncommitted-changes block. and continue. (Archive still works without git; we just lose history-preservation via git mv and skip the archive commit step.)
Soft warnings (non-blocking)
Collect the following warnings, then present them all at once with a single confirmation prompt.
- Status check: read
change.md.status. If it is NOT in{implemented, impl_reviewed}, queue:Status is "<status>"; expected "implemented" or "impl_reviewed". - Pending Progress check: parse the
## Progresssection of$CONTEXT_ROOT/changes/<change-id>/plan.md(ifplan.mdexists). For each### Phase N:block, identify its#### Automatedand#### Manualsubsections and count- [ ]rows under each separately. Let<X>= total automated pending across all phases,<Y>= total manual pending across all phases,<N>=<X> + <Y>.
- If the plan uses Auto/Manual subsections (any
### Phase N:block contains a#### Automatedor#### Manualheading) and<N> > 0, queue:<N> Progress items still pending (<X> automated, <Y> manual): <comma-separated list of "N.M <title>" tokens, truncated to 5 with "…" if longer>.Order the combined token list by automated items first (in document order), then manual items (in document order); the truncation cap of 5 applies to the combined list. - Legacy fallback: if no
### Phase N:block in Progress contains either#### Automatedor#### Manualheading, fall back to the original behavior — count- [ ]lines under### Phasesub-headers; if any remain, queue:<N> Progress items still pending: <comma-separated list of "N.M <title>" tokens, truncated to 5 with "…" if longer>.(no parenthetical breakdown). This preserves zero behavior change for plans authored before workflow-v2. - If
plan.mdis missing, queue:No plan.md found in change folder.and skip the Progress count.
- Missing impl-review check: glob
$CONTEXT_ROOT/changes/<change-id>/reviews/impl-review*.md. If none match, queue:No impl-review found at reviews/impl-review*.md. - Missing-SHA check: parse the
## Progresssection ofplan.md(if it exists). Count- [x]rows whose line does NOT end with— <sha>where<sha>is 7+ hexadecimal characters (i.e., the regex— [0-9a-f]{7,}$does not match). If the count is non-zero, queue:<N> Progress rows missing SHA suffix: <comma-separated "N.M <title>" tokens, truncated to 5 with "…" if longer>.SHA-less rows are legitimate for empty-diff phases and for plans that completed before the SHA contract shipped — this is a soft signal, not a defect. Skip silently ifplan.mdis missing (the Pending Progress check already covered that case).
If at least one warning was queued, print:
⚠ /sdd-archive warnings for <change-id>:- <warning 1>- <warning 2>- <warning 3>
Then ask the user:
- question:
Archive "<change-id>" anyway?
header: Archive options:
- label:
Continue archiving
description: Move the folder to $CONTEXT_ROOT/archive/ despite the warnings.
- label:
Resume implementation
description: Don't archive. Suggest /sdd-implement <change-id> next.
- label:
Cancel
description: Don't archive. Exit cleanly without further action. multiSelect: false
If the Pending Progress check above queued a warning whose breakdown was exactly 0 automated, <Y> manual with <Y> ≥ 1, append (Recommended) to the Continue archiving label so the prompt visibly nudges toward archive — manual checks are often deferred-by-design, and archiving is the expected path. In all other cases (mixed pending, automated-only, legacy-fallback warning, or no Progress warning), present the labels verbatim.
- Continue archiving → proceed to "Move and stamp" below.
- Resume implementation → print
→ /sdd-implement <change-id>and copy that to clipboard viapbcopy 2>/dev/null || clip.exe 2>/dev/null || xclip -selection clipboard 2>/dev/null || true(orSet-Clipboardon PowerShell) (best effort, cross-platform). STOP. - Cancel → print
Cancelled. Folder unchanged.and STOP.
If no warnings were queued, skip the prompt and proceed directly.
Move and stamp
- Compute archive destination:
CREATED=$(awk '/^created:/ {print $2; exit}' "$CONTEXT_ROOT/changes/<change-id>/change.md")(date prefix, e.g.,2026-04-29).DEST="$CONTEXT_ROOT/archive/${CREATED}-<change-id>".- If
$DESTalready exists, print:error: archive destination "<DEST>" already exists. Inspect manually.and STOP.
- Stamp `change.md` (in place, before the move):
- Set
status: archived. - Set
archived_at: <ISO-8601 datetime, today, UTC>— produced bydate -u +"%Y-%m-%dT%H:%M:%SZ". - Set
updated: <today as YYYY-MM-DD>. - Use a file editing operation to update each of the three frontmatter lines. Do NOT touch any other field; in particular, leave
createdandchange_idalone.
- Move the folder:
- Prefer running a bash command
git mv "$CONTEXT_ROOT/changes/<change-id>" "$DEST"so history follows. - If
git mvfails (not a git repo, or git refuses for some reason), fall back to running bash commandsmkdir -p "$CONTEXT_ROOT/archive"thenmv "$CONTEXT_ROOT/changes/<change-id>" "$DEST". Print a warning if the fallback was used. - Confirm post-move:
[ -d "$DEST" ] && [ ! -d "$CONTEXT_ROOT/changes/<change-id>" ]. If either check fails, print a diagnostic and STOP.
- Stage the stamp into the rename. The edit in step 2 modified
change.mdin the working tree, butgit mvonly stages the rename with the file's HEAD content. Run a bash commandgit add "$DEST/change.md"so the frontmatter stamp lands in the same commit as the rename.
- Close the matching roadmap item — best effort; this step never blocks, never rolls back, and never prompts. A roadmap is optional; most changes won't trace to one.
The roadmap is no longer a single top-level file. It is per-project, scoped to the same CONTEXT_ROOT: $CONTEXT_ROOT/foundation/<project-slug>/roadmap.md. Locate it by globbing $CONTEXT_ROOT/foundation/*/roadmap.md and selecting the roadmap whose ## At a glance table / item body carries a Change ID equal to <change-id>. Search every roadmap under that root; a change traces to at most one. If no roadmap under the root contains the change-id (or the root has no roadmaps at all), skip this step silently. Once located, treat $CONTEXT_ROOT/foundation/<project-slug>/roadmap.md as the roadmap path in every sub-step below.
- If the glob above found no matching roadmap, skip this step silently.
- Capture whether the file is already dirty by running a bash command
git status --porcelain "$CONTEXT_ROOT/foundation/<project-slug>/roadmap.md" 2>/dev/null. (Used in sub-step 7 to decide whether to stage it into the archive commit.) - Read
$CONTEXT_ROOT/foundation/<project-slug>/roadmap.md. Look for<change-id>used as aChange ID:
- in the
## At a glancetable — the row whose Change ID column cell equals<change-id>exactly; - and in the
## Foundations/## Slicesbodies — the### <ID>: …block that contains a- **Change ID:** <change-id>line.
<ID> is that item's roadmap-local id (F-NN or S-NN); <Outcome> is the text of its - **Outcome:** line (keep a leading (foundation) if present).
- No match → print
ℹ $CONTEXT_ROOT/foundation/<project-slug>/roadmap.md has no item with Change ID "<change-id>" — roadmap left untouched.and skip the rest of this step. Match is exact-string only; a roadmap slice can spawn several changes, so a near-miss is intentionally _not_ closed. - Match found → apply the three edits below using file editing operations. Each is independent and best effort: if a target isn't where the
/sdd-roadmaptemplate puts it (hand-edited roadmap, older format), skip that sub-edit, keep going, and note what was skipped — never abort the archive over roadmap shape. Touch only the fields named here; leaveOutcome,Prerequisites,Parallel with,Risk, etc. alone.
- `## At a glance` — in the matched table row, set the Status column cell to
done. - Item body — in the
### <ID>: …block, rewrite the- **Status:**line to- **Status:** done. - `## Done` section — append one bullet under the
## Doneheading, in that section's documented format:
```
- <ID>: <Outcome> — Archived <today> →
$CONTEXT_ROOT/archive/<CREATED>-<change-id>/. Lesson: —.
```
<today> is date -u +%F (YYYY-MM-DD); <CREATED> is the value computed in step 1 of "Compute archive destination". If the roadmap has no ## Done heading, append the heading and this bullet at the end of the file.
- Bump the roadmap frontmatter: set
updated: <today as YYYY-MM-DD>. Leave every other key (created,version,status,prd_version,main_goal,top_blocker, …) untouched. If the file has no YAML frontmatter, skip this sub-step. - Stage it into the archive commit — only if
gitis available andROADMAP_PREDIRTY(sub-step 2) was empty. Then run a bash commandgit add "$CONTEXT_ROOT/foundation/<project-slug>/roadmap.md"so the roadmap close lands in the same commit as the rename + stamp. IfROADMAP_PREDIRTYwas non-empty, the file already had uncommitted edits; leave the roadmap close in the working tree and print⚠ $CONTEXT_ROOT/foundation/<project-slug>/roadmap.md had pre-existing uncommitted changes — closed roadmap item <ID> in the working tree but did NOT stage it. Commit it yourself.Ifgitis unavailable, the edit just stays in the working tree (the pre-flight already warned). - Remember
<ID>and<Outcome>for the confirmation output.
- Commit the archive. First determine the commit scope from how
CONTEXT_ROOTresolved in "Resolution":
- `CONTEXT_ROOT` resolved to a legacy (app-partitioned) root (
CONTEXT_ROOT = R/<app>) → the scope is that `<app>`:
``bash git commit -m "$(cat <<'EOF' chore(<app>): archive <change-id> EOF )" ``
This repo's commitlint enforces a fixed scope list of package/app names (assets, campaigns, crm, …) and rejects a literal archive scope, so the change-folder's app is the correct, accepted scope for these repos.
- `CONTEXT_ROOT` resolved to a flat root (the default for anything scaffolded going forward — there is no
<app>to derive a scope from) → usearchiveas the scope:
``bash git commit -m "$(cat <<'EOF' chore(archive): archive <change-id> EOF )" ``
This is the default for flat roots, not a fallback for an edge case — most new roots have no commitlint scope-enum tied to app names, so chore(archive): … is the expected form.
No body — the subject is mechanical and the diff (rename + frontmatter stamp, plus the roadmap close when one matched) is self-explanatory. Never pass --no-verify or signing-bypass flags. If a pre-commit hook fails (e.g. commitlint rejects the scope), fix the underlying issue and create a NEW commit — never bypass the hook.
Skip this step entirely if git is unavailable or the repo is not a git repo (the pre-flight already warned).
- Print confirmation:
✓ Archived <change-id>$CONTEXT_ROOT/changes/<change-id>/ → <DEST>/change.md updated:status: archivedarchived_at: <ISO datetime>updated: <today>roadmap.md: closed <ID> "<Outcome>" → Status: done, entry added to ## Done ← print only when a roadmap item matched; omit this line otherwiseCommitted as: <short SHA> chore(<app>|archive): archive <change-id> ← scope is <app> for a legacy root, "archive" for a flat rootThe folder is now read-only by convention. To start a new change: /sdd-new <new-id>
Error handling
- Any unexpected filesystem error during the move leaves the source folder in place — the staged
change.mdedits land before the move, so on partial failure the user seesstatus: archivedin$CONTEXT_ROOT/changes/<change-id>/change.mdbut the folder is still in$CONTEXT_ROOT/changes/./sdd-helpwill surface this as astatus drift: archived in wrong folderwarning. Re-running/sdd-archiveis safe: the resolution check at the top will detectstatus: archivedand ask the user to inspect manually. - Do NOT attempt rollback — the change.md edits are intent-marking, and partial state is recoverable by hand.
- The roadmap-close step ("Move and stamp" step 5) is isolated: any failure there is caught, noted in the confirmation output, and skipped. It never aborts the archive and never triggers rollback. A half-applied roadmap edit is recoverable by hand.
What this skill does NOT do
- Does not append SHAs to Progress items —
/sdd-implementis the sole writer of the SHA suffix at phase end. The archive gate enforces SHA presence as a warn-only signal (see soft-warning check 4); it never rewrites a SHA-less row. - Does not run
pnpm test/pnpm build/pnpm ci:localas a gate — the gate is lenient warn-only by design. - Does not push. The archive commit lands locally;
git pushis the user's call. - Does not rewrite the roadmap beyond closing the one matched item. When the located per-project roadmap
$CONTEXT_ROOT/foundation/<project-slug>/roadmap.mdhas an item whoseChange IDequals the archived<change-id>, this skill flips only that item'sStatus(table cell +### <ID>:body line), appends one## Donebullet, and bumps theupdated:date. It never reorders slices, recomputes the dependency graph, edits other items, or creates a roadmap that doesn't exist. No match (or no roadmap file) → roadmap untouched. - Does not write to
$CONTEXT_ROOT/archive/<...>/after the move; archived folders are read-only by convention. Other sdd skills (/sdd-research,/sdd-frame,/sdd-plan,/sdd-plan-review,/sdd-implement,/sdd-impl-review,/sdd-tdd,/sdd-goal-implement) refuse when a resolved path matches$CONTEXT_ROOT/archive/…(or, for a legacy root,context/*/archive/…). - Does not unarchive. To revisit an archived change, open a new change with
/sdd-newand reference the archived folder for context.