Skip to main content
guidesSource-backed

File Checkpointing in Claude Agent SDK Workflows

A practical walkthrough of file checkpointing in the Claude Agent SDK: enabling it, capturing checkpoint UUIDs from user messages, rewinding files by resuming the session, multiple restore points, and the limitations you must know.

by JPette1783·added 2026-06-05·
Review first review before installing

Open the source and read safety notes before installing.

Citation facts

Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.

Source URLs
https://code.claude.com/docs/en/agent-sdk/file-checkpointing, https://github.com/JSONbored/awesome-claude/blob/main/content/guides/file-checkpointing-in-claude-agent-sdk-workflows.mdx
Safety notes
Only changes made through Write, Edit, and NotebookEdit are tracked; changes made by Bash (echo >, sed -i, rm) are NOT captured and cannot be rewound., Rewinding restores files on disk but does not rewind the conversation; history and context remain intact., Checkpoints are tied to the session that created them and cover file content only, not directory creation/move/delete; treat this as session-level undo, not version control.
Privacy notes
Checkpoint backups are stored locally for the session; they hold prior file content, so be mindful of sensitive files captured during a session., Rewinding is a local file operation and does not transmit anything beyond the normal model requests., Capturing and reusing a session ID lets you resume and rewind later; protect session IDs like other local state.
Author
JPette1783
Submitted by
JPette1783
Claim status
unclaimed
Last verified
2026-06-05

Decision playbook

Review trust signals before you adopt

Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.

Compare context
Selected

0

Current score

63

Baseline

Delta

No baseline selected

No major trust-signal divergence detected in the current selection.

Source and provenance checks

Needs review

Confirm ownership and provenance before trusting install instructions.

  • Source link availableRequired

    Open the canonical repository and verify ownership.

    Done
  • Source provenance statusRequired

    Marked as source-backed.

    Done
  • Metadata reviewed

    No reviewed flag detected in metadata.

    Pending

Safety and privacy checks

Complete

Validate risk disclosures before installation or API wiring.

  • Safety notes presentRequired

    Review the listed safety guidance before running commands.

    Done
  • Privacy notes presentRequired

    Review data handling notes before connecting accounts or secrets.

    Done
  • Trust level risk gateRequired

    Trust level does not block evaluation.

    Done

Package and install checks

Needs review

Check package metadata and artifact integrity signals.

  • Install payload available

    Install or copy payload is available for review.

    Done
  • Package verification flag

    No package verification flag provided.

    Pending
  • Checksum metadata

    No checksum provided for downloaded artifact.

    Pending

Compare-driven decision checks

Needs review

Use compare context to validate trade-offs before adoption.

  • Compare tray has multiple entries

    Add at least one more entry to compare trust differences.

    Pending
  • Baseline comparison available

    No baseline peer selected yet.

    Pending
  • Diverging trust signals identified

    No major trust-signal divergence found.

    Pending

Setup at a glance

Copy & paste

Copy-ready — paste the snippet to get started.

Adoption plan

Balanced adoption plan

Current risk score 24/100. Use staged verification before broader rollout.

Risk 24

Pre-adoption checks

Validate source and review signals before any execution.

  • Confirm source provenanceRequired

    Source URL/provenance metadata is present.

    Done
  • Confirm metadata review state

    No review metadata found; increase manual validation.

    Pending
  • Verify install payload

    Install/config payload exists and can be inspected.

    Done

Security checks

Confirm safety, privacy, and package integrity signals.

  • Review safety notesRequired

    Safety notes are present.

    Done
  • Review privacy notesRequired

    Privacy notes are present.

    Done
  • Verify package integrity metadata

    No package verification/checksum metadata.

    Pending

Rollout

Adopt in controlled steps based on the selected plan.

  • Run in isolated sandbox firstRequired

    Use a constrained sandbox and observe behavior across multiple tasks.

    Pending
  • Roll out graduallyRequired

    Roll out to a small cohort before wider usage.

    Pending
  • Set monitoring and fallback

    Define rollback path and monitor errors after adoption.

    Pending

Evidence readiness

Evidence readiness matrix · balanced

Missing required evidence: Metadata review. Risk score 31.

Risk 31

Source provenance

Present

Source repository/provenance is listed.

Required in this preset

Metadata review

Missing

Review metadata is missing.

Required in this preset

Safety notes

Present

Safety notes are present.

Required in this preset

