Initial commit: Claude Code Hooks with Diátaxis documentation
✨ Features: - 🧠 Shadow learner that builds intelligence from command patterns - 🛡️ Smart command validation with safety checks - 💾 Automatic context monitoring and backup system - 🔄 Session continuity across Claude restarts 📚 Documentation: - Complete Diátaxis-organized documentation - Learning-oriented tutorial for getting started - Task-oriented how-to guides for specific problems - Information-oriented reference for quick lookup - Understanding-oriented explanations of architecture 🚀 Installation: - One-command installation script - Bootstrap prompt for installation via Claude - Cross-platform compatibility - Comprehensive testing suite 🎯 Ready for real-world use and community feedback! 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
commit
162ca67098
34 changed files with 5904 additions and 0 deletions
176
docs/how-to/restore-backup.md
Normal file
176
docs/how-to/restore-backup.md
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
# How to Restore Your Work from a Backup
|
||||
|
||||
**When to use this guide**: Your Claude session crashed, lost context, or you need to recover previous work.
|
||||
|
||||
## Quick Recovery (Most Common)
|
||||
|
||||
If you just lost context but your files are still there:
|
||||
|
||||
1. **Check for session recovery files**:
|
||||
```bash
|
||||
ls -la | grep -E "(LAST_SESSION|ACTIVE_TODOS|RECOVERY_GUIDE)"
|
||||
```
|
||||
|
||||
2. **Read your session summary**:
|
||||
```bash
|
||||
cat LAST_SESSION.md
|
||||
```
|
||||
|
||||
3. **Continue from your todos**:
|
||||
```bash
|
||||
cat ACTIVE_TODOS.md
|
||||
```
|
||||
|
||||
This covers 90% of recovery scenarios. If you need to restore actual files, continue below.
|
||||
|
||||
## Full File Recovery
|
||||
|
||||
### Find Available Backups
|
||||
|
||||
List all available backups:
|
||||
```bash
|
||||
claude-hooks list-backups
|
||||
```
|
||||
|
||||
Or check the backups directory directly:
|
||||
```bash
|
||||
ls -la .claude_hooks/backups/
|
||||
```
|
||||
|
||||
You'll see entries like:
|
||||
```
|
||||
🗂️ backup_20240115_143022
|
||||
📅 2024-01-15T14:30:22
|
||||
📝 context_threshold
|
||||
|
||||
🗂️ backup_20240115_141856
|
||||
📅 2024-01-15T14:18:56
|
||||
📝 critical_operation
|
||||
```
|
||||
|
||||
### Choose the Right Backup
|
||||
|
||||
**For context-related crashes**: Use the most recent `context_threshold` backup
|
||||
**For command failures**: Use the backup before the problematic operation
|
||||
**For file corruption**: Use the backup with the timestamp just before your issue
|
||||
|
||||
### Restore Files from Backup
|
||||
|
||||
1. **Navigate to the backup directory**:
|
||||
```bash
|
||||
cd .claude_hooks/backups/backup_20240115_143022
|
||||
```
|
||||
|
||||
2. **Check what files are available**:
|
||||
```bash
|
||||
ls -la files/
|
||||
```
|
||||
|
||||
3. **Copy specific files back**:
|
||||
```bash
|
||||
cp files/important_script.py ../../
|
||||
```
|
||||
|
||||
Or restore all modified files:
|
||||
```bash
|
||||
cp -r files/* ../../
|
||||
```
|
||||
|
||||
### Restore from Git Backup
|
||||
|
||||
If git backups were enabled:
|
||||
|
||||
1. **Check git history**:
|
||||
```bash
|
||||
git log --oneline | grep "Claude hooks auto-backup"
|
||||
```
|
||||
|
||||
2. **See what changed in a backup commit**:
|
||||
```bash
|
||||
git show abc1234
|
||||
```
|
||||
|
||||
3. **Restore specific files**:
|
||||
```bash
|
||||
git checkout abc1234 -- path/to/file.py
|
||||
```
|
||||
|
||||
4. **Or reset to a backup completely** (careful - loses recent work):
|
||||
```bash
|
||||
git reset --hard abc1234
|
||||
```
|
||||
|
||||
## Restore Session State
|
||||
|
||||
If you want to continue exactly where you left off:
|
||||
|
||||
1. **Restore the patterns database**:
|
||||
```bash
|
||||
cp .claude_hooks/backups/backup_20240115_143022/state/patterns/* .claude_hooks/patterns/
|
||||
```
|
||||
|
||||
2. **Review the session state**:
|
||||
```bash
|
||||
cat .claude_hooks/backups/backup_20240115_143022/state/session.json
|
||||
```
|
||||
|
||||
3. **Check what commands were running**:
|
||||
```bash
|
||||
jq '.commands_executed[-5:]' .claude_hooks/backups/backup_20240115_143022/state/session.json
|
||||
```
|
||||
|
||||
## Emergency Recovery
|
||||
|
||||
If something went very wrong and you need to recover everything:
|
||||
|
||||
1. **Find the most recent emergency backup**:
|
||||
```bash
|
||||
ls -la .claude_hooks/emergency_backup.json
|
||||
```
|
||||
|
||||
2. **Extract the session data**:
|
||||
```bash
|
||||
jq '.session_state.modified_files[]' .claude_hooks/emergency_backup.json
|
||||
```
|
||||
|
||||
3. **Manually locate and recover files** using the file paths from the emergency backup
|
||||
|
||||
## Validate Your Recovery
|
||||
|
||||
After restoring:
|
||||
|
||||
1. **Check that your files are correct**:
|
||||
```bash
|
||||
git status
|
||||
git diff
|
||||
```
|
||||
|
||||
2. **Verify Claude Hooks is working**:
|
||||
```bash
|
||||
claude-hooks status
|
||||
```
|
||||
|
||||
3. **Test a simple command** to ensure hooks are functioning:
|
||||
```bash
|
||||
echo 'print("test")' > test_recovery.py
|
||||
python3 test_recovery.py
|
||||
rm test_recovery.py
|
||||
```
|
||||
|
||||
## Prevention for Next Time
|
||||
|
||||
To make future recovery easier:
|
||||
|
||||
- Enable git backups: Set `"git_enabled": true` in config/settings.json
|
||||
- Lower backup threshold: Set `"backup_threshold": 0.75` to backup more frequently
|
||||
- Create manual backups before risky operations: Run `claude-hooks backup`
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
**No backups found**: Check if hooks were properly installed with `claude-hooks status`
|
||||
|
||||
**Backup files corrupted**: Try the git backup method or emergency recovery
|
||||
|
||||
**Can't find recent work**: Check if files are in a different directory - backups preserve the relative path structure
|
||||
|
||||
**Git backups not working**: Ensure git is initialized in your project: `git init`
|
||||
Loading…
Add table
Add a link
Reference in a new issue