Skip to content

Checkpoints

CodeBuddy automatically snapshots your workspace before each agent turn so you can revert to any previous state. Checkpoints capture file contents on disk, not just editor buffers, so even files you haven’t opened are protected.

graph TB A["Agent turn starts"] --> B["CheckpointService.createCheckpoint()<br/>Snapshots all tracked + extra files"] B --> C["Agent executes<br/>Edits, creates, deletes files"] C --> D["User reviews changes"] D -->|"Happy"| E["Continue"] D -->|"Revert"| F["revertToCheckpoint(id)<br/>Restores every file to snapshot state<br/>Deletes files that didn't exist yet"] F --> G["Checkpoints after this point are discarded"]

Before the agent writes any file, it calls trackFile() to register the path. When createCheckpoint() runs, every tracked file is read from disk and stored in memory. Files that don’t exist yet are recorded with a didNotExist flag — reverting will delete them.

Each checkpoint stores:

FieldDescription
idUnique ID (ckpt-{timestamp}-{random})
labelHuman-readable label (e.g. “Before turn 3”)
timestampUnix timestamp of creation
conversationIdThread ID the checkpoint belongs to
filesArray of file snapshots — path, content, and existence flag

When you revert to a checkpoint:

  1. Files that existed at checkpoint time have their content restored
  2. Files that didn’t exist at checkpoint time are deleted (the agent created them)
  3. All checkpoints created after the target are discarded — you can’t redo past a revert
  4. Directories are created as needed if a restored file’s parent was deleted
  • 50 checkpoints maximum per session. Once the cap is reached, the oldest checkpoint is evicted.
  • Checkpoints are in-memory only — they don’t survive editor restarts. This keeps the feature lightweight and avoids disk bloat.
  • Only files the agent has touched are tracked. Your own manual edits outside the agent flow are not captured.
CommandWhat it does
Revert to CheckpointShows a list of checkpoints and reverts to the selected one

Checkpoints are separate from the editor’s built-in undo (Cmd+Z). Use Cmd+Z for single-file undo of your own edits. Use checkpoints to revert multi-file agent changes atomically.