Openspec archive change

From Asymmetric-al/core · View interactive version

Openspec archive change is an AI agent skill from the GitHub repository Asymmetric-al/core. Archive a completed OpenSpec change in the experimental workflow. Use when the user wants to finalize and archive a change after implementation is complete. Also use when the user says "openspec archive" or "opsx archive".

How to use this skill

Skill file

<!-- CORE-OVERLAY-START -->

This repository (Asymmetric-al/core)

These repo-owned sections sit above the official OpenSpec skill. Reconcile this

overlay after upstream refreshes before running bun run skills:sync.

Use the locally pinned CLI only: bun run openspec -- <command>. Do not invoke

@latest. Core does not use Stores. Pass an explicit change ID before any

mutating OpenSpec operation. Follow AGENTS.md and docs/ai/rules/openspec.md.

Do not bypass TDD, exact base-maia, data-access boundaries, security, or

repository checks. Do not archive unmerged or incomplete work. Do not run

openspec update against the live customized repository. Do not treat product

runtime Eve as a coding agent.

Allowed-tools metadata includes Bash(bun:*) so the local wrapper can run.

Triggers

Verify, Sync, or Archive.

workflows.

Workflow

  1. Read openspec/config.yaml, openspec/project.md, and the relevant specs

or active change.

  1. Invoke bun run openspec -- with the explicit change ID for mutating work.
  2. Keep Core TDD, UI, data-boundary, and Guardian rules in force.
  3. Leave the change active until implementation has merged.

Checklist

<!-- CORE-OVERLAY-END -->

Archive a completed change in the experimental workflow.

Project check: Before writing, run bun run openspec -- list --json and confirm the root is the Core checkout containing its local openspec/ tree. A missing root, Store declaration, or external root is a configuration error: stop before writing and report it. Do not initialize a root or select an external Store.

<capability-path> is the spec directory relative to specs/ (for example, user-auth or identity/user-auth). Preserve the full path from each delta spec when resolving its main spec.

Input: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.

Steps

  1. Select the change

If a name is provided, use it. Otherwise:

When prompting, show only active changes (not already archived).

Include the schema used for each change if available.

Always announce: "Using change: <name>" and how to override (e.g., openspec-archive-change <other>).

Load current archive inputs before the existing archive checks:

After resolving the selected change and planning root, run:

```bash

openspec instructions archive --change "<name>" --json

```

Keep the same selected-root flags on this command. This lookup is advisory and

optional: it only supplies extra prompt inputs, so it must never block archiving.

If it exits non-zero or returns invalid JSON — for example on an older CLI that

does not support this command yet — continue the archive workflow with no

context and no operation guidance. Do not report an error and do not stop.

A successful response may omit both optional fields. Treat context as a

required prompt-level input: read and consider it, and apply relevant project

facts, conventions, and constraints. Treat operationGuidance as optional

additive advice: read and consider every entry, and follow entries that are

applicable and compatible with the built-in archive workflow.

Keep both fields separate from built-in steps, explicit user choices, resolved

paths, CLI checks, and command contracts. If context conflicts with one of those

controlling inputs, report the conflict and preserve the controlling value. If

guidance is inapplicable or conflicts with a controlling input, do not follow it

and explain why. Do not infer replacement paths, skipped prompts, or flags from

either field, and do not copy their text verbatim into specs, change artifacts,

or archive summaries unless the user separately asks for it. These are

prompt-level behavior contracts, not enforceable checks.

  1. Check artifact completion status

Run openspec status --change "<name>" --json to check artifact completion.

Parse the JSON to understand:

If any artifacts are neither done nor skipped (skipped artifacts satisfy the requirement - the change declares skip_specs):

  1. Check task completion status

Run openspec list --json with the same selected-root flags and find the

entry in changes whose name exactly matches the selected change.

Require exactly one match and nonnegative integer totalTasks and

completedTasks, with completedTasks <= totalTasks. The CLI resolves

the schema's tracked task files, including custom artifact names, output

