Archive a completed change in the experimental workflow.
-
If no change name provided, prompt for selection
Run openspec list --json to get available changes. Use the AskUserQuestion tool to let the user select.
Show only active changes (not already archived).
Include the schema used for each change if available.
IMPORTANT: Do NOT guess or auto-select a change. Always let the user choose.
-
Check artifact completion status
Run openspec status --change "<name>" --json to check artifact completion.
Parse the JSON to understand:
schemaName: The workflow being used
artifacts: List of artifacts with their status (done or other)
If any artifacts are not done:
- Display warning listing incomplete artifacts
- Use AskUserQuestion tool to confirm user wants to proceed
- Proceed if user confirms
-
Check task completion status
Read the tasks file (typically tasks.md) to check for incomplete tasks.
Count tasks marked with - [ ] (incomplete) vs - [x] (complete).
If incomplete tasks found:
- Display warning showing count of incomplete tasks
- Use AskUserQuestion tool to confirm user wants to proceed
- Proceed if user confirms
If no tasks file exists: Proceed without task-related warning.
-
Archive target assessment — identify spec merge destinations
IMPORTANT: This step MUST be completed before any spec sync or archive action.
a. Scan the change's delta specs at openspec/changes/<name>/specs/:
- List each
<capability> directory name
b. Scan the main spec library at openspec/specs/:
- List all existing capability directory names
c. Scan archived changes at openspec/changes/archive/:
- For each archived change, note its capability names (under
specs/)
d. Classify each delta spec capability:
- 🔄 Merge into existing — capability name matches an existing main spec
- 🆕 Create new — capability name not found in main specs
- ⚠️ Possible duplicate — similar name to an existing spec; ask user whether to merge or create new
e. Present the assessment to user and use AskUserQuestion tool to confirm:
- Show each capability with its classification and intended action
- Options: "Proceed", "Merge into " (redirect), or "Cancel — stop entire operation"
- If ⚠️ possible duplicate detected, explicitly ask whether to merge into existing or create new
Cancel behavior: If user chooses "Cancel" at this step, stop the entire archive process. No specs will be synced and no changes will be archived. Inform the user that no changes were made.
f. Record user's confirmed merge plan for use in Step 5.
If no delta specs exist: Skip this step entirely (no spec sync will happen).
-
Assess delta spec sync state (using confirmed merge plan)
Check for delta specs at openspec/changes/<name>/specs/. If none exist, proceed without sync prompt.
If delta specs exist:
- Using the merge plan confirmed in Step 4, compare each delta spec with its confirmed target main spec at
openspec/specs/<capability>/spec.md
- Determine what changes would be applied (adds, modifications, removals, renames)
- Show a combined summary before prompting
Prompt options:
- If changes needed: "Sync now (recommended)", "Archive without syncing"
- If already synced: "Archive now", "Sync anyway", "Cancel"
If user chooses sync, use Task tool (subagent_type: "general-purpose", prompt: "Use Skill tool to invoke openspec-sync-specs for change ''. Delta spec analysis: "). Proceed to archive regardless of choice.
-
Final confirmation and perform the archive
Before performing any file operations, show a final summary and use AskUserQuestion tool to get explicit confirmation:
## Ready to Archive: <change-name>
- Schema: <schema-name>
- Artifacts: <completion status>
- Tasks: <completion status>
- Specs: <sync status / merge plan summary>
- Archive to: openspec/changes/archive/YYYY-MM-DD-<name>/
Proceed with archive?
1. "Yes, archive now"
2. "Cancel — stop entire operation"
Cancel behavior: If user chooses "Cancel", stop the entire archive process immediately. Do NOT move any directories, and inform the user that no changes were made.
Only after user confirms "Yes", perform the archive:
Create the archive directory if it doesn't exist:
mkdir -p openspec/changes/archive
Generate target name using current date: YYYY-MM-DD-<change-name>
Check if target already exists:
- If yes: Fail with error, suggest renaming existing archive or using different date
- If no: Move the change directory to archive
mv openspec/changes/<name> openspec/changes/archive/YYYY-MM-DD-<name>
-
Display summary
Show archive completion summary including:
- Change name
- Schema that was used
- Archive location
- Whether specs were synced (if applicable), including merge destinations
- Note about any warnings (incomplete artifacts/tasks)