# Backup Before Edit Before editing any file, back up the original to a `.backup/` directory in the same parent folder. ## Why Disk space is cheap. Lost work is expensive. AI assistants sometimes make destructive edits — overwriting files, truncating content, or introducing bugs that are hard to reverse. A `.backup/` directory provides instant recovery without relying on git history (which may not exist yet, or may have uncommitted changes). ## How Before modifying `src/config.py`: ```bash mkdir -p src/.backup cp src/config.py src/.backup/config.py ``` For files that get edited multiple times, timestamp the backup: ```bash cp src/config.py src/.backup/config.py.$(date +%Y%m%d-%H%M%S) ``` ## Gitignore Add `.backup/` to your `.gitignore` so backups are never committed: ``` .backup/ ``` ## When to Apply - **Always** before editing existing files, especially configuration or infrastructure files - **Always** when an AI assistant is making changes to files you haven't read yet - **Skip** for files you just created in this session (nothing to back up) - **Skip** for test files during rapid iteration (git handles recovery) ## Where This Rule Lives This belongs in your global `~/.claude/CLAUDE.md` so it applies to every project without per-project configuration. It's the one rule that should be universal and unconditional.