Checkpoints
Before every agent turn, CodeBuddy snapshots the affected files. If you don’t like where the turn went, revert atomically. Captures on-disk content, not just editor buffers — files you haven’t opened are protected too.
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]
D -->|Happy| E[Continue]
D -->|Revert| F[revertToCheckpoint id<br/>Restore every file to snapshot state<br/>Delete files that didn't exist yet]
F --> G[Checkpoints after this point discarded]
Before writing any file, the agent calls trackFile() to register the path. createCheckpoint() reads every tracked file from disk and stores it in memory. Files that don’t exist yet are recorded with didNotExist: true — reverting deletes them.
Snapshot shape
Section titled “Snapshot shape”| Field | Meaning |
|---|---|
id | Unique ID (ckpt-{timestamp}-{random}) |
label | Human-readable label (e.g. “Before turn 3”) |
timestamp | Unix timestamp of creation |
conversationId | Thread ID the checkpoint belongs to |
files | File snapshots — path, content, existence flag |
Reverting
Section titled “Reverting”When you revert:
- Files that existed at checkpoint time → content restored.
- Files that didn’t exist at checkpoint time → deleted (the agent created them).
- All checkpoints created after the target → discarded (no redo across a revert).
- Parent directories re-created as needed if a restored file’s parent was deleted.
Limits
Section titled “Limits”- 50 checkpoints per session. Cap reached → oldest evicted.
- In-memory only. Don’t survive editor restarts — keeps the feature lightweight, avoids disk bloat.
- Agent-touched files only. Your own manual edits outside the agent flow aren’t captured.
Commands
Section titled “Commands”| Command | Effect |
|---|---|
| Revert to Checkpoint | List checkpoints, revert to the selected one |
vs. editor undo
Section titled “vs. editor undo”Checkpoints are separate from Cmd/Ctrl+Z. Use editor undo for single-file undo of your own edits. Use checkpoints to revert multi-file agent changes atomically.
Related
Section titled “Related”- Diff review — the review step BEFORE checkpoints matter
- Concurrency queue — how agent turns queue up