Skip to content

检查点

检查点概念

检查点(Checkpoints)允许你保存和恢复 Claude Code 的状态,类似于游戏存档。

用途:

  • 保存工作进度
  • 回滚到之前状态
  • 分支实验
  • 协作共享

保存与恢复

创建检查点

bash
You: /checkpoint save feature-complete

 Checkpoint saved: feature-complete
  Location: ~/.claude-code/checkpoints/feature-complete
  Files: 12 tracked
  Context: 2,450 tokens

恢复检查点

bash
You: /checkpoint restore feature-complete

 This will restore to checkpoint 'feature-complete'
  Created: 2026-01-21 10:30
  Files will be restored: 12
  Current changes will be backed up

Continue? (yes/no)
You: yes

 Checkpoint restored
  Backed up current state to: backup-20260121-143000

列出检查点

bash
You: /checkpoint list

Saved checkpoints:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📌 feature-complete
   2026-01-21 10:30 | 12 files

📌 before-refactor
   2026-01-20 15:00 | 8 files

📌 working-auth
   2026-01-19 09:15 | 15 files
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

最佳实践

何时创建检查点:

  • ✅ 完成重要功能前
  • ✅ 大型重构开始前
  • ✅ 实验性修改前
  • ✅ 工作日结束前

命名规范:

  • 使用描述性名称
  • 包含日期或版本
  • 例如:auth-feature-v1, pre-refactor-20260121

小结

在本章中,我们学习了:

  • ✅ 检查点概念和用途
  • ✅ 保存、恢复、列出检查点
  • ✅ 最佳实践