Recover deleted items from trash through interactive selection.
Synopsis
Description
Recover deleted items interactively:
- Interactive Selection - Choose from available trash items
- Safe Recovery - Restores to current working directory
- Simple Process - No complex options or flags needed
No options or flags - simple and safe through interactive selection.
Examples
Basic Restoration
Interactive Flow:
? Select file to restore: (Use arrow keys)
❯ config.json.1726405815234
old-memories.jsonl.1726319122456
project-backup.1726405815234
session-transcript.log.1726302008789
After Selection:
Restored config.json.1726405815234
Restores to current directory with original name (config.json
).
Empty Trash
When trash is empty:
Output:
No selection interface appears.
Canceling Restoration
During selection:
- Press Esc or Ctrl+C to cancel
- No items are restored
- Returns to command prompt immediately
? Select file to restore: (Use arrow keys)
❯ config.json.1726405815234
old-memories.jsonl.1726319122456
^C
No output on cancellation.
How Restoration Works
File Naming
Items return to original names:
- Trash:
config.json.1726405815234
- Restored:
config.json
Timestamp suffix automatically removed.
Target Location
Restore to current working directory:
# Working in /home/user/projects/my-app
cd /home/user/projects/my-app
claude-mem restore
# File restored to: /home/user/projects/my-app/config.json
Ensure you’re in the correct directory before running claude-mem restore
.
Conflict Handling
When file exists:
- Overwrites existing file without warning
- No backup of existing file is created
- Be careful when restoring to avoid data loss
# If config.json already exists in current directory
claude-mem restore
# Selecting config.json.1726405815234 will overwrite existing config.json
Directory Restoration
Folder Recovery
Restore directories with full contents:
# Trash contains: project-backup.1726405815234/
claude-mem restore
# Restores to: ./project-backup/
# With all subdirectories and files intact
Directory Structure
Preserves directory structure:
# Original structure before deletion:
project-backup/
├── src/
│ ├── main.js
│ └── utils.js
├── docs/
│ └── readme.md
└── package.json
# After restoration:
./project-backup/
├── src/
│ ├── main.js
│ └── utils.js
├── docs/
│ └── readme.md
└── package.json
Selection Interface
Navigation
Keyboard controls:
Key | Action |
---|
↑/↓ | Navigate up/down |
Enter | Select current item |
Esc | Cancel restoration |
Ctrl+C | Cancel restoration |
Shows trash names with timestamps:
? Select file to restore:
❯ config.json.1726405815234 ← Most recent
old-memories.jsonl.1726319122456 ← Older
session-transcript.log.1726302008789 ← Oldest
Ordered by deletion time (newest first).
Use Cases
Accidental Deletion Recovery
Recover accidentally deleted files:
# Oops, deleted important config
rm config.json
# Check what's in trash
claude-mem trash-view
# Restore the file
claude-mem restore
# → Select config.json.1726405815234
# → File restored as config.json
Project Restoration
Recover project folders:
# Restore full project directory
claude-mem restore
# → Select project-backup.1726405815234
# → Full directory restored as project-backup/
Memory Recovery
Restore memory files:
# Restore accidentally deleted memory index
claude-mem restore
# → Select memories.jsonl.1726405815234
# → Memory file restored
Best Practices
Preparation
Before restoring:
-
Navigate to correct directory
cd /path/to/intended/location
-
Check existing files
ls -la # Verify what's already present
-
View trash contents
claude-mem trash-view # See what's available
Safety
Avoid conflicts:
-
Backup existing files before restoration
cp important-file.txt important-file.txt.backup
-
Use temporary directory for inspection
mkdir temp-restore
cd temp-restore
claude-mem restore
# Inspect restored files, then move to final location
-
Check file timestamps to identify correct version
claude-mem trash-view # Note deletion dates
Error Handling
Permission Denied
Permission errors:
claude-mem restore
# → Permission denied writing to current directory
Solutions:
# Check directory permissions
ls -ld .
# Fix permissions if needed
chmod 755 .
# Or move to writable directory
cd ~/Documents
claude-mem restore
Disk Space
Insufficient space:
claude-mem restore
# → No space left on device
Solutions:
# Check available space
df -h .
# Free up space or choose different directory
cd /path/with/more/space
claude-mem restore
Corrupted Trash Items
Corrupted items:
claude-mem restore
# → Error reading trash item
Solutions:
# Check trash integrity
claude-mem trash-view
# If necessary, clean corrupted items
claude-mem trash empty
Integration
With Workflow Scripts
Automate in scripts:
#!/bin/bash
# Restore to specific directory
cd /home/user/recovery/
echo "Restoring to recovery directory..."
# Note: restore command is interactive,
# so automation requires expect or similar tools
With File Management
Workflow patterns:
# 1. Check what's available
claude-mem trash-view
# 2. Navigate to target location
cd /path/to/restore/location
# 3. Restore items
claude-mem restore
# 4. Verify restoration
ls -la
Limitations
Interactive Only
- No batch restoration options
- No command-line file specification
- No scripting-friendly modes
Single Directory Target
- Always restores to current working directory
- No option to specify different target location
- No support for restoring to original location
No Conflict Resolution
- Overwrites existing files without prompting
- No backup of overwritten files
- No merge options for directories
Troubleshooting
No Items to Restore
claude-mem restore
# → Trash is empty
Possible causes:
- No files have been deleted
- Trash was previously emptied
- Items were manually removed from trash directory
Selection Interface Issues
Interface issues:
- Terminal compatibility - Ensure terminal supports interactive prompts
- SSH sessions - May not support interactive mode
- Screen/tmux - May interfere with prompt display
Restoration to Wrong Location
Wrong location:
-
Check current directory
pwd # Verify where you ran restore command
-
Find restored files
find . -name "restored-filename" -type f
-
Move to correct location
mv restored-file /correct/path/
See Also