git-file-deletion-guard

Blocks accidental whole-file deletions during git commits and pushes.

Updated Mar 22, 2026
One-click install
npx skills add https://github.com/diazMelgarejo/orama-system --skill git-file-deletion-guard-diazmelgarejo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-file-deletion-guard
Source: https://github.com/diazMelgarejo/orama-system/tree/main/bin/orama-system/skills/git-file-deletion-guard
Command: npx skills add https://github.com/diazMelgarejo/orama-system --skill git-file-deletion-guard-diazmelgarejo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? Accidental deletion of tracked files can slip into commits and pushes unnoticed, causing data loss and broken repositories. This Skill intercepts staged deletions and mass file removals before they reach the remote, forcing an explicit justification for any intentional deletion. ## Core Features & Use Cases - Staged Deletion Detection: Runs check_file_deletion_guard.sh --staged to block any Git D-status paths before commit time. - Pre-Push Range Audit: Audits a commit range (e.g., origin/main..HEAD) for file deletions before pushing to a remote. - Controlled Override Policy: Deliberate deletions require GIT_ALLOW_FILE_DELETIONS=1 plus a recorded justification preserved in the commit or PR, instead of bypassing hooks with --no-verify. - Use Case: A developer runs git add -u after refactoring and unknowingly stages the deletion of a fixture file; the guard halts the commit and reports GIT_SCOPE_E_FILE_DELETION until the deletion is justified or reverted. ## Quick Start Ask the agent to run the file deletion guard on your staged changes before committing to confirm no tracked files are being accidentally deleted.

Frequently Asked Questions about git-file-deletion-guard

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

FAQPage Schema
How do I prevent accidental file deletion in git commits?

Run the deletion guard script with the --staged flag before committing to block any Git D-status paths. Local hooks execute both staged and range checks automatically, while normal line removals and modifications remain allowed.

How do I check a commit range for deleted files before pushing?

Run check_file_deletion_guard.sh with --range origin/main..HEAD to audit all commits about to be pushed. The pre-push hook performs this deletion audit automatically and blocks the push if unintended deletions are found.

How do I intentionally delete a file when the guard blocks it?

Set GIT_ALLOW_FILE_DELETIONS=1 together with GIT_FILE_DELETION_JUSTIFICATION describing the reason, then commit normally. Do not bypass with --no-verify; the justification is preserved in the commit or PR for auditability.

Does the deletion guard block normal line removals in files?

No, the guard only blocks Git D-status paths, meaning whole-file deletions. Editing lines within a file or modifying content passes the checks without triggering the guard.

What does the GIT_SCOPE_E_FILE_DELETION error mean?

It indicates the guard detected one or more tracked files staged for deletion without an approved justification. Either restore the files, unstage the deletion, or re-run with the justification environment variables set.