paths, and globs.

Incomplete tasks = totalTasks - completedTasks.

Do not infer task completion from artifact status or the absence of a

top-level tasks.md. If the lookup fails, returns invalid JSON, omits or

duplicates the selected change, or returns invalid counts, report the problem

and stop before syncing or archiving.

The CLI counts only x/X checkbox markers as complete;

other markers, including unfamiliar ones, remain incomplete.

If incomplete tasks found:

If totalTasks is zero: Proceed without a task-related warning.

  1. Assess delta spec sync state

Check the archive target first: Record the target name as <target-name>: use the change name as-is when it already starts with a YYYY-MM-DD- prefix; otherwise prepend the current date as YYYY-MM-DD-<change-name>. Never stack a second date (same rule as openspec archive).

If <planningHome.changesDir>/archive/<target-name> already exists, stop before writing any main spec. Report the collision, name any main specs this run already synced, leave changeRoot where it is, and suggest renaming the existing archive or this change.

Use artifactPaths.specs.existingOutputPaths from status JSON as the only

delta-spec source. If the specs entry is missing or

existingOutputPaths is empty, proceed without a sync prompt and do not infer

delta specs from other artifacts.

If delta specs exist:

Prompt options:

Route on the answer:

Check the archive target again now. If <planningHome.changesDir>/archive/<target-name> exists, stop before writing any main spec, leave changeRoot where it is, and suggest renaming the existing archive or this change.

Before a selected sync writes any main spec, run

openspec instructions specs --change "<name>" --json once with the same

selected-root flags. Require a zero exit status and valid artifact-instruction

JSON. If the lookup fails or returns invalid JSON, report the error and stop

before writing any main spec or moving the change. A valid response with omitted

rules is the no-rules case. Apply returned rules only to the content and

form of main specs produced by this merge; do not use them as archive guidance,

change CLI behavior, or copy the rule text into any output file.

Then run the openspec-sync-specs workflow inline if that skill is installed, or otherwise perform the delta-to-main-spec merge inline yourself (an agent-driven intelligent merge either way) for change '<name>', passing the delta spec analysis and the fetched specs-rule snapshot from above, and wait for it to finish. The inline sync must reuse that snapshot without fetching specs instructions again. Do not delegate it to a background task — step 5 would move changeRoot out from under a sync that is still reading it, leaving the change archived and the main specs never updated. If your agent can only run it by delegation, delegate synchronously and wait for the result.

If the sync reports any stop or blocking condition, treat the sync as failed.

Stop the archive immediately. Do not perform the post-sync content comparison and do not move its changeRoot.

Nothing has moved, so the user can fix the blocking condition or re-run the sync.

After the sync writes each main spec, verify its structure against the canonical sync contract:

Then re-run the comparison from the top of this step, including the explicitly retired, missing-spec case, against every capability that has a delta spec in artifactPaths.specs.existingOutputPaths — not only the ones the sync reports it touched. A successful sync leaves nothing left to apply, so each capability must now read as already synced:

If the sync failed, or any capability does not match, report what differs and stop — do not archive. Nothing has moved and changeRoot is intact, so the user can fix the mismatch or re-run the sync and start the archive again.

  1. Perform the archive

Create an archive directory under planningHome.changesDir if it doesn't exist:

```bash

mkdir -p "<planningHome.changesDir>/archive"

```

Use the <target-name> recorded in step 4, unchanged.

Check again immediately before the move:

```bash

mv "<changeRoot>" "<planningHome.changesDir>/archive/<target-name>"

```

  1. Display summary

Show archive completion summary including:

Output On Success

## Archive Complete

**Change:** <change-name>
**Schema:** <schema-name>
**Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
**Specs:** <"✓ Synced to main specs" only if the step 4 verification passed; otherwise "No delta specs" or "Sync skipped">

<"All artifacts complete. All tasks complete." — or, if archived with warnings, list them instead (e.g. "Archived with 2 incomplete tasks")>

Guardrails

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.