Skip to main content
enableFileCheckpointing is one of the query() options. It enables the CLI to take snapshots before and after tools modify files; once enabled, the caller can use q.rewindFiles(userMessageId, ...) to roll back files to the state they were in when a particular user message started processing. These two features must be used together: without checkpointing enabled, rewind is not available.

Enabling File Checkpoint

Advanced: when you also need to adjust other CLI configuration via settings query() options also accepts a settings field — either a Settings object or an absolute path string to a settings file. Its relationship with enableFileCheckpointing:
  • When passing a settings object, the SDK automatically merges general.fileCheckpointing.enabled = true — no need to write it manually.
  • When passing a settings file path string, the SDK will not rewrite the file contents; you need to configure it yourself in that file:
Just setting enableFileCheckpointing: true without passing settings is sufficient for scenarios that only need rewind.

Using Explicit User Message IDs

Rewind uses user message IDs as anchor points. For precise rollback, it’s recommended to use structured input and generate your own uuid, so the UI can reliably reference “go back to before that message.”

Dry Run Preview

A dry run lets you see whether rollback is possible, which files would be affected, and overall insertion/deletion statistics. Dry run does not modify files. The returned RewindFilesResult contains these fields:
The SDK currently only returns the list of affected files and aggregate line-level statistics in RewindFilesResult — it does not return per-file diffs. If you need per-file differences, you can read the disk contents based on filesChanged after the dry run and compare them with the checkpoint, or use git/workspace diffing tools after executing the rewind.

Executing Rewind


Failure Semantics


Options Reference


Return Value Reference


Best Practices

  • Save user message IDs: Applications that need rollback capability should save the uuid when sending messages; do not rely on UI text to look them up.
  • Dry run before rewinding: Show the impact scope first, then let the user confirm the rollback.
  • Refresh UI after rollback: Rewind only changes files, not conversation history; the UI needs to reload relevant views based on filesChanged.
  • Show error to the user on failure: The error text when canRewind=false can typically be displayed directly to end users for diagnostics.