git-safety

Enforce git mv and git rm for tracked file operations.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Git operations can easily corrupt history or leave dangling changes when moving, renaming, or deleting tracked files. This skill enforces safe practices to preserve history and stability.

Core Features & Use Cases

  • Enforces use of git mv and git rm for file moves and deletions to preserve history.
  • Pre-operation checks verify the repository state before performing file operations.
  • Use Case: When reorganizing a project, ensure all file renames and removals are tracked correctly without introducing spurious delete/add commits.

Quick Start

Instruct the agent to migrate a file from src/old.go to src/new.go using git mv.

Frequently Asked Questions about git-safety

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

FAQPage Schema
How do I preserve git history when renaming or moving tracked files?

To preserve git history when renaming tracked files, you must use the git mv command instead of plain mv. This ensures the operation is recorded as a rename, maintaining file traceability and preventing spurious delete/add commits in your repository.

Why does using standard rm or mv commands break my version control history?

Using standard rm or mv on tracked files breaks version control history because Git registers the original file as deleted and the new location as untracked. This creates dangling changes and spurious delete/add commits, permanently obscuring the file's historical traceability.

What is the safest way to delete tracked files in a git repository?

The safest way to delete tracked files in a git repository is using the git rm command. This performs a pre-operation check with git ls-files to verify the repository state, ensuring accidental deletions are prevented and changes are properly tracked.

Can I automate safe git operations for project reorganization?

Yes, you can automate safe git operations during project reorganization by enforcing git mv and git rm for file moves and deletions. This workflow performs pre-operation checks to ensure all renames and removals are tracked correctly without manual oversight.

Does git ls-files need to run before moving or deleting tracked files?

Yes, running git ls-files serves as a pre-operation check to verify the repository state before moving or deleting tracked files. It confirms which files are currently tracked, preventing accidental loss of history and ensuring safe operations.