# π‘οΈ Repository Protection Documentation
**Complete guide to keeping your notepadpp-mcp repository safe**
---
## π **Documentation Index**
### **Quick Start**
1. [Branch Protection Settings](BRANCH_PROTECTION_SETTINGS.md) - **START HERE** (5 minutes setup)
2. [Branch Strategy & AI Workflow](BRANCH_STRATEGY_AND_AI_WORKFLOW.md) - How to collaborate with AI safely
3. [Backup & Recovery Guide](BACKUP_AND_RECOVERY_GUIDE.md) - Multiple layers of protection
---
## π― **What's In This Directory**
### **1. Branch Protection Settings**
π `BRANCH_PROTECTION_SETTINGS.md`
**Quick reference for setting up GitHub branch protection**
**What it covers**:
- β
Step-by-step GitHub settings
- β
Exact checkboxes to enable
- β
Visual setup checklist
- β
Verification tests
**Time to complete**: 5 minutes
**Difficulty**: Easy
**Priority**: **HIGH** - Do this first!
---
### **2. Branch Strategy & AI Workflow**
π `BRANCH_STRATEGY_AND_AI_WORKFLOW.md`
**Complete guide to safe AI collaboration**
**What it covers**:
- β
Three-branch strategy (main/develop/experimental)
- β
AI playground on feature/experimental
- β
PR workflow for production
- β
Examples of AI prompts for each branch
- β
Cherry-picking experimental features
- β
Keeping branches synchronized
**Key benefit**: AI can experiment wildly without risking production code!
---
### **3. Backup & Recovery Guide**
π `BACKUP_AND_RECOVERY_GUIDE.md`
**Multi-layer protection strategy**
**What it covers**:
- β
5 layers of protection
- β
Automated backup script
- β
Git reflog (90-day time machine)
- β
Recovery scenarios
- β
Emergency procedures
- β
Windows Task Scheduler setup
**Key benefit**: Almost impossible to permanently lose code!
---
## π **Quick Setup (15 Minutes)**
### **Step 1: Enable Branch Protection (5 min)**
Follow: [BRANCH_PROTECTION_SETTINGS.md](BRANCH_PROTECTION_SETTINGS.md)
1. Go to GitHub repository settings
2. Add protection rule for `main` branch
3. Enable required PR reviews
4. Disable force pushes and deletions
**Result**: Main branch is bulletproof! β
---
### **Step 2: Understand Branch Strategy (5 min)**
Read: [BRANCH_STRATEGY_AND_AI_WORKFLOW.md](BRANCH_STRATEGY_AND_AI_WORKFLOW.md)
**Learn**:
- When to use `main` (production)
- When to use `develop` (testing)
- When to use `feature/experimental` (AI playground)
**Result**: Clear workflow for AI collaboration! β
---
### **Step 3: Set Up Automated Backups (5 min)**
Follow: [BACKUP_AND_RECOVERY_GUIDE.md](BACKUP_AND_RECOVERY_GUIDE.md)
1. Run backup script: `..\..\scripts\backup-repo.ps1`
2. Optionally: Set up Windows Task Scheduler
3. Verify backups are created
**Result**: Automated daily backups! β
---
## π¨ **Usage Scenarios**
### **Scenario 1: Normal Development**
```powershell
# Work on develop branch
git checkout develop
# Make changes, test
git commit -am "Add feature"
git push origin develop
# When ready, create PR to main
# Review and merge on GitHub
```
---
### **Scenario 2: AI Experimentation**
**You say to AI**:
> "Switch to feature/experimental and add 5 crazy experimental features!"
**AI workflow**:
```powershell
git checkout feature/experimental
# AI experiments freely
git commit -am "Added experimental features"
git push origin feature/experimental --force # Can do this!
```
**Your protection**: Main and develop are safe! β
---
### **Scenario 3: Emergency Recovery**
**If something breaks**:
```powershell
# Option 1: Use reflog (undo last operations)
git reflog
git reset --hard HEAD@{5}
# Option 2: Use backup branch
git reset --hard backup-safe-2025-10-08
# Option 3: Restore from bundle
git clone D:\Backups\notepadpp-mcp\[latest-bundle].bundle restored
# Option 4: Re-clone from GitHub (nuclear option)
git clone https://github.com/sandraschi/notepadpp-mcp.git
```
---
## π **Protection Layers**
Your repository is protected by **5 independent layers**:
| Layer | What | Recovery Time | Auto |
|-------|------|---------------|------|
| **GitHub Remote** | All commits & history | Instant | β
|
| **Git Reflog** | 90-day operation log | Instant | β
|
| **Backup Branches** | Known-good states | Instant | Manual |
| **Local Bundles** | Complete repo files | 5 minutes | Setup |
| **Branch Protection** | PR-only workflow | N/A | Setup |
**Combined**: Almost impossible to permanently lose code! π‘οΈ
---
## π― **Best Practices**
### **Before AI Does Anything Risky**
```powershell
# Create safety snapshot
git branch backup-before-ai
git push origin backup-before-ai
```
### **Daily Routine**
```powershell
# Run backup
..\..\scripts\backup-repo.ps1
# Check status
git status
git log --oneline -5
```
### **Weekly Maintenance**
```powershell
# Verify backups exist
Get-ChildItem D:\Backups\notepadpp-mcp\
# Sync branches
git checkout develop
git merge main
git push origin develop
```
---
## π¨ **Emergency Contacts**
### **If Something Goes Wrong**
1. **Don't Panic** - Your code is safe on GitHub
2. **Check Reflog** - `git reflog` shows everything
3. **Check Backups** - Look in `D:\Backups\notepadpp-mcp\`
4. **Re-clone if Needed** - GitHub has everything
### **Common Issues**
**"I can't push to main!"**
- β
This is correct! Use PR workflow
- Create branch β Push β Create PR β Merge
**"AI broke something on experimental!"**
- β
That's fine! Experimental is expendable
- Reset: `git reset --hard origin/develop`
**"I lost uncommitted work!"**
- Check: `git stash list`
- Restore: `git stash pop`
---
## π **Checklist**
### **Protection Setup**
- [ ] Branch protection enabled on `main`
- [ ] Backup script tested (`scripts\backup-repo.ps1`)
- [ ] Backup branches created
- [ ] Windows Task Scheduler configured (optional)
- [ ] Recovery procedure tested
### **Workflow Understanding**
- [ ] Know when to use `main` (production)
- [ ] Know when to use `develop` (testing)
- [ ] Know when to use `feature/experimental` (AI playground)
- [ ] Understand PR workflow
- [ ] Can create backup branches
### **Emergency Preparedness**
- [ ] Know how to use `git reflog`
- [ ] Know where backups are stored
- [ ] Tested bundle restore
- [ ] Can re-clone from GitHub
- [ ] Have backup of backup branches
---
## π **Learning Resources**
### **Git Basics**
- [Git Reflog Explained](https://git-scm.com/docs/git-reflog)
- [Branch Protection](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches)
- [Pull Request Workflow](https://docs.github.com/en/pull-requests)
### **Advanced Topics**
- [Git Bundles](https://git-scm.com/docs/git-bundle)
- [Cherry-picking Commits](https://git-scm.com/docs/git-cherry-pick)
- [Interactive Rebase](https://git-scm.com/docs/git-rebase)
---
## π **You're Protected!**
With these three documents and tools, you have:
β
**Branch protection** preventing accidents
β
**Clear workflow** for AI collaboration
β
**Multiple backups** for recovery
β
**Safe playground** for experimentation
β
**Emergency procedures** for any scenario
**You can now safely say to AI**:
> *"Let's experiment on feature/experimental and try some wild ideas!"*
**And your production code stays 100% safe!** π‘οΈ
---
## π **Quick Reference**
| Need | Document | Section |
|------|----------|---------|
| Setup protection | [BRANCH_PROTECTION_SETTINGS.md](BRANCH_PROTECTION_SETTINGS.md) | Quick Setup |
| AI workflow | [BRANCH_STRATEGY_AND_AI_WORKFLOW.md](BRANCH_STRATEGY_AND_AI_WORKFLOW.md) | AI Prompts |
| Create backup | [BACKUP_AND_RECOVERY_GUIDE.md](BACKUP_AND_RECOVERY_GUIDE.md) | Layer 4 |
| Undo changes | [BACKUP_AND_RECOVERY_GUIDE.md](BACKUP_AND_RECOVERY_GUIDE.md) | Git Reflog |
| Recover lost work | [BACKUP_AND_RECOVERY_GUIDE.md](BACKUP_AND_RECOVERY_GUIDE.md) | Emergency Recovery |
---
## π **Related Documentation**
### **In This Repository**
- [Main README](../../README.md) - Project overview
- [CONTRIBUTING.md](../../CONTRIBUTING.md) - Contribution guidelines
- [Build Scripts](../../scripts/) - Automation scripts
### **External Resources**
- [GitHub Repository](https://github.com/sandraschi/notepadpp-mcp)
- [Issue Tracker](https://github.com/sandraschi/notepadpp-mcp/issues)
- [Pull Requests](https://github.com/sandraschi/notepadpp-mcp/pulls)
---
*Repository Protection Documentation*
*Created: October 8, 2025*
*Location: `docs/repository-protection/`*
*Status: Complete and Ready to Use*
**Your repository is safer than Fort Knox!** π°π‘οΈ