DEV Community

Ronit Sachdev
Ronit Sachdev

Posted on

I Built ccundo: Instantly Undo Claude Code Mistakes Without Wasting Tokens

Ever had Claude Code make changes you immediately regretted? Instead of burning more tokens asking it to fix things, I built a tool to instantly undo operations.

The Problem

Claude Code is amazing, but sometimes it:

  • Edits the wrong file
  • Deletes something important
  • Makes changes you didn't expect

Your usual options suck:

  1. Ask Claude Code to undo (wastes tokens)
  2. Manual fixes (time consuming)
  3. Git reset (undoes unrelated changes)

Meet ccundo

ccundo reads Claude Code's session files and lets you selectively undo individual operations with full previews.

Quick Start

npm install -g ccundo

# In any directory where you've used Claude Code
ccundo list      # See recent operations
ccundo preview   # See what would be undone
ccundo undo      # Undo with confirmation
Enter fullscreen mode Exit fullscreen mode

Real Example

$ ccundo undo
⚠️  Cascading undo: Selecting an operation will undo it and ALL operations that came after it.
? Select operation to undo: file_edit (1 ops)

This will undo 1 operation(s):

1. file_edit - 42s ago
   Will revert file: /project/test.txt
  This is an updated test file with new content.
- Here are some additional sentences.
- This file now contains multiple lines of text.
- Each line demonstrates different content.

? Are you sure you want to undo these 1 operations? Yes

✓ File reverted: /project/test.txt
  Backup saved to: ~/.ccundo/backups/toolu_01AhVF5HYdmpAz91sUWre3te-current

Completed: 1 successful, 0 failed
Enter fullscreen mode Exit fullscreen mode

Key Features

Detailed Previews - See exactly what will change before undoing

Cascading Safety - Maintains project consistency by undoing dependent operations

Safe Backups - Creates backups before making changes

Multi-language - Full English and Japanese support

Zero Config - Works immediately with Claude Code

How It Works

ccundo automatically:

  1. Reads Claude Code session files from ~/.claude/projects/
  2. Extracts file operations and bash commands
  3. Tracks dependencies for safe cascading undo
  4. Creates backups before reverting changes

Supports undoing:

  • File edits, creations, deletions, renames
  • Directory operations
  • Bash commands (with manual intervention prompts)

Why I Built This

Last week, Claude Code made some changes I immediately knew were wrong. Instead of spending more tokens explaining what to undo, I thought "there has to be a better way to handle this."

Now when Claude Code does something unexpected, I just run ccundo undo and I'm back where I started in seconds.

Try It Out

⭐ Star the repo if you find it useful!


What tools have you built to improve your Claude Code workflow? I'd love to hear about other productivity hacks in the comments!

Top comments (0)