Git Safety Rules

VerifiedSafe

Critical Git safety rules to prevent destructive operations. Use whenever performing git operations to avoid accidental loss of work.

Sby Skills Guide Bot
DevelopmentBeginner
7/22/2026
Claude CodeCursorWindsurfCopilotCodex
#git#safety#version-control#revert#workflow

Recommended for

Automated summary

This skill enforces a Git safety protocol that blocks destructive operations like git checkout, git reset --hard or git clean until the user explicitly confirms them.

Strengths

  • Explicitly forbids unconfirmed destructive commands (git checkout --, reset --hard, clean -fd, stash drop)
  • Requires checking state first with git status and reviewing impact with git diff
  • Offers a non-destructive fallback: reverting changes through targeted manual edits
  • Prompts the agent to clarify whether the user means committed or uncommitted changes

Limitations

  • Very directive in tone, written almost entirely in capitals and imperatives
  • Does not address merge conflicts, rebase, or recovery via reflog
  • May slow down legitimate workflows where a reset is genuinely intended
When to use it

Enable it whenever an agent might run Git commands, especially when undoing or cleaning up changes.

When not to use it

Unnecessary outside a Git repository or for purely documentary tasks with no version-control interaction.

Security analysis

Safe
Quality score82/100

This skill only adds guardrails around git usage: it forbids destructive commands (git checkout --, reset --hard, clean -fd, stash drop) without explicit approval and requires inspecting git status/diff first. There is no code execution, no network access, no secret handling, and no obfuscation. The only mild caveat is the blanket ban on `git checkout` for reverts, which pushes the agent toward manual file edits, but that is a workflow preference rather than a security risk.

No concerns found

How this analysis is made

Examples

Undo recent edits
Revert the changes I just made to src/auth.js, they broke the login flow.
Clean working directory
My working tree is messy, just wipe all uncommitted changes so I can start fresh.
Before committing
Check if I have uncommitted changes and commit everything with the message 'wip'.

name: gitrules description: Critical Git safety rules to prevent destructive operations. Use whenever performing git operations, reverting changes, or managing commits. Prevents accidental loss of work.

Critical Git Safety Protocol

NEVER USE git checkout TO REVERT CHANGES.

MANDATORY GIT SAFETY RULES:

  • NEVER run git checkout -- <file> without first examining what you're about to destroy
  • ALWAYS use git diff <file> to see exactly what changes will be lost
  • MANUALLY undo changes by editing files to revert specific problematic sections
  • Preserve valuable work: if user says changes are bad, ask which specific parts to revert
  • git checkout destroys ALL changes: this can eliminate hours of valuable progress
  • When user asks to "undo" changes: Read the current file, identify problematic sections, and manually edit to fix them

Why this matters: Using git checkout blindly can destroy sophisticated implementations, complex prompts, provider-specific logic, and other valuable work that took significant time to develop.

Git Safety Rules

NEVER run these commands without explicit user approval:

  • git reset --hard: Destroys uncommitted changes permanently
  • git checkout -- .: Discards all working directory changes
  • git clean -fd: Deletes untracked files permanently
  • git stash drop: Deletes stashed changes

ALWAYS before any git operation:

  1. Run git status first to check for uncommitted changes
  2. If there are uncommitted changes, STOP and ASK the user before proceeding
  3. Suggest git stash to preserve changes if needed
  4. Never create a commit unless the user explicitly asked for one

If user asks to "revert" something:

  1. First clarify: revert committed changes or uncommitted changes?
  2. Show what will be affected before doing anything
  3. Get explicit confirmation for destructive operations

This rule exists because careless git operations destroyed 2 days of work.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/git-safety-rules-mrwakd7t/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/git-safety-rules-mrwakd7t' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/git-safety-rules-mrwakd7t/download' --output '.skill-downloads/git-safety-rules-mrwakd7t/SKILL.md.part' && mv '.skill-downloads/git-safety-rules-mrwakd7t/SKILL.md.part' '.skill-downloads/git-safety-rules-mrwakd7t/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/git-safety-rules-mrwakd7t/SKILL.md' && test -s '.skill-downloads/git-safety-rules-mrwakd7t/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/gitrules' && cp -R '.skill-downloads/git-safety-rules-mrwakd7t' '.claude/skills/gitrules'

Cursor
test -f '.skill-downloads/git-safety-rules-mrwakd7t/SKILL.md' && test -s '.skill-downloads/git-safety-rules-mrwakd7t/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/gitrules' && cp -R '.skill-downloads/git-safety-rules-mrwakd7t' '.cursor/skills/gitrules'

Codex
test -f '.skill-downloads/git-safety-rules-mrwakd7t/SKILL.md' && test -s '.skill-downloads/git-safety-rules-mrwakd7t/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/gitrules' && cp -R '.skill-downloads/git-safety-rules-mrwakd7t' '.agents/skills/gitrules'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/git-safety-rules-mrwakd7t'

openskills read 'git-safety-rules-mrwakd7t'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/git-safety-rules-mrwakd7t/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills