ccundo: Granular Undo for Claude Code Sessions
Introducing ccundo: The Smart Undo for Claude Code Developers
In the fast-paced world of software development, mistakes happen. Whether it's an accidental deletion, an erroneous edit, or a series of changes that lead to an unstable state, the ability to undo operations is crucial. For developers using Claude Code, a new open-source project named ccundo
is set to revolutionize how you manage your code history.
What is ccundo?
ccundo
is a command-line utility designed to provide granular undo functionality specifically for Claude Code sessions. Unlike traditional version control systems that track repository-wide changes, ccundo
focuses on the individual operations performed within a Claude Code session. It directly reads Claude Code's session files, identifying and tracking every file operation—from edits, creations, and deletions to renames and even bash commands.
Key Features That Empower Your Workflow:
- Granular Control: Selectively revert individual file operations. No more blanket rollbacks; undo precisely what you need.
- Automatic Detection:
ccundo
seamlessly integrates by reading directly from Claude Code's session files, requiring zero configuration. - Detailed Previews: Before committing to an undo,
ccundo
offers comprehensive previews, showing exactly which files will be affected and the specific content changes (diffs for edits, content for restorations). - Cascading Undo: This intelligent feature ensures project consistency. If you undo an operation,
ccundo
automatically undoes all dependent operations that occurred after it, preventing orphaned files or broken references. - Multi-language Support: Currently supporting English and Japanese,
ccundo
aims to be accessible to a global developer community. - Smart Operation Tracking: It tracks a variety of operations, including
file_edit
,file_create
,file_delete
,file_rename
,directory_create
,directory_delete
, andbash_command
. - Safe Backups: Before making any changes,
ccundo
creates safe backups of the current state, so you can always recover if something goes awry. - Session Management: Easily list and switch between multiple Claude Code sessions, making it ideal for developers working on various projects simultaneously.
How It Works Under the Hood:
ccundo
achieves its powerful functionality by:
- Reading Session Files: It parses the
.jsonl
files located in~/.claude/projects/
, which contain the detailed logs of your Claude Code interactions. - Extracting Operations: It intelligently identifies tool usage events that correspond to file system modifications.
- Tracking Dependencies: By understanding the chronological order and nature of operations,
ccundo
builds a dependency graph, crucial for its cascading undo capability. - Maintaining State: It manages its own configuration and undo history in
~/.ccundo/
, ensuring persistent preferences and reliable operation tracking.
Getting Started with ccundo:
Installation is straightforward via npm:
npm install -g ccundo
Once installed, you can start using it in any directory where you've used Claude Code:
- List operations:
ccundo list
- Preview changes:
ccundo preview
- Undo operations:
ccundo undo
ccundo
provides both interactive and direct command options for these actions, giving you full control over your workflow.
Contributions Welcome!
As an open-source project, ccundo
benefits greatly from community contributions. Whether you're interested in adding new features, improving documentation, or extending language support, the GitHub repository is open for pull requests.
ccundo
is more than just an undo tool; it's a precision instrument that brings a new level of control and safety to your Claude Code development process, ensuring your projects remain consistent and recoverable, no matter the challenges.