openspec-archiving
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSpecification Archiving
规范归档
Archives completed change proposals and merges their spec deltas into the living specification documentation.
归档已完成的变更提案,并将其规范增量合并到现行规范文档中。
Quick Start
快速入门
Archiving involves two main operations:
- Move change folder to archive with timestamp
- Merge spec deltas into living specs (ADDED/MODIFIED/REMOVED operations)
Critical rule: Verify all tasks are complete before archiving. Archiving signifies deployment and completion.
归档包含两个主要操作:
- 将变更文件夹移动到带时间戳的归档目录
- 将规范增量合并到现行规范中(包含ADDED/MODIFIED/REMOVED操作)
重要规则:归档前需验证所有任务已完成。归档意味着变更已部署并全部完成。
Workflow
工作流程
Copy this checklist and track progress:
Archive Progress:
- [ ] Step 1: Verify implementation is complete
- [ ] Step 2: Review spec deltas to merge
- [ ] Step 3: Create timestamped archive directory
- [ ] Step 4: Merge ADDED requirements into living specs
- [ ] Step 5: Merge MODIFIED requirements into living specs
- [ ] Step 6: Merge REMOVED requirements into living specs
- [ ] Step 7: Move change folder to archive
- [ ] Step 8: Validate living spec structure复制以下检查清单并跟踪进度:
Archive Progress:
- [ ] Step 1: Verify implementation is complete
- [ ] Step 2: Review spec deltas to merge
- [ ] Step 3: Create timestamped archive directory
- [ ] Step 4: Merge ADDED requirements into living specs
- [ ] Step 5: Merge MODIFIED requirements into living specs
- [ ] Step 6: Merge REMOVED requirements into living specs
- [ ] Step 7: Move change folder to archive
- [ ] Step 8: Validate living spec structureStep 1: Verify implementation is complete
步骤1:验证实施已完成
Before archiving, confirm all work is done:
bash
undefined归档前,确认所有工作已完成:
bash
undefinedCheck for IMPLEMENTED marker
Check for IMPLEMENTED marker
test -f spec/changes/{change-id}/IMPLEMENTED && echo "✓ Implemented" || echo "✗ Not implemented"
test -f spec/changes/{change-id}/IMPLEMENTED && echo "✓ Implemented" || echo "✗ Not implemented"
Review tasks
Review tasks
cat spec/changes/{change-id}/tasks.md
cat spec/changes/{change-id}/tasks.md
Check git status for uncommitted work
Check git status for uncommitted work
git status
**Ask the user**:
```markdown
Are all tasks complete and tested?
Has this change been deployed to production?
Should I proceed with archiving?git status
**询问用户**:
```markdown
Are all tasks complete and tested?
Has this change been deployed to production?
Should I proceed with archiving?Step 2: Review spec deltas to merge
步骤2:查看待合并的规范增量
Understand what will be merged:
bash
undefined了解将要合并的内容:
bash
undefinedList all spec delta files
List all spec delta files
find spec/changes/{change-id}/specs -name "*.md" -type f
find spec/changes/{change-id}/specs -name "*.md" -type f
Read each delta
Read each delta
for file in spec/changes/{change-id}/specs/**/*.md; do
echo "=== $file ==="
cat "$file"
done
**Identify**:
- Which capabilities are affected
- How many requirements are ADDED/MODIFIED/REMOVED
- Where in living specs these changes belongfor file in spec/changes/{change-id}/specs/**/*.md; do
echo "=== $file ==="
cat "$file"
done
**确认内容**:
- 哪些功能模块会受影响
- 有多少需求会被新增/修改/移除
- 这些变更在现行规范中的对应位置Step 3: Create timestamped archive directory
步骤3:创建带时间戳的归档目录
bash
undefinedbash
undefinedCreate archive with today's date
Create archive with today's date
TIMESTAMP=$(date +%Y-%m-%d)
mkdir -p spec/archive/${TIMESTAMP}-{change-id}
**Example**:
```bashTIMESTAMP=$(date +%Y-%m-%d)
mkdir -p spec/archive/${TIMESTAMP}-{change-id}
**示例**:
```bashFor change "add-user-auth" archived on Oct 26, 2025
For change "add-user-auth" archived on Oct 26, 2025
mkdir -p spec/archive/2025-10-26-add-user-auth
undefinedmkdir -p spec/archive/2025-10-26-add-user-auth
undefinedStep 4: Merge ADDED requirements into living specs
步骤4:将新增需求合并到现行规范
For each section:
## ADDED RequirementsProcess:
- Locate the target living spec file
- Append the new requirements to the end of the file
- Maintain proper markdown formatting
Example:
Source ():
spec/changes/add-user-auth/specs/authentication/spec-delta.mdmarkdown
undefined针对每个部分:
## ADDED Requirements操作流程:
- 定位目标现行规范文件
- 将新需求追加到文件末尾
- 保持原有的Markdown格式
示例:
源文件 ():
spec/changes/add-user-auth/specs/authentication/spec-delta.mdmarkdown
undefinedADDED Requirements
ADDED Requirements
Requirement: User Login
Requirement: User Login
WHEN a user submits valid credentials,
the system SHALL authenticate the user and create a session.
WHEN a user submits valid credentials,
the system SHALL authenticate the user and create a session.
Scenario: Successful Login
Scenario: Successful Login
GIVEN valid credentials
WHEN user submits login form
THEN system creates session
**Target** (`spec/specs/authentication/spec.md`):
```bashGIVEN valid credentials
WHEN user submits login form
THEN system creates session
**目标文件** (`spec/specs/authentication/spec.md`):
```bashAppend to living spec
Append to living spec
cat >> spec/specs/authentication/spec.md << 'EOF'
cat >> spec/specs/authentication/spec.md << 'EOF'
Requirement: User Login
Requirement: User Login
WHEN a user submits valid credentials,
the system SHALL authenticate the user and create a session.
WHEN a user submits valid credentials,
the system SHALL authenticate the user and create a session.
Scenario: Successful Login
Scenario: Successful Login
GIVEN valid credentials
WHEN user submits login form
THEN system creates session
EOF
undefinedGIVEN valid credentials
WHEN user submits login form
THEN system creates session
EOF
undefinedStep 5: Merge MODIFIED requirements into living specs
步骤5:将修改后的需求合并到现行规范
For each section:
## MODIFIED RequirementsProcess:
- Locate the existing requirement in the living spec
- Replace the ENTIRE requirement block (including all scenarios)
- Use the complete updated text from the delta
Example using sed:
bash
undefined针对每个部分:
## MODIFIED Requirements操作流程:
- 在现行规范中找到对应的现有需求
- 替换整个需求块(包括所有场景)
- 使用增量文件中的完整更新文本
使用sed的示例:
bash
undefinedFind and replace requirement block
Find and replace requirement block
This is conceptual - actual implementation depends on structure
This is conceptual - actual implementation depends on structure
First, identify the line range of the old requirement
First, identify the line range of the old requirement
START_LINE=$(grep -n "### Requirement: User Login" spec/specs/authentication/spec.md | cut -d: -f1)
START_LINE=$(grep -n "### Requirement: User Login" spec/specs/authentication/spec.md | cut -d: -f1)
Find the end (next requirement or end of file)
Find the end (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)
grep -n "^### Requirement:" | head -1 | cut -d: -f1)
END_LINE=$(tail -n +$((START_LINE + 1)) spec/specs/authentication/spec.md |
grep -n "^### Requirement:" | head -1 | cut -d: -f1)
grep -n "^### Requirement:" | head -1 | cut -d: -f1)
Delete old requirement
Delete old requirement
sed -i "${START_LINE},${END_LINE}d" spec/specs/authentication/spec.md
sed -i "${START_LINE},${END_LINE}d" spec/specs/authentication/spec.md
Insert new requirement at same position
Insert new requirement at same position
(Extract from delta and insert)
(Extract from delta and insert)
**Manual approach** (recommended for safety):
```markdown
1. Open living spec in editor
2. Find the requirement by name
3. Delete entire block (requirement + all scenarios)
4. Paste updated requirement from delta
5. Save
**手动方法**(推荐用于确保安全):
```markdown
1. 在编辑器中打开现行规范
2. 通过名称找到对应的需求
3. 删除整个需求块(需求+所有场景)
4. 粘贴增量文件中的更新后需求
5. 保存文件Step 6: Merge REMOVED requirements into living specs
步骤6:将移除的需求合并到现行规范
For each section:
## REMOVED RequirementsProcess:
- Locate the requirement in the living spec
- Delete the entire requirement block
- Add a comment documenting the removal
Example:
bash
undefined针对每个部分:
## REMOVED Requirements操作流程:
- 在现行规范中找到对应的需求
- 删除整个需求块
- 添加一条注释记录移除信息
示例:
bash
undefinedOption 1: Delete with comment
Option 1: Delete with comment
Manually edit spec/specs/authentication/spec.md
Manually edit spec/specs/authentication/spec.md
Add deprecation comment
Add deprecation comment
echo "<!-- Requirement 'Legacy Password Reset' removed $(date +%Y-%m-%d) -->" >> spec/specs/authentication/spec.md
echo "<!-- Requirement 'Legacy Password Reset' removed $(date +%Y-%m-%d) -->" >> spec/specs/authentication/spec.md
Delete the requirement block manually or with sed
Delete the requirement block manually or with sed
**Pattern**:
```markdown
<!-- Removed 2025-10-26: User must use email-based password reset -->
~~### Requirement: SMS Password Reset~~
**格式示例**:
```markdown
<!-- Removed 2025-10-26: User must use email-based password reset -->
~~### Requirement: SMS Password Reset~~Step 7: Move change folder to archive
步骤7:将变更文件夹移动到归档目录
After all deltas are merged:
bash
undefined所有增量合并完成后:
bash
undefinedMove entire change folder to archive
Move entire change folder to archive
mv spec/changes/{change-id} spec/archive/${TIMESTAMP}-{change-id}
**Verify move succeeded**:
```bashmv spec/changes/{change-id} spec/archive/${TIMESTAMP}-{change-id}
**验证移动是否成功**:
```bashCheck archive exists
Check archive exists
ls -la spec/archive/${TIMESTAMP}-{change-id}
ls -la spec/archive/${TIMESTAMP}-{change-id}
Check changes directory is clean
Check changes directory is clean
ls spec/changes/ | grep "{change-id}" # Should return nothing
undefinedls spec/changes/ | grep "{change-id}" # Should return nothing
undefinedStep 8: Validate living spec structure
步骤8:验证现行规范结构
After merging, validate the living specs are well-formed:
bash
undefined合并完成后,验证现行规范格式是否正确:
bash
undefinedCheck requirement format
Check requirement format
grep -n "### Requirement:" spec/specs/**/*.md
grep -n "### Requirement:" spec/specs/**/*.md
Check scenario format
Check scenario format
grep -n "#### Scenario:" spec/specs/**/*.md
grep -n "#### Scenario:" spec/specs/**/*.md
Count requirements per spec
Count requirements per spec
for spec in spec/specs/**/spec.md; do
count=$(grep -c "### Requirement:" "$spec")
echo "$spec: $count requirements"
done
**Manual review**:
- Open each modified spec file
- Verify markdown formatting is correct
- Check requirements flow logically
- Ensure no duplicate requirements existfor spec in spec/specs/**/spec.md; do
count=$(grep -c "### Requirement:" "$spec")
echo "$spec: $count requirements"
done
**手动检查**:
- 打开每个被修改的规范文件
- 验证Markdown格式是否正确
- 检查需求逻辑是否连贯
- 确保没有重复的需求Merge Logic Reference
合并逻辑参考
ADDED Operation
新增操作
Action: Append to living spec
Location: End of file (before any footer/appendix)
Format: Copy requirement + all scenarios exactly as writtenAction: Append to living spec
Location: End of file (before any footer/appendix)
Format: Copy requirement + all scenarios exactly as writtenMODIFIED Operation
修改操作
Action: Replace existing requirement
Location: Find by requirement name, replace entire block
Format: Use complete updated text from delta (don't merge, replace)
Note: Old version is preserved in archiveAction: Replace existing requirement
Location: Find by requirement name, replace entire block
Format: Use complete updated text from delta (don't merge, replace)
Note: Old version is preserved in archiveREMOVED Operation
移除操作
Action: Delete requirement, add deprecation comment
Location: Find by requirement name
Format: Delete entire block, optionally add <!-- Removed YYYY-MM-DD: reason -->Action: Delete requirement, add deprecation comment
Location: Find by requirement name
Format: Delete entire block, optionally add <!-- Removed YYYY-MM-DD: reason -->RENAMED Operation (uncommon)
重命名操作(不常见)
Action: Update requirement name, keep content
Location: Find by old name, update to new name
Format: Just change the header: ### Requirement: NewName
Note: Typically use MODIFIED insteadAction: Update requirement name, keep content
Location: Find by old name, update to new name
Format: Just change the header: ### Requirement: NewName
Note: Typically use MODIFIED insteadBest Practices
最佳实践
Pattern 1: Verify Before Moving
模式1:移动前验证
Always verify delta merges before moving to archive:
bash
undefined务必在移动到归档目录前验证增量合并结果:
bash
undefinedAfter merging, check diff
After merging, check diff
git diff spec/specs/
git diff spec/specs/
Review changes
Review changes
git diff spec/specs/authentication/spec.md
git diff spec/specs/authentication/spec.md
If correct, commit
If correct, commit
git add spec/specs/
git commit -m "Merge spec deltas from add-user-auth"
git add spec/specs/
git commit -m "Merge spec deltas from add-user-auth"
Then archive
Then archive
mv spec/changes/add-user-auth spec/archive/2025-10-26-add-user-auth
undefinedmv spec/changes/add-user-auth spec/archive/2025-10-26-add-user-auth
undefinedPattern 2: Atomic Archiving
模式2:原子化归档
Archive entire changes, not individual files:
Good:
bash
undefined归档完整的变更文件夹,而非单个文件:
正确做法:
bash
undefinedMove complete change folder
Move complete change folder
mv spec/changes/add-user-auth spec/archive/2025-10-26-add-user-auth
**Bad**:
```bashmv spec/changes/add-user-auth spec/archive/2025-10-26-add-user-auth
**错误做法**:
```bashDon't cherry-pick files
Don't cherry-pick files
mv spec/changes/add-user-auth/proposal.md spec/archive/
mv spec/changes/add-user-auth/proposal.md spec/archive/
(leaves orphaned files)
(leaves orphaned files)
undefinedundefinedPattern 3: Archive Preservation
模式3:归档保存
The archive is a historical record. Never modify archived files:
markdown
❌ Don't: Edit files in spec/archive/
✓ Do: Treat archive as read-only history归档是历史记录,切勿修改归档文件:
markdown
❌ 禁止:编辑spec/archive/中的文件
✓ 正确:将归档视为只读历史Pattern 4: Git Commit Strategy
模式4:Git提交策略
Recommended commit workflow:
bash
undefined推荐的提交流程:
bash
undefinedCommit 1: Merge deltas
Commit 1: Merge deltas
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"
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
Commit 2: Archive change
git add spec/archive/ spec/changes/
git commit -m "Archive add-user-auth change"
undefinedgit add spec/archive/ spec/changes/
git commit -m "Archive add-user-auth change"
undefinedAdvanced Topics
进阶主题
For complex deltas: See reference/MERGE_LOGIC.md
Conflict resolution: If multiple changes modified the same requirement, manual merge is required.
Rollback strategy: To rollback an archive, reverse the process (move from archive back to changes, remove merged content from living specs).
针对复杂增量:参考reference/MERGE_LOGIC.md
冲突解决:如果多个变更修改了同一个需求,需要手动合并。
回滚策略:要回滚归档,逆向执行流程即可(将文件从归档移回变更目录,从现行规范中移除已合并的内容)。
Common Patterns
常见模式
Pattern 1: Simple Addition
模式1:简单新增
markdown
Change adds 1 new requirement → Append to spec → Archivemarkdown
Change adds 1 new requirement → Append to spec → ArchivePattern 2: Behavioral Change
模式2:行为变更
markdown
Change modifies 1 requirement → Replace in spec → Archivemarkdown
Change modifies 1 requirement → Replace in spec → ArchivePattern 3: Deprecation
模式3:废弃
markdown
Change removes 1 requirement → Delete from spec with comment → Archivemarkdown
Change removes 1 requirement → Delete from spec with comment → ArchivePattern 4: Feature with Multiple Requirements
模式4:包含多个需求的功能
markdown
Change adds 5 requirements across 2 specs
→ Append each to respective spec
→ Verify all are merged
→ Archivemarkdown
Change adds 5 requirements across 2 specs
→ Append each to respective spec
→ Verify all are merged
→ ArchiveAnti-Patterns to Avoid
需避免的反模式
Don't:
- Archive incomplete implementations
- Merge deltas before deployment
- Modify archived files
- Skip validation after merging
- Forget to git commit merged specs
Do:
- Verify all tasks complete before archiving
- Merge deltas carefully and completely
- Treat archive as immutable history
- Validate merged specs structure
- Commit merged specs before archiving move
禁止:
- 归档未完成的实现
- 部署前合并增量
- 修改归档文件
- 合并后跳过验证
- 忘记提交合并后的规范到Git
推荐:
- 归档前验证所有任务已完成
- 仔细完整地合并增量
- 将归档视为不可变的历史
- 验证合并后的规范结构
- 移动归档前提交合并后的规范
Troubleshooting
故障排除
Issue: Merge conflict (requirement exists in living spec)
问题:合并冲突(现行规范中已存在该需求)
Solution:
markdown
1. If names match but content differs → Use MODIFIED pattern
2. If truly different requirements → Rename one
3. If duplicate by mistake → Use whichever is correct解决方案:
markdown
1. 如果名称匹配但内容不同 → 使用修改模式
2. 如果确实是不同的需求 → 重命名其中一个
3. 如果是误重复的需求 → 使用正确的版本Issue: Can't find requirement to modify/remove
问题:找不到要修改/移除的需求
Solution:
markdown
1. Search by partial name: grep -i "login" spec/specs/**/*.md
2. Check if already removed
3. Check if in different capability file解决方案:
markdown
1. 按部分名称搜索:grep -i "login" spec/specs/**/*.md
2. 检查该需求是否已被移除
3. 检查是否在不同的功能文件中Issue: Living spec has formatting errors after merge
问题:合并后现行规范出现格式错误
Solution:
markdown
1. Fix formatting manually
2. Re-run validation: grep -n "###" spec/specs/**/*.md
3. Ensure consistent heading levels解决方案:
markdown
1. 手动修复格式
2. 重新运行验证:grep -n "###" spec/specs/**/*.md
3. 确保标题层级一致Reference Materials
参考资料
- MERGE_LOGIC.md - Detailed merge operation rules
Token budget: This SKILL.md is approximately 480 lines, under the 500-line recommended limit.
- MERGE_LOGIC.md - 详细的合并操作规则
Token预算:本SKILL.md约480行,低于推荐的500行限制。