Privacy notes

Present

Privacy notes are present.

Optional in this preset

Package integrity

Missing

Package integrity metadata is missing.

Optional in this preset

Install payload

Present

Install payload is available.

Required in this preset

Required gaps: Metadata review

Decision timeline

Decision timeline · balanced

Blocking gaps: Check metadata review status. Risk 28.

Risk 28

triage

Confirm source provenanceRequired

Source/provenance metadata is available.

Done

triage

Check metadata review statusRequired

Review metadata is missing.

Pending

verify

Review safety notesRequired

Safety notes are available.

Done

verify

Review privacy notes

Privacy notes are available.

Done

verify

Validate package integrity metadata

Package integrity metadata is missing.

Pending

rollout

Verify install payload and commandsRequired

Install payload is available.

Done

Blockers: Check metadata review status

Prerequisite readiness

Prerequisite readiness

3 prerequisites to line up before setup.

0/3 ready
Install & runtime1General2

Safety & privacy surface

Safety & privacy surface

3 safety and 3 privacy notes across 4 risk areas. Review closely: credentials & tokens, network access.

4 areas
  • SafetyGeneralOnly changes made through Write, Edit, and NotebookEdit are tracked; changes made by Bash (echo >, sed -i, rm) are NOT captured and cannot be rewound.
  • SafetyLocal filesRewinding restores files on disk but does not rewind the conversation; history and context remain intact.
  • SafetyCredentials & tokensCheckpoints are tied to the session that created them and cover file content only, not directory creation/move/delete; treat this as session-level undo, not version control.
  • PrivacyCredentials & tokensCheckpoint backups are stored locally for the session; they hold prior file content, so be mindful of sensitive files captured during a session.
  • PrivacyNetwork accessRewinding is a local file operation and does not transmit anything beyond the normal model requests.
  • PrivacyCredentials & tokensCapturing and reusing a session ID lets you resume and rewind later; protect session IDs like other local state.

Safety notes

  • Only changes made through Write, Edit, and NotebookEdit are tracked; changes made by Bash (echo >, sed -i, rm) are NOT captured and cannot be rewound.
  • Rewinding restores files on disk but does not rewind the conversation; history and context remain intact.
  • Checkpoints are tied to the session that created them and cover file content only, not directory creation/move/delete; treat this as session-level undo, not version control.

Privacy notes

  • Checkpoint backups are stored locally for the session; they hold prior file content, so be mindful of sensitive files captured during a session.
  • Rewinding is a local file operation and does not transmit anything beyond the normal model requests.
  • Capturing and reusing a session ID lets you resume and rewind later; protect session IDs like other local state.

Prerequisites

  • A recent Claude Agent SDK (Python claude-agent-sdk or TypeScript @anthropic-ai/claude-agent-sdk).
  • A session that edits files through the Write, Edit, or NotebookEdit tools.
  • The replay-user-messages extra arg set so checkpoint UUIDs appear in the stream.

Schema details

Install type
copy
Troubleshooting
Yes
Full copyable content
## Overview

File checkpointing tracks file modifications made through the Write, Edit, and
NotebookEdit tools during an Agent SDK session, so you can rewind files to a
previous state. It is useful for undoing unwanted changes, exploring
alternatives, and recovering from errors before a risky refactor.

## Enable checkpointing

Set `enableFileCheckpointing` (TS) / `enable_file_checkpointing` (Python), and add
the `replay-user-messages` extra arg so each user message in the stream carries a
checkpoint UUID:

```typescript
const opts = {
  enableFileCheckpointing: true,
  permissionMode: "acceptEdits" as const,
  extraArgs: { "replay-user-messages": null },
};
```

## Capture the checkpoint and session id

Each user message in the response stream has a `uuid` that serves as a checkpoint;
capture the first one to restore all files to their original state. Capture
`session_id` too if you want to rewind after the stream completes.

```typescript
for await (const message of response) {
  if (message.type === "user" && message.uuid && !checkpointId) checkpointId = message.uuid;
  if ("session_id" in message && !sessionId) sessionId = message.session_id;
}
```

## Rewind files

After the stream completes, resume the session with an empty prompt and call
`rewindFiles()` (TS) / `rewind_files()` (Python):

```typescript
const rewindQuery = query({ prompt: "", options: { ...opts, resume: sessionId } });
for await (const msg of rewindQuery) {
  await rewindQuery.rewindFiles(checkpointId);
  break;
}
```

