Loading...
Loading...
Archive completed changes and merge specification differences into permanent documents. Used when changes have been deployed, are ready for archiving, or when specifications need to be updated after implementation. Trigger words include "openspec archive", "archive", "archive proposal", "merge specifications", "complete proposal", "update documents", "finalize specifications", "mark as completed".
npx skill4agent add forztf/open-skilled-sdd openspec-archiving-cnArchiving Progress:
- [ ] Step 1: Verify implementation completion
- [ ] Step 2: Review specification differences to be merged
- [ ] Step 3: Create a timestamped archive directory
- [ ] Step 4: Merge ADDED requirements into permanent specifications
- [ ] Step 5: Merge MODIFIED requirements into permanent specifications
- [ ] Step 6: Merge REMOVED requirements into permanent specifications
- [ ] Step 7: Move the change directory to archive
- [ ] Step 8: Verify permanent specification structure# Check IMPLEMENTED marker
test -f spec/changes/{change-id}/IMPLEMENTED && echo "✓ Implemented" || echo "✗ Not implemented"
# View tasks
cat spec/changes/{change-id}/tasks.json
# Check uncommitted work using git
git statusHave all tasks been completed and passed testing?
Has this change been deployed to production?
Proceed with archiving?# List all specification difference files
find spec/changes/{change-id}/specs -name "*.md" -type f
# Read each difference file
for file in spec/changes/{change-id}/specs/**/*.md; do
echo "=== $file ==="
cat "$file"
done# Create archive directory with today's date
TIMESTAMP=$(date +%Y-%m-%d)
mkdir -p spec/archive/${TIMESTAMP}-{change-id}# For "add-user-auth" change archived on 2025-10-26
mkdir -p spec/archive/2025-10-26-add-user-auth## ADDED Requirementsspec/changes/add-user-auth/specs/authentication/spec-delta.md## ADDED Requirements
### Requirement: User Login
WHEN a user submits valid credentials,
the system SHALL authenticate the user and create a session.
#### Scenario: Successful Login
GIVEN valid credentials
WHEN the user submits the login form
THEN the system creates a sessionspec/specs/authentication/spec.md# Append to permanent specification
cat >> spec/specs/authentication/spec.md << 'EOF'
### Requirement: User Login
WHEN a user submits valid credentials,
the system SHALL authenticate the user and create a session.
#### Scenario: Successful Login
GIVEN valid credentials
WHEN the user submits the login form
THEN the system creates a session
EOF## MODIFIED Requirements# Find and replace requirement block
# This is a conceptual example - actual implementation depends on structure
# First, determine the start line of the old requirement
START_LINE=$(grep -n "### Requirement: User Login" spec/specs/authentication/spec.md | cut -d: -f1)
# Find the end position (next requirement or end of file)
END_LINE=$(tail -n +$((START_LINE + 1)) spec/specs/authentication/spec.md | \
grep -n "^### Requirement:" | head -1 | cut -d: -f1)
# Delete the old requirement
sed -i "${START_LINE},${END_LINE}d" spec/specs/authentication/spec.md
# Insert the new requirement at the same position
# (Extract from difference file and insert)1. Open the permanent specification in an editor
2. Locate the target requirement by name
3. Delete the entire block (requirement + all scenarios)
4. Paste the updated requirement from the difference file in its place
5. Save## REMOVED Requirements# Option 1: Delete with comment
# Manually edit spec/specs/authentication/spec.md
# Add deprecation comment
echo "<!-- Requirement 'Legacy Password Reset' removed $(date +%Y-%m-%d) -->" >> spec/specs/authentication/spec.md
# Delete the requirement block manually or via sed<!-- Removed 2025-10-26: Users must use email-based password reset -->
~~### Requirement: SMS Password Reset~~# Move the complete change directory to archive
mv spec/changes/{change-id} spec/archive/${TIMESTAMP}-{change-id}# Check if archive exists
ls -la spec/archive/${TIMESTAMP}-{change-id}
# Check if changes directory is clean
ls spec/changes/ | grep "{change-id}" # Should return no results# Check requirement formatting
grep -n "### Requirement:" spec/specs/**/*.md
# Check scenario formatting
grep -n "#### Scenario:" spec/specs/**/*.md
# Count number of requirements in each specification
for spec in spec/specs/**/spec.md; do
count=$(grep -c "### Requirement:" "$spec")
echo "$spec: $count requirements"
doneAction: Append to permanent specification
Location: End of file (before any footnotes/appendices)
Format: Copy requirements and all scenarios exactly as writtenAction: Replace existing requirement
Location: Locate by requirement name, replace entire block
Format: Use complete updated text from difference file (no splicing, direct replacement)
Note: Old version is preserved in archiveAction: Delete requirement and add deprecation comment
Location: Locate by requirement name
Format: Delete entire block, optionally add <!-- Removed YYYY-MM-DD: reason -->Action: Update requirement name, retain content
Location: Locate by old name, update to new name
Format: Only modify the title: ### Requirement: New Name
Note: MODIFIED is typically used more often# View differences after merging
git diff spec/specs/
# Review changes
git diff spec/specs/authentication/spec.md
# Commit if correct
git add spec/specs/
git commit -m "Merge spec deltas from add-user-auth"
# Then archive
mv spec/changes/add-user-auth spec/archive/2025-10-26-add-user-auth# Move complete change directory
mv spec/changes/add-user-auth spec/archive/2025-10-26-add-user-auth# Don't pick individual files
mv spec/changes/add-user-auth/proposal.md spec/archive/
# (Leaves orphaned files)❌ Don't: Edit spec/archive/
✓ Do: Treat archives as read-only history# Commit 1: Merge differences
git add spec/specs/
git commit -m "Merge spec deltas from add-user-auth
- Added User Login requirement
- Modified Password Policy requirement
- Removed Legacy Auth requirement"
# Commit 2: Archive change
git add spec/archive/ spec/changes/
git commit -m "Archive add-user-auth change"Change adds 1 requirement → Append to specification → ArchiveChange modifies 1 requirement → Replace in specification → ArchiveChange removes 1 requirement → Delete and add comment → ArchiveChange adds 5 requirements across 2 specifications
→ Append to respective specifications
→ Verify all are merged
→ Archive1. If same name but different content → Use MODIFIED mode
2. If truly different requirements → Rename one of them
3. If it's a duplication error → Select the correct version1. Search by partial name: grep -i "login" spec/specs/**/*.md
2. Check if it was already removed
3. Check if it's located in another capability file1. Fix formatting manually
2. Re-run verification: grep -n "###" spec/specs/**/*.md
3. Ensure consistent heading levels