---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://sourcecraft.dev/portal/docs/en/code-assistant/operations/agent/checkpoints.md
  - https://sourcecraft.dev/portal/docs/ru/code-assistant/operations/agent/checkpoints.md
title: Checkpoints in SourceCraft Code Assistant
description: How to use checkpoints in SourceCraft Code Assistant to safely experiment with changes and restore previous file versions.
---
> **Documentation Index:** Fetch the complete configuration index at https://sourcecraft.dev/portal/docs/en/llms.txt


# Checkpoints in SourceCraft Code Assistant

<!-- source: en/_includes/code-assistant/only-in-vscode.md -->
{% note warning %}

This feature is only available in Visual Studio Code.

{% endnote %}
<!-- endsource: en/_includes/code-assistant/only-in-vscode.md -->

While you are running tasks in Code Assistant, checkpoints automatically create file versions in your workspace, allowing you to safely explore AI suggestions and easily restore previous file versions.

With checkpoints, you can:
* Safely experiment with AI-suggested changes.
* Easily restore previous file versions.
* Compare various implementation methods.
* Revert to earlier project states without losing progress.

{% note info %}

* Checkpoints are enabled by default.
* You need Git installed to work with checkpoints. Follow [this installation guide](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
* The system auxiliary Git repository operates separately from your project's Git configuration.

{% endnote %}

## Configuration settings {#configuration-settings}

To enable checkpoints:
1. In the chat's top panel, click <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M7.199 2H8.8a.2.2 0 0 1 .2.2c0 1.808 1.958 2.939 3.524 2.034a.2.2 0 0 1 .271.073l.802 1.388a.2.2 0 0 1-.073.272c-1.566.904-1.566 3.164 0 4.069a.2.2 0 0 1 .073.271l-.802 1.388a.2.2 0 0 1-.271.073C10.958 10.863 9 11.993 9 13.8a.2.2 0 0 1-.199.2H7.2a.2.2 0 0 1-.2-.2c0-1.808-1.958-2.938-3.524-2.034a.2.2 0 0 1-.272-.073l-.8-1.388a.2.2 0 0 1 .072-.271c1.566-.905 1.566-3.165 0-4.07a.2.2 0 0 1-.073-.27l.801-1.389a.2.2 0 0 1 .272-.072C5.042 5.138 7 4.007 7 2.199c0-.11.089-.199.199-.199M5.5 2.2c0-.94.76-1.7 1.699-1.7H8.8c.94 0 1.7.76 1.7 1.7a.85.85 0 0 0 1.274.735 1.7 1.7 0 0 1 2.32.622l.802 1.388c.469.813.19 1.851-.622 2.32a.85.85 0 0 0 0 1.472 1.7 1.7 0 0 1 .622 2.32l-.802 1.388a1.7 1.7 0 0 1-2.32.622.85.85 0 0 0-1.274.735c0 .939-.76 1.7-1.699 1.7H7.2a1.7 1.7 0 0 1-1.699-1.7.85.85 0 0 0-1.274-.735 1.7 1.7 0 0 1-2.32-.622l-.802-1.388a1.7 1.7 0 0 1 .622-2.32.85.85 0 0 0 0-1.471 1.7 1.7 0 0 1-.622-2.32l.801-1.389a1.7 1.7 0 0 1 2.32-.622A.85.85 0 0 0 5.5 2.2m4 5.8a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M11 8a3 3 0 1 1-6 0 3 3 0 0 1 6 0" clip-rule="evenodd"/></svg> **Settings**.
1. On the left-hand panel, navigate to <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M5.312 4.909A1.25 1.25 0 1 1 3.19 3.593a1.25 1.25 0 0 1 2.123 1.316m-2.124 6.182a1.25 1.25 0 1 0 2.125 1.318 1.25 1.25 0 0 0-2.125-1.318M5 9.104V6.896a2.751 2.751 0 1 0-1.5 0v2.208A2.751 2.751 0 1 0 6.896 12.5H9.5a3 3 0 0 0 3-2.98V6.895a2.751 2.751 0 1 0-1.5 0V9.5A1.5 1.5 0 0 1 9.5 11H6.896A2.76 2.76 0 0 0 5 9.104m7.812-4.195a1.25 1.25 0 1 0-2.125-1.318 1.25 1.25 0 0 0 2.125 1.318" clip-rule="evenodd"/></svg> **Checkpoints**.
1. Select **Enable automatic checkpoints**.

## How checkpoints work {#how-checkpoints-work}

Code Assistant creates snapshots of your project using an auxiliary Git repository, independent from your main version control system. These snapshots, called checkpoints, are created automatically prior to any file modifications to allow undoing of unwanted changes. Checkpoints are saved at task start and before file modifications. They are not created automatically before running commands.

The system auxiliary repository stores checkpoints as Git commits, capturing:
* File content changes
* New files
* Deleted files
* Renamed files
* Binary file changes

## Working with checkpoints {#working-with-checkpoints}

The chat interface integrates checkpoints directly into your workflow.

You can see checkpoints directly in the chat history:
* The task's first checkpoint (<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M7.25 1.75v2.32a4.001 4.001 0 0 0 0 7.86v2.32a.75.75 0 0 0 1.5 0v-2.32a4.001 4.001 0 0 0 0-7.86V1.75a.75.75 0 0 0-1.5 0M8 10.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5" clip-rule="evenodd"/></svg> **Initial Checkpoint**) captures the initial state of your project.
* Before modifying files, the system creates current checkpoints (<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M7.25 1.75v2.32a4.001 4.001 0 0 0 0 7.86v2.32a.75.75 0 0 0 1.5 0v-2.32a4.001 4.001 0 0 0 0-7.86V1.75a.75.75 0 0 0-1.5 0M8 10.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5" clip-rule="evenodd"/></svg> **Checkpoint**), allowing you to roll back easily.

Each checkpoint allows you to [view](#viewing-differences) the differences between the current project state and the previous checkpoint, and [restore](#restoring-checkpoints) the project to that earlier state.

### Viewing differences {#viewing-differences}

To compare the current state of files with the previous checkpoint:
1. Find the checkpoint in the chat history.
1. Click <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="#FFF" d="M0 0h16v16H0z"/><path stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.2" d="M3 2.5h6l3 3v8H3v-11z"/><path stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.2" d="M9 2.5v3h3"/><path stroke="#000" stroke-linecap="round" stroke-width="1.2" d="M6 7.5h4m-2-2v4m-2 2h4"/></svg> **View Diff** on its right.
1. View differences in comparison mode:
    * New lines are highlighted in green.
    * Deleted lines are highlighted in red.
    * Modified files are listed with detailed descriptions.
    * File renames may sometimes go undetected as differences primarily show file content changes between commits.
    * New or deleted files are clearly highlighted.

### Restoring checkpoints {#restoring-checkpoints}

To restore your project to the state of a previous checkpoint:
1. Find the checkpoint at hand in the chat history.
1. Click <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M1.5 8a6.5 6.5 0 1 1 7.348 6.445.75.75 0 1 1-.194-1.487A5.001 5.001 0 1 0 4.5 11.57v-1.32a.75.75 0 0 1 1.5 0v3a.75.75 0 0 1-.75.75h-3a.75.75 0 0 1 0-1.5h1.06A6.48 6.48 0 0 1 1.5 8M8 4.25a.75.75 0 0 1 .75.75v2.625l1.033.775a.75.75 0 1 1-.9 1.2l-1.333-1a.75.75 0 0 1-.3-.6V5A.75.75 0 0 1 8 4.25" clip-rule="evenodd"/></svg> **Restore Checkpoint** on its right.
1. Select a restore option:
    * **Restore files**: Only restores the workspace files to the checkpoint state, leaving the chat history unchanged. This option is perfect for comparing alternative implementations while keeping the chat context, so you can switch between project states seamlessly and quickly with no confirmation needed.
    * **Restore Files & Task**: Restores workspace files and deletes all subsequent chat messages. Use this option to fully revert your code and chat to the checkpoint state. This action requires confirmation in a dialog box since it cannot be undone.

## Technical implementation {#technical-implementation}

### Checkpoint architecture {#checkpoints-architecture}

The checkpoint system features the following components:
* System auxiliary Git repository: Separate repository created specifically to track checkpoints, serving as a permanent storage for checkpoint states.
* Checkpoint service: Handles Git operations and manages states by:
  * Initializing the repository
  * Creating and saving checkpoints
  * Computing differences
  * Restoring the state
* UI components: Chat interface elements that enable working with checkpoints.

### Restoring {#restoration-process}

While restoring, Code Assistant:
* Performs a hard reset to the specified checkpoint commit.
* Copies all files from the system auxiliary repository to your workspace.
* Updates the internal checkpoint tracking state.

### Storage type {#storage-type}

Checkpoints are linked to tasks, meaning they are task-specific.

### Computing differences {#difference-calculation}

Checkpoint comparison uses Git's built-in features to compute differences and generate structured file changes:
* Modified files display changes line by line.
* Binary files are accurately recognized and processed.
* File renames may sometimes go undetected as differences primarily focus on file content changes between checkpoints.
* File creation and deletion are clearly tracked.

### File exclusion and ignore patterns {#file-exclusion-and-ignore-patterns}

The checkpoint system uses intelligent file exclusion to track only relevant files:

#### Built-in exclusions {#built-in-exclusions}

The system offers extensive built-in exclusion patterns that automatically ignore:
* Build artifacts and dependency directories (`node_modules/`, `dist/`, and `build/`).
* Media and binary files (images, video, and audio).
* Cache and temporary files (`.cache/`, `.tmp/`, and `.bak`).
* Configuration files with confidential information (`.env`).
* Large data files (archives, executables, and binary files).
* Database files and logs.

The system writes these patterns to the `.git/info/exclude` file in the auxiliary repository during initialization.

#### .gitignore support {#gitignore-support}

The checkpoint system factors in `.gitignore` patterns in your workspace:
* Files excluded via `.gitignore` will not initiate checkpoint creation.
* Excluded files will not be listed among checkpoint differences.
* Git's standard ignore rules apply when staging changes.

#### Git LFS patterns {#git-lfs-patterns}

Patterns specified in `.gitattributes` of your workspace for Git LFS are read and added to checkpoint exclusions. This helps exclude large LFS-managed files from tracking in the system auxiliary repository.

#### .codeassistantignore behavior {#codeassistantignore-behavior}

The `.codeassistantignore` file that manages AI access to your files is kept separate from checkpoint tracking.
* Files excluded via `.codeassistantignore` but not via `.gitignore` will still be tracked in checkpoints.
* You can still use checkpoints to restore changes in files inaccessible to the AI.

This separation is intentional because `.codeassistantignore` manages AI access, not file version tracking.

#### Nested Git repositories {#nested-git-repositories}

If the system detects nested Git repositories in your workspace, it disables checkpoints. To enable checkpoints, delete or move all nested repositories.

### Managing parallelism {#parallelism-management}

A dedicated extension keeps checkpoints from being created multiple times within one streaming operation. There is no special queue for Git operations.