safe-git-guard

Block destructive Git commands and require backups before history-modifying operations.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/freitasp1/claude-code-skills --skill safe-git-guard-freitasp1
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: safe-git-guard
Source: https://github.com/freitasp1/claude-code-skills/tree/main/skills/safe-git-guard
Command: npx skills add https://github.com/freitasp1/claude-code-skills --skill safe-git-guard-freitasp1

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents accidental data loss and corrupted Git history by intercepting and requiring confirmation for potentially destructive Git commands.

Core Features & Use Cases

  • Prevent Irreversible Deletions: Blocks commands like git reset --hard and git clean -fd.
  • Enforce Backups: Requires creating backups (tags, branches, stashes) before executing commands that modify history like git checkout -- <file>, git reset, or git rebase.
  • Protect Main Branches: Prevents force-pushing to critical branches like main or master.
  • Use Case: Before you can accidentally run git reset --hard and lose uncommitted work, this skill will prompt you to confirm and ensure you have a backup.

Quick Start

Use the safe-git-guard skill to protect your main branch from accidental force pushes.

Frequently Asked Questions about safe-git-guard

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent accidental data loss from git reset --hard?

To prevent accidental data loss from git reset --hard, you can use a safety guard that intercepts the command and requires explicit confirmation before execution. This blocks irreversible actions and protects uncommitted work.

What is the best way to protect main branches from force pushes?

The best way to protect main branches from force pushes is to enforce a policy that blocks git push --force on critical branches like main or master, preventing corrupted history and accidental overwrites of remote code.

How do I enforce backups before running git rebase or git checkout?

To enforce backups before running git rebase or git checkout, you need a mechanism that requires creating backups like tags, branches, or stashes before executing history-modifying commands. This ensures you can recover your data if the operation fails.

Can I block destructive git commands like git clean -fd automatically?

Yes, you can block destructive git commands like git clean -fd automatically by using a safety intercept that prevents irreversible deletions. It stops the command execution entirely without explicit user confirmation.

Does git history modification require a backup strategy for uncommitted work?

Yes, git history modification requires a backup strategy for uncommitted work because commands like git reset alter your commit timeline. Requiring a stash or branch backup ensures your local changes are not permanently lost during these operations.