safe-git-guard

Enforce backups and confirmations before destructive Git operations.

38|5|Updated Dec 18, 2025
One-click install
npx skills add https://github.com/Svenja-dev/claude-code-skills --skill safe-git-guard
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: safe-git-guard
Source: https://github.com/Svenja-dev/claude-code-skills/tree/main/skills/safe-git-guard
Command: npx skills add https://github.com/Svenja-dev/claude-code-skills --skill safe-git-guard

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Prevents destructive Git operations by enforcing backups and explicit confirmations.

Core Features & Use Cases

  • Backup-before-action workflow: requires a backup (stash, tag, or branch) before destructive operations like git reset --hard, git clean -fd, or rebase.
  • Confirmation prompts: prompts users to confirm risky actions and document intent.
  • Scope across main operations: blocks or warns on commands like git push --force on main, git reset --hard, and git clean -fd in any branch.

Quick Start

To enable, copy this skill into your Claude skills directory and run a destructive operation to see the backup-prompt workflow. Create a backup first using:

  • git stash push -m "backup-before-destructive-<date>" Then proceed with the destructive command only after the prompt confirms.

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 losing commits when running git reset --hard or git clean?▼

Prevent destructive git operations by requiring a backup before action. You must create a stash, tag, or branch before running commands like git reset --hard or git clean, ensuring your work is safely recoverable.

What is the best way to block force push to main and master branches?▼

The best way to block git push --force on main or master is to enforce No-Touch Zones. This mechanism blocks or warns on force pushes to critical branches in both local and CI workflows, requiring explicit confirmation.

How do I back up my working directory before a destructive git rebase?▼

Back up your working directory before a destructive git rebase by running git stash push -m "backup-before-destructive-<date>". This creates a recovery point before the destructive operation begins and prompts you to confirm intent.

Can I enforce git safety and confirmation prompts in CI workflows?▼

Yes, you can enforce git safety and confirmation prompts in CI workflows. The backup-before-action workflow and No-Touch Zones apply across both local and CI environments, blocking destructive commands like git clean -fd and requiring explicit confirmation.

When do I need a backup before running destructive git commands?▼

You need a backup before running destructive git commands whenever executing git reset --hard, git push --force on main/master, git clean -fd, or rebase. The backup-before-action workflow requires a stash, tag, or branch to protect critical code from irreversible loss.