safe-git-guard
Safe Git Guard
Skill to prevent destructive Git operations
Trigger
This skill activates automatically on these commands:
git reset --hardgit checkout -- <file>git clean -fdgit rebase(without explicit confirmation)git push --force
Rules
FORBIDDEN (never execute):
git reset --hard- Deletes uncommitted changes irreversiblygit push --forceon main/master - Can destroy remote historygit clean -fd- Deletes untracked files irreversibly
WARNING + BACKUP required:
-
git checkout -- <file>- Overwrites local changes- BEFORE execution: Create backup
git stash push -m "backup-before-checkout-$(date +%s)"
-
git reset HEAD~n- Resets commits- BEFORE execution: Create tag
git tag backup-before-reset-$(date +%s)
-
git rebase- Modifies history- BEFORE execution: Create backup branch
git branch backup-before-rebase-$(date +%s)
Workflow for Destructive Operations
1. STOP - Don't execute immediately
2. BACKUP - Save current state (tag/branch/stash)
3. ASK - "Are you sure? What will be lost?"
4. CONFIRM - Explicit "Yes, I understand the risk"
5. EXECUTE - Only then run the command
Example Dialog
User: "Undo the last 3 commits"
Claude (with this skill):
WARNING: DESTRUCTIVE OPERATION DETECTED
You want to run `git reset HEAD~3`. This would:
- Remove 3 commits from history
- Changes become "unstaged" (--soft) or deleted (--hard)
Creating backup:
> git tag backup-YYYYMMDD-pre-reset
Should I proceed? (Answer with "Yes, proceed with reset")
Protected Branches
Configure in your project's CLAUDE.md:
protected_branches:
- main # Production branch, never force-push
- master # Legacy production branch
- develop # Development branch, PR only
- release/* # Release branches, approval only
Integration with No-Touch Zones
This skill respects No-Touch Zones defined in CLAUDE.md. When changes affect protected files: Additional warning + Impact Analysis.
Configuration
Add to your CLAUDE.md:
### Git Safety Rules
Protected Branches:
- main, develop, release/*
No-Touch Zones (require explicit approval):
- src/auth/**
- src/core/**
- config/production.*
Origin
Originally developed for fabrikIQ - AI-powered manufacturing data analysis.
License
MIT - Free to use and modify
More from svenja-dev/claude-code-skills
social-media-content
Erstellt plattformoptimierte Social Media Inhalte für LinkedIn, X/Twitter, Discord, Reddit. B2B/MES-Industrie fokussiert.
179reddit-research
Reddit-Recherche und Engagement für B2B/Manufacturing. Scannt Subreddits, formuliert Antworten vor, extrahiert Insights.
85tdd-strict
Erzwingt striktes Test-Driven Development mit Red-Green-Refactor Zyklus. Blockiert Code-Generierung ohne vorherige Tests. Dokumentiert 13 ungueltige Rationalisierungen. Aktivieren bei neuen Features, Bug Fixes, Refactoring.
57linkedin-engagement
LinkedIn Content-Erstellung, Engagement und Monitoring für B2B/Manufacturing. Regionale Anpassung (US/EU/Asien), Artikel mit Teasern, Bildgenerierung via Gemini, Kommentar-Monitoring.
45prompt-architect
|
21strict-typescript-mode
Enforces TypeScript best practices when writing code. Automatically enables strict typing for TypeScript projects, prevents `any` usage, and recommends generic constraints. Activate on TS/TSX files, new features, code reviews.
20