Agent skill
gitrules-skill
Git safety protocol that prevents destructive operations and accidental data loss during version control workflows.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/gitrules-skill
SKILL.md
Git Safety Protocol
Critical rules to prevent accidental data loss from destructive git operations.
Never use git checkout to revert changes
MANDATORY 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 checkoutdestroys 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.
Destructive commands requiring explicit approval
NEVER run these commands without explicit user approval:
| Command | Effect |
|---|---|
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 |
git push --force |
Overwrites remote history (dangerous for shared branches) |
Before any git operation
- Run
git statusfirst to check for uncommitted changes - If there are uncommitted changes, STOP and ASK the user before proceeding
- Suggest
git stashto preserve changes if needed
Handling revert requests
If user asks to "revert" something:
- First clarify: revert committed changes or uncommitted changes?
- Show what will be affected before doing anything
- Get explicit confirmation for destructive operations
If user says "undo my changes":
- Read the current file
- Identify which specific sections are problematic
- Manually edit to fix those sections
- Preserve everything else
Quick checklist
Before git operations:
- Have I run
git statusfirst? - Are there uncommitted changes I might destroy?
- Have I used
git diffto see what will be affected? - Do I have explicit user approval for any destructive command?
- Am I preserving valuable work?
When asked to revert:
- Did I clarify what specifically should be reverted?
- Am I manually editing instead of using checkout?
- Am I preserving work not mentioned in the revert request?
Why these rules exist
These rules exist because careless git operations can destroy days of work. A single git checkout -- . can eliminate sophisticated implementations, complex logic, and carefully crafted code that took significant time to develop.
When in doubt, ask first.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?