SuperAPI AI Directory

git-safety

Coding & development

View repository

Updated 10-15 08:13

About this skill

Git Safety & Standards

This Skill is designed to ensure safety and historical integrity when performing file operations in a Git repository.

Core Principles

1. Move & Rename

  • Prohibitedto directly use the mv command to operate on files tracked by Git.
  • Mandatory use of git mv <old_path> <new_path>。
  • Reason: Ensures Git automatically tracks file refactoring, preserves the file's Git History, and avoids it being identified as a "deletion + addition".

2. Delete

  • Prohibitedto directly use rm or rm -rf to operate on files tracked by Git.
  • Mandatory use of git rm <path> or git rm -r <path>。
  • Reason: Removes synchronously from the working tree and index directly, avoiding residual untracked deletion changes.

3. Pre-operation Self-check Process

When an Agent is about to operate on files, it should follow this logic:

  1. Check status: Execute git ls-files <path>。
  2. Determine:
    • If there is output (indicating the file is tracked) → use git mv / git rm。
    • If there is no output (indicating it is an untracked file) → use regular mv / rm。

Applicable Scenarios

  • File directory structure adjustments caused by refactoring code.
  • Deleting outdated documents or code files.
  • Project cleanup.

Constraints

  • It is strictly prohibited to blindly use regular file management commands without confirming the file status.
  • Before performing large-scale move operations, it is recommended to first execute git status to ensure the working tree is clean.