git-safety
CRITICAL SAFETY SKILL - Use this skill before any Git operation that could lose commits, rewrite history, or affect shared branches. Activate when the user wants to force push, reset hard, rebase, clean, or perform any destructive Git operation. This skill prevents loss of work through verification and confirmation.
What this skill does
# Git Safety **CRITICAL: Some Git operations can permanently lose work. This skill prevents commit loss.** ## Danger Levels | Level | Operations | Requires | |-------|------------|----------| | โ CRITICAL | `push --force` to shared branch, `reset --hard` with unpushed work | Full verification + explicit confirmation | | ๐ด HIGH | `rebase` on shared branches, `clean -fd`, `checkout .` | Stash check + confirmation | | ๐ MEDIUM | `reset --soft/mixed`, `stash drop`, `branch -D` | Verify branch state + confirm | | ๐ข LOW | `commit`, `push`, `pull`, `fetch`, `branch` | Standard execution | ## Pre-Operation Protocol ### Before Force Push ```markdown โ **CRITICAL: FORCE PUSH REQUESTED** **Command:** git push --force origin main **โ ๏ธ THIS REWRITES SHARED HISTORY** **Current state:** - Local branch: main - Local HEAD: abc1234 "Add new feature" - Remote HEAD: def5678 "Fix bug in login" **Commits that will be OVERWRITTEN on remote:** 1. def5678 - "Fix bug in login" (by [email protected], 2 hours ago) 2. ghi9012 - "Update documentation" (by [email protected], 3 hours ago) **These commits will be LOST if not saved elsewhere:** - 2 commits by other team members - Anyone who pulled these will have conflicts **Safety checks:** - [ ] Is this your personal branch? NO - this is main โ ๏ธ - [ ] Have you notified the team? Unknown - [ ] Are the overwritten commits backed up? Unknown **Safer alternatives:** 1. `git push --force-with-lease` (fails if remote changed) 2. Create a new branch for your changes 3. Merge instead of rebase 4. Coordinate with team first **I strongly recommend against force pushing to main.** If you must proceed, type: "yes, force push to main and overwrite 2 commits" ``` ### Before Reset --hard ```markdown โ **CRITICAL: HARD RESET REQUESTED** **Command:** git reset --hard HEAD~3 **โ ๏ธ THIS DISCARDS CHANGES PERMANENTLY** **What will be LOST:** **Commits to be removed (3):** 1. abc1234 - "Work in progress on feature X" 2. def5678 - "Add unit tests" 3. ghi9012 - "Fix styling issues" **Uncommitted changes that will be LOST:** - Modified: src/App.tsx (45 lines changed) - Modified: src/utils/helper.ts (12 lines changed) - Untracked: src/components/NewFeature.tsx (new file, 156 lines) **Recovery options after reset:** - Commits: Can recover via `git reflog` (within 90 days) - Staged changes: Can recover via `git fsck --lost-found` - Untracked files: PERMANENTLY LOST โ ๏ธ **Before reset, I will:** 1. Stash uncommitted changes: `git stash push -m "backup before reset"` 2. Create backup branch: `git branch backup-before-reset` 3. Note reflog position: HEAD is currently at abc1234 Proceed with backup and reset? Type "yes, reset after backup" to confirm. ``` ### Before Clean ```markdown ๐ด **DANGEROUS: GIT CLEAN REQUESTED** **Command:** git clean -fd **This will DELETE untracked files and directories:** | Type | Path | Size | |------|------|------| | File | .env.local | 1.2 KB โ ๏ธ (may contain secrets) | | File | config.local.json | 0.5 KB | | Dir | node_modules/ | 234 MB (can be recreated) | | Dir | uploads/ | 45 MB โ ๏ธ (user uploaded files) | | File | notes.txt | 2 KB (your notes) | **Files that will be PRESERVED (tracked):** - All committed files - All files in .gitignore that are tracked **โ ๏ธ WARNING: These untracked files cannot be recovered after deletion:** - .env.local (may contain API keys!) - uploads/ (user data!) - notes.txt (your work!) **Safer alternatives:** ```bash # See what would be deleted (dry run) git clean -fdn # Interactive mode (choose what to delete) git clean -fdi # Exclude certain patterns git clean -fd -e "*.local" -e "uploads/" ``` Type "yes, delete untracked files" to proceed, or use a safer alternative above. ``` ### Before Rebase on Shared Branch ```markdown ๐ด **DANGEROUS: REBASE ON SHARED BRANCH** **Command:** git rebase main feature-branch **โ ๏ธ REBASE REWRITES HISTORY** **Branch state:** - feature-branch has been pushed: Yes - feature-branch has other contributors: Checking... - You: 5 commits - [email protected]: 2 commits โ ๏ธ **If you rebase this branch:** - All 7 commits will get new SHA hashes - Your teammate will have to force-reset their local branch - Any PRs referencing old commits will break - CI/CD caches may be invalidated **Safer alternatives:** 1. **Merge instead:** `git merge main` (preserves history) 2. **Rebase only your commits:** ```bash git rebase --onto main HEAD~5 # Only your 5 commits ``` 3. **Create new branch:** ```bash git checkout -b feature-branch-v2 git rebase main ``` If you must rebase, notify teammates first and type: "yes, rebase shared branch" ``` ### Before Checkout . (Discard All Changes) ```markdown ๐ด **DANGEROUS: DISCARD ALL CHANGES** **Command:** git checkout . (or git restore .) **This will DISCARD all uncommitted changes:** **Modified files (15):** | File | Lines Changed | |------|---------------| | src/App.tsx | +45, -12 | | src/components/Header.tsx | +23, -5 | | src/utils/api.ts | +67, -34 | | ... and 12 more files | **Total changes to be discarded:** - 234 lines added - 89 lines removed - 15 files modified **These changes are NOT committed and will be PERMANENTLY LOST.** **Safer alternatives:** ```bash # Stash changes (can be recovered later) git stash push -m "work in progress" # Discard specific file only git checkout -- src/App.tsx # See changes first git diff ``` Type "yes, discard all uncommitted changes" to proceed. ``` ### Before Branch -D (Force Delete) ```markdown ๐ **WARNING: FORCE DELETE BRANCH** **Command:** git branch -D feature/experimental **Branch state:** - Local branch: feature/experimental - Commits ahead of main: 8 - Merged to main: No โ ๏ธ - Has remote tracking: No - Last commit: 2 days ago **Commits that may be LOST (not on any other branch):** 1. abc1234 - "Experimental feature WIP" 2. def5678 - "Add database schema" 3. ... and 6 more commits **Recovery:** - Can recover via `git reflog` within 90 days - Cannot recover if git gc runs **Safer alternatives:** ```bash # Merge first, then delete git checkout main git merge feature/experimental git branch -d feature/experimental # -d fails if not merged # Archive the branch instead git tag archive/feature-experimental feature/experimental git branch -D feature/experimental ``` Type "yes, delete unmerged branch" to proceed. ``` ### Before Stash Drop ```markdown ๐ **WARNING: DROP STASH** **Command:** git stash drop stash@{0} **Stash contents:** - Created: 2024-01-15 14:30:00 (3 days ago) - Message: "WIP: payment integration" - Branch: feature/payments - Files: - src/services/payment.ts (modified) - src/types/payment.ts (new file) - tests/payment.test.ts (modified) **Changes in this stash:** - 156 lines added - 23 lines removed **Recovery after drop:** - Very difficult (requires git fsck --lost-found) - May not be recoverable after git gc **Safer alternatives:** ```bash # Apply stash first, then drop git stash apply stash@{0} # ... verify changes look good ... git stash drop stash@{0} # List all stashes to make sure dropping the right one git stash list ``` Type "yes, drop stash" to proceed. ``` ## Safe Git Workflow ### Before Any Destructive Operation ```bash # 1. Check current state git status git log --oneline -5 git stash list # 2. Create safety backup git stash push -m "safety backup $(date +%Y%m%d_%H%M%S)" git branch backup-$(date +%Y%m%d_%H%M%S) # 3. Note reflog position git reflog -1 # Remember this hash! ``` ### Recovery Commands ```bash # Recover from reset --hard git reflog # Find the commit before reset git reset --hard HEAD@{1} # Go back to that commit # Recover deleted branch git reflog # Find the branch's last commit git checkout -b recovered-branch abc1234 # Recover dropped stash git fsck --lost-found # Find dangling commits git show abc1234 # Check if it's your stash git stash apply abc1234 # Recover from clean
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.