list_undos
Display all undo checkpoints in the stack, enabling quick identification and restoration of previous file states within Claude Code's checkpoint-based undo system.
Instructions
List all undo checkpoints in the stack
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"type": "object"
}
Implementation Reference
- src/index.ts:119-129 (handler)Handler for the 'list_undos' tool call. Retrieves the undo stack using changeTracker.listUndoStack() and formats it as a text response.case "list_undos": { const undoList = changeTracker.listUndoStack(); return { content: [ { type: "text", text: `Undo Stack:\n${undoList.join('\n\n')}`, }, ], }; }
- src/changeTracker.ts:145-175 (helper)Core implementation of listing the undo stack. Formats each checkpoint with details like files modified/created, timestamps, and highlights the next undoable checkpoint.listUndoStack(): string[] { // Deduplicate checkpoints before listing this.deduplicateCheckpoints(); if (this.undoStack.length === 0) { return ["No undo checkpoints available"]; } const list: string[] = []; this.undoStack.forEach((checkpoint, index) => { const fileCount = checkpoint.files.size; const createdFileCount = checkpoint.createdFiles.size; const totalFiles = fileCount + createdFileCount; const timeAgo = this.getTimeAgo(checkpoint.timestamp); const filesList = Array.from(checkpoint.files.keys()).map(f => ` - ${f} (modified)`).join('\n'); const createdFilesList = Array.from(checkpoint.createdFiles).map(f => ` - ${f} (created)`).join('\n'); const allFilesList = [filesList, createdFilesList].filter(Boolean).join('\n'); const isNext = index === this.undoStack.length - 1; const prefix = isNext ? "⭐ NEXT TO UNDO" : ""; list.push( `[${index + 1}] ${checkpoint.description}${prefix ? ` ${prefix}` : ""}\n` + ` Created: ${timeAgo} | Files: ${totalFiles} (${fileCount} modified, ${createdFileCount} created)\n${allFilesList}` ); }); return list; }
- src/index.ts:53-60 (registration)Tool registration in the TOOLS array, including name, description, and empty input schema. Used by ListToolsRequestSchema handler.{ name: "list_undos", description: "List all undo checkpoints in the stack", inputSchema: { type: "object", properties: {}, }, },
- src/index.ts:53-60 (schema)Input schema definition for the 'list_undos' tool (empty object, no parameters required).{ name: "list_undos", description: "List all undo checkpoints in the stack", inputSchema: { type: "object", properties: {}, }, },