git-safety

Warn before destructive Git operations and suggest safer alternatives.

5|1|Updated Feb 4, 2026
One-click install
npx skills add https://github.com/latestaiagents/agent-skills --skill git-safety-latestaiagents
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-safety
Source: https://github.com/latestaiagents/agent-skills/tree/main/skills/safety/ai-safety-guardrails/git-safety
Command: npx skills add https://github.com/latestaiagents/agent-skills --skill git-safety-latestaiagents

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill prevents accidental data loss and irreversible mistakes when performing potentially destructive Git operations like force pushing, hard resets, or rebasing shared branches.

Core Features & Use Cases

  • Destructive Operation Warnings: Identifies and warns about operations that can lose commits or uncommitted changes.
  • Safety Protocols: Guides users through pre-operation checks, backup procedures, and safer alternative commands.
  • Use Case: Before running git reset --hard HEAD~5, the skill will show you exactly which commits and uncommitted changes will be lost, offer to stash your work, and create a backup branch.

Quick Start

Use the git-safety skill before performing a force push to a shared branch.

Frequently Asked Questions about git-safety

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

FAQPage Schema
How do I prevent data loss when running destructive git operations?

Preventing data loss during destructive git operations requires enforcing pre-operation protocols, suggesting safer alternatives, and confirming user intent before executing commands like force push or reset hard. This skill provides critical safety checks and recovery commands to protect your work.

What happens if I force push to a shared git branch?

Force pushing to a shared git branch can overwrite remote commits and cause irreversible data loss for collaborators. This skill identifies such destructive operations, warns you of the specific risks, and guides you through safer alternative commands to preserve team history.

How do I safely perform a git reset hard without losing uncommitted changes?

To safely perform a git reset hard without losing uncommitted changes, this skill shows exactly which commits and local modifications will be lost, offers to stash your work, and creates a backup branch before executing the destructive command.

Can I recover deleted commits after a git branch -D command?

Recovering deleted commits after a git branch -D command is possible using included recovery commands and best practices. This skill enforces pre-operation checks and confirms your intent before execution, ensuring you have backup procedures in place to retrieve lost work.

What is the best way to manage git safety during rebasing on shared branches?

Managing git safety during rebasing on shared branches involves enforcing pre-operation protocols and suggesting safer alternatives to prevent data loss. This skill confirms user intent and provides critical safety checks before executing potentially destructive rebase commands.

Does git clean require safety checks to prevent losing untracked files?

Git clean requires safety checks to prevent losing untracked files because it is a destructive operation that permanently deletes data. This skill warns about the operation, confirms your intent, and guides you through pre-operation backup procedures to avoid data loss.