You can also rewind during the stream (keep the latest UUID and rewind on a revert
condition), or from the CLI:
`claude -p --resume <session-id> --rewind-files <checkpoint-uuid>`.

## Multiple restore points

Store each user-message UUID in an array to rewind to an intermediate state (for
example, keep a refactor but undo later test changes).

## Limitations

- Write/Edit/NotebookEdit tools only; Bash-driven changes are not tracked.
- Checkpoints are tied to their session.
- File content only; directory create/move/delete is not undone.
- Local files only.

## Troubleshooting

- No UUIDs on user messages: add the `replay-user-messages` extra arg.
- "ProcessTransport is not ready for writing": rewinding after the loop finished;
  resume with an empty prompt, then call rewind on the new query.

## Source

- Rewind file changes with checkpointing: https://code.claude.com/docs/en/agent-sdk/file-checkpointing

About this resource

Overview

File checkpointing tracks file modifications made through the Write, Edit, and NotebookEdit tools during an Agent SDK session, so you can rewind files to a previous state. It is useful for undoing unwanted changes, exploring alternatives, and recovering from errors before a risky refactor.

Enable checkpointing

Set enableFileCheckpointing (TS) / enable_file_checkpointing (Python), and add the replay-user-messages extra arg so each user message in the stream carries a checkpoint UUID:

const opts = {
  enableFileCheckpointing: true,
  permissionMode: "acceptEdits" as const,
  extraArgs: { "replay-user-messages": null },
};

Capture the checkpoint and session id

Each user message in the response stream has a uuid that serves as a checkpoint; capture the first one to restore all files to their original state. Capture session_id too if you want to rewind after the stream completes.

for await (const message of response) {
  if (message.type === "user" && message.uuid && !checkpointId) checkpointId = message.uuid;
  if ("session_id" in message && !sessionId) sessionId = message.session_id;
}

Rewind files

After the stream completes, resume the session with an empty prompt and call rewindFiles() (TS) / rewind_files() (Python):

const rewindQuery = query({ prompt: "", options: { ...opts, resume: sessionId } });
for await (const msg of rewindQuery) {
  await rewindQuery.rewindFiles(checkpointId);
  break;
}

You can also rewind during the stream (keep the latest UUID and rewind on a revert condition), or from the CLI: claude -p --resume <session-id> --rewind-files <checkpoint-uuid>.

Multiple restore points

Store each user-message UUID in an array to rewind to an intermediate state (for example, keep a refactor but undo later test changes).

Limitations

  • Write/Edit/NotebookEdit tools only; Bash-driven changes are not tracked.
  • Checkpoints are tied to their session.
  • File content only; directory create/move/delete is not undone.
  • Local files only.

Troubleshooting

  • No UUIDs on user messages: add the replay-user-messages extra arg.
  • "ProcessTransport is not ready for writing": rewinding after the loop finished; resume with an empty prompt, then call rewind on the new query.

Source

Source citations

Add this badge to your README

Show that File Checkpointing in Claude Agent SDK Workflows is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.

