Ccundo: Smart Undo and Redo Tool for Claude Code Sessions

7月8日 Published inAI Tools

Ccundo introduces intelligent undo and redo functionality to Claude Code by directly parsing native session files. The tool tracks every file creation, edit, deletion, rename, and directory change. Before any action is finalized, Ccundo provides a detailed preview of the changes. Its cascade system ensures project integrity: reverting a specific action automatically rolls back all subsequent operations to prevent state conflicts. The redo system follows the same logical chain. Ccundo also monitors bash commands and generates a secure backup before any modification is applied. The tool supports English and Japanese natively and requires no configuration files. You can also switch between multiple Claude Code sessions with ease.

Key Features

  • Automatic Detection: Parses Claude Code session files without manual setup.
  • Detailed Previews: Inspect every modification before committing to an undo or redo.
  • Cascade Undo/Redo: Dependent actions roll back or forward together to maintain a consistent project state.
  • Comprehensive Redo System: Replay reverted actions using the same cascade logic.
  • Native Multi-language Support: Includes full English and Japanese (日本語) localizations.
  • Smart Tracking: Monitors file edits, new file creations, deletions, renames, and bash commands.
  • Secure Backups: Generates a restore point before modifying any files.
  • Zero Configuration: Fully functional immediately upon installation.

Installing Ccundo

Install the tool globally using npm:

npm install -g ccundo

Quick Start

  1. Navigate (cd) to a directory where you have used Claude Code.
  2. List recent operations:
    ccundo list
    
  3. Preview the results of an undo action:
    ccundo preview
    
  4. Confirm and revert:
    ccundo undo
    
  5. Redo a previously reverted action:
    ccundo redo
    

How to Use Ccundo

List Actions

View the history of the current Claude Code session:

ccundo list                    # Display recent active actions
ccundo list --all              # Include actions that have already been undone

Sample output:

Operations in Claude Code session:

1. [ACTIVE] file_edit - 2 minutes ago
ID: toolu_01XYZ...
File: /project/src/app.js

2. [ACTIVE] file_create - 5 minutes ago
ID: toolu_01ABC...
File: /project/src/utils.js

3. [ACTIVE] bash_command - 7 minutes ago
ID: toolu_01DEF...
Command: npm install express

Preview Changes

Inspect the effects of an undo operation without modifying any files:

ccundo preview                 # Open the interactive picker
ccundo preview <operation-id>  # Preview a specific action by ID

Previews display:

  • Diffs for file edits (comparing current vs. original content).
  • Content of deleted files that will be restored.
  • Files that will be removed if they were newly created.
  • Bash commands flagged for manual review.

Undo Actions

Revert changes with a confirmation step:

ccundo undo                    # Interactive mode with preview
ccundo undo <operation-id>     # Revert a specific operation
ccundo undo --yes              # Skip the confirmation prompt

Cascade Undo: When you select an action to revert, Ccundo also undoes every subsequent action in the timeline. This prevents the project from entering a partially broken or inconsistent state.

Redo Actions

Restore actions that were previously undone:

ccundo redo                    # Interactive picker for undone actions
ccundo redo <operation-id>     # Redo a specific action by ID
ccundo redo --yes              # Skip confirmation

Cascade Redo: When redoing an action, Ccundo also reapplies any undone actions that preceded it in the sequence to maintain the logical chain.

Session Management

Manage undo history across different projects:

ccundo sessions                # List all available project sessions
ccundo session <session-id>    # Switch context to a different session

Language Support

Ccundo persists your preferred language setting:

ccundo language                # Display current and available languages
ccundo language en             # Switch to English
ccundo language ja             # Switch to Japanese (日本語)

Supported:

  • 🇺🇸 English (en) – Default
  • 🇯🇵 Japanese (ja) – Full support

How Ccundo Works

Ccundo integrates with Claude Code through the following process:

  1. Session Parsing: It reads the .jsonl files stored in ~/.claude/projects/.
  2. Operation Extraction: It identifies file changes and bash commands from the tool usage logs.
  3. Dependency Tracking: It maps the chronological order of events to ensure cascade safety.
  4. Backup Creation: Current file states are saved to ~/.ccundo/backups/ before any changes occur.
  5. State Persistence: Undo history and user preferences are stored in ~/.ccundo/.

Supported Operation Types

Type Description Undo Action Redo Action
File Create Claude created a file Delete file (backed up) Recreate file with original content
File Edit File content modified Restore original content Reapply the edit
File Delete Claude removed a file Restore file content Delete file again (backed up)
File Rename File or folder renamed Revert to original name Reapply rename
Directory Create New folder created Remove folder Recreate folder
Directory Delete Folder removed Recreate folder Remove folder again
Bash Command Shell command executed Manual review required Manual review required

Examples

Undo a Recent File Edit

$ ccundo list
Operations in Claude Code session:

1. [ACTIVE] file_edit - 30 seconds ago
ID: toolu_01XYZ123
File: /project/src/app.js

$ ccundo preview
📋 Preview: 1 operation will be undone:

1. file_edit - 30 seconds ago
Will restore file: /project/src/app.js

- const newFeature = true;
+ const newFeature = false;
    console.log('App started');

$ ccundo undo --yes
✓ File restored: /project/src/app.js
Backup saved to: ~/.ccundo/backups/toolu_01XYZ123-current

Done: 1 succeeded, 0 failed

Cascade Undo Example

$ ccundo preview
⚠️  Cascade Undo: Reverting an operation will also undo all subsequent operations.

? Select an operation to preview:
❯ file_create - 1 minute ago (will also undo 2 operations)
file_edit - 2 minutes ago (will also undo 1 operation)
bash_command - 5 minutes ago

📋 Preview: 3 operations will be undone:

1. file_create - 1 minute ago
Will delete file: /project/new-feature.js

2. file_edit - 2 minutes ago
Will restore file: /project/app.js

3. bash_command - 5 minutes ago
Cannot automatically undo bash command: npm install new-package
Manual intervention required

Configuration

Ccundo stores configuration and metadata in ~/.ccundo/:

~/.ccundo/
├── config.json              # Language preferences
├── undone-operations.json   # Undo/redo state tracking
├── sessions/                # Local session metadata
└── backups/                 # Pre-operation file backups

Config format:

{
  "language": "en"
}

Development Setup

To contribute to Ccundo or build from source:

git clone https://github.com/RonitSachdev/ccundo.git
cd ccundo
npm install
npm link

Adding a New Language

  1. Insert new translations in src/i18n/languages.js.
  2. Update the language documentation.
  3. Verify changes by running npm run test.