comet-archive.sh is the final step in the Comet workflow. It performs all archive operations in a single atomic command, ensuring delta specs are properly synced and no cleanup steps are missed. Running it on a change that does not meet prerequisites produces a clear fatal error rather than a partial archive.
Usage
| Argument | Description |
|---|---|
<change-name> | The name of the change to archive |
--dry-run | Preview all steps without making any changes |
Prerequisites
Archive enforces three hard entry conditions and exits immediately if any is not met:| Condition | Required value |
|---|---|
phase | archive |
verify_result | pass |
archived | not true (change not already archived) |
phase: archive and verify_result: pass are set by comet-state.sh transition <name> verify-pass, which comet-guard.sh verify --apply calls after all verify-phase checks pass. That transition itself requires verification_report to point to an existing file and branch_status: handled — so by the time phase: archive is reached, those conditions are already guaranteed.
What Archive Does
Archive executes the following steps in order:Validate entry state
Reads
phase, verify_result, and archived from .comet.yaml. Exits with a fatal error if any condition is not met.Check archive target
Verifies that
openspec/changes/archive/YYYY-MM-DD-<name>/ does not already exist to prevent accidental overwrites.Sync delta specs → main specs
For each
openspec/changes/<name>/specs/<capability>/spec.md, copies the delta spec to openspec/specs/<capability>/spec.md. Creates the target directory if needed. If the main spec already exists and differs, the diff is printed to stderr before overwriting.Annotate Design Doc frontmatter
If
design_doc is set and the file exists, inserts archived-with: YYYY-MM-DD-<name> and status: final into the YAML frontmatter.Annotate Plan frontmatter
If
plan is set and the file exists, inserts archived-with: YYYY-MM-DD-<name> into the YAML frontmatter.Move change to archive
Moves
openspec/changes/<name>/ → openspec/changes/archive/YYYY-MM-DD-<name>/.Dry Run
Use--dry-run to preview all steps without making any file system changes:
Resulting File Layout
After archive completes, the change and its associated documents are finalized:Archive is typically invoked automatically by the AI agent after
/comet-verify passes. You can also trigger it manually by running /comet-archive in your AI tool, or by calling the script directly as shown above.