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
mvcommand 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
rmorrm -rfto operate on files tracked by Git. - Mandatory use of
git rm <path>orgit 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:
- Check status: Execute
git ls-files <path>。 - 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。
- If there is output (indicating the file is tracked) → use
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 statusto ensure the working tree is clean.