Listed on HeyClaude
[![Listed on HeyClaude](https://heyclau.de/badge/guides/file-checkpointing-in-claude-agent-sdk-workflows.svg)](https://heyclau.de/entry/guides/file-checkpointing-in-claude-agent-sdk-workflows)

How it compares

File Checkpointing in Claude Agent SDK Workflows side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.

Field

A practical walkthrough of file checkpointing in the Claude Agent SDK: enabling it, capturing checkpoint UUIDs from user messages, rewinding files by resuming the session, multiple restore points, and the limitations you must know.

Open dossier

A practical walkthrough of Claude Code checkpointing: how automatic checkpoints capture code before each edit, how to rewind and summarize with /rewind, the difference between restore and summarize, and the limitations you must know before a risky refactor.

Open dossier

A practical walkthrough of structured outputs in the Claude Agent SDK: defining a JSON Schema via the outputFormat option, reading validated structured_output, type-safe schemas with Zod or Pydantic, and handling validation failures.

Open dossier

A practical walkthrough of using Agent Skills in the Claude Agent SDK: how skills are discovered from the filesystem via settingSources, the skills option to enable or filter them, tool access, and troubleshooting discovery.

Open dossier
Next steps
Trust
Review statusNot reviewedNot reviewedNot reviewedNot reviewed
Package trustPackage not verifiedPackage not verifiedPackage not verifiedPackage not verified
Source provenanceSource-backedSource-backedSource-backedSource-backed
SubmitterJPette1783JPette1783JPette1783JPette1783
Install riskReview firstReview firstReview firstReview first
Notes Safety ✓ Privacy ✓ Safety ✓ Privacy ✓ Safety ✓ Privacy ✓ Safety ✓ Privacy ✓
Brand
Categoryguidesguidesguidesguides
SourceSource-backedSource-backedSource-backedSource-backed
AuthorJPette1783JPette1783JPette1783JPette1783
Added2026-06-052026-06-052026-06-052026-06-05
Platforms
Harness
Source repo
Safety notesOnly changes made through Write, Edit, and NotebookEdit are tracked; changes made by Bash (echo >, sed -i, rm) are NOT captured and cannot be rewound. Rewinding restores files on disk but does not rewind the conversation; history and context remain intact. Checkpoints are tied to the session that created them and cover file content only, not directory creation/move/delete; treat this as session-level undo, not version control.Checkpoints only track files edited through Claude's file-editing tools; changes made by bash commands (rm, mv, cp) are NOT tracked and cannot be undone via rewind. External or concurrent-session edits are generally not captured unless they touch the same files; do not rely on checkpoints for those. Checkpoints are session-level local undo, not version control; commit to Git before and after risky work for permanent history.If validation does not succeed within the retry limit, the result is an error (error_max_structured_output_retries), not structured data; handle that subtype. Structured outputs constrain the final result shape, not what tools the agent may use; tool permissions still apply. Keep schemas focused: deeply nested schemas with many required fields are harder to satisfy and more likely to fail.The skills option is a context filter, not a sandbox: unlisted skills are hidden from the model but their files remain on disk and are reachable via Read and Bash. Skills are model-invoked; pair them with a tight allowedTools list (and dontAsk where appropriate) so an invoked skill cannot use more tools than intended. The allowed-tools frontmatter in SKILL.md does not apply through the SDK; control tool access with the main allowedTools option.
Privacy notesCheckpoint backups are stored locally for the session; they hold prior file content, so be mindful of sensitive files captured during a session. Rewinding is a local file operation and does not transmit anything beyond the normal model requests. Capturing and reusing a session ID lets you resume and rewind later; protect session IDs like other local state.Checkpoints and session state are stored locally and cleaned up with the session after 30 days by default. Restoring or summarizing changes session state locally; it does not transmit anything beyond the normal model requests. Summaries are AI-generated from your conversation; the original messages remain in the local transcript.The agent may use tools (search, bash) to gather data before producing output; that activity sends data to the provider and any tools you allow. Validated output is returned to your application in the final result message; handle it like any data you persist or display. Do not embed secrets in schema field descriptions; they are sent to the model as part of the request.Skill descriptions are loaded so the model can decide when to use them; keep sensitive workflow detail and secrets out of descriptions. Skills sourced from outside your project run their instructions in your sessions; review them before enabling. Skill content is sent to the model provider when a skill is invoked; treat it like any other prompt content.
Prerequisites
  • A recent Claude Agent SDK (Python claude-agent-sdk or TypeScript @anthropic-ai/claude-agent-sdk).
  • A session that edits files through the Write, Edit, or NotebookEdit tools.
  • The replay-user-messages extra arg set so checkpoint UUIDs appear in the stream.
  • Claude Code installed and a session where Claude makes edits with its file-editing tools.
  • A working understanding that checkpoints complement, not replace, Git.
  • Optional: configured cleanupPeriodDays if you want to change the 30-day retention.
  • The Claude Agent SDK installed for Python or TypeScript.
  • A JSON Schema for the output shape, or Zod (TypeScript) / Pydantic (Python) to generate one.
  • Configured provider credentials for the SDK.
  • The Claude Agent SDK installed for Python or TypeScript.
  • SKILL.md files in .claude/skills/ (project) or ~/.claude/skills/ (user).
  • A cwd that points at or below the directory containing .claude/skills/, within the same repository.
Install
Config
Citations
ClaimUnclaimedUnclaimedUnclaimedUnclaimed
Open 4 picks in the interactive comparison tool

Related guides

Signals

Loading live community signals…

More like this, weekly

A short, calm digest of reviewed Claude resources. Unsubscribe any time.