Files
2026-09-16 01:47:28 -07:00

83 lines
2.7 KiB
Markdown

---
name: openspec-archive-change
description: Archive a completed change after implementation. Use when the user wants to finalize and archive a change once its tasks are done.
license: MIT
compatibility: Claude Code — no external CLI required.
metadata:
author: openspec (adapted for Claude Code)
version: "1.0-claude"
source: SAP-samples/cap-agentic-engineered
---
Archive a completed change.
> **Adapted for Claude Code.** No `openspec` CLI. Archiving is a plain directory move:
> `openspec/changes/<name>/` → `openspec/changes/archive/YYYY-MM-DD-<name>/`.
**Input**: Optionally specify a change name. If omitted, prompt for selection.
**Steps**
1. **Select the change**
List active changes and let the user choose with the **AskUserQuestion tool**:
```bash
ls -1 openspec/changes 2>/dev/null | grep -v '^archive$'
```
**IMPORTANT**: Do NOT guess or auto-select. Always let the user choose (unless they
already named the change in their request).
2. **Check task completion**
Read `openspec/changes/<name>/tasks.md` and count incomplete tasks (`- [ ]`) vs
complete (`- [x]`).
- **If incomplete tasks exist:** show the count and use the **AskUserQuestion tool** to
confirm the user still wants to archive. Proceed only if confirmed.
- **If no `tasks.md` exists:** proceed without a task warning.
3. **Sync any delta specs (optional)**
If the change captured spec deltas under `openspec/changes/<name>/specs/`, compare each
with its main spec at `openspec/specs/<capability>/spec.md` and offer to apply the
changes (read both, then Edit the main spec). Options to present:
- "Sync now (recommended)" / "Archive without syncing"
If there are no delta specs, skip this step.
4. **Perform the archive**
```bash
mkdir -p openspec/changes/archive
```
Determine today's date (`date +%F` → `YYYY-MM-DD`) and build the target name
`YYYY-MM-DD-<name>`.
- **If the target already exists:** stop with an error; suggest a different date suffix
or renaming the existing archive.
- **Otherwise:** move the change folder:
```bash
mv openspec/changes/<name> openspec/changes/archive/<YYYY-MM-DD>-<name>
```
5. **Display summary**
```
## Archive Complete
**Change:** <change-name>
**Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
**Specs:** ✓ Synced to main specs (or "No delta specs" / "Sync skipped")
```
**Guardrails**
- Always prompt for change selection if not provided
- Don't block archive on warnings — inform, confirm, then proceed
- Never overwrite an existing archive target
- Show a clear summary of what happened
- If delta specs exist, run the sync assessment and show the summary before prompting