Skip to content
Back to skills

Git Safety

BSecurity

Git 操作安全与规范。强制要求使用 git 原生命令处理受控文件,防止丢失索引或产生冗余变更。当 Agent 尝试移动、重命名或删除文件时触发。

  • 755 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added February 8, 2026
toolsgit

Security analysis

B85/100
  • highPerforms destructive filesystem operations

Pro shows the line behind each finding and how to fix it

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill git-safety --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Git Safety?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Git Safety
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-git-safety/badge)](https://www.skillsdirectory.com/skills/majiayu000-git-safety)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: git-safety
description: Git 操作安全与规范。强制要求使用 git 原生命令处理受控文件,防止丢失索引或产生冗余变更。当 Agent 尝试移动、重命名或删除文件时触发。
---

# Git Safety & Standards

该 Skill 旨在确保在 Git 仓库中进行文件操作时的安全性和历史完整性。

## 核心准则

### 1. 移动与重命名 (Move & Rename)
- **禁止**直接使用 `mv` 命令操作受 Git 跟踪的文件。
- **强制使用** `git mv <old_path> <new_path>`。
- **理由**:确保 Git 自动跟踪文件重构,保留文件的 Git History,避免识别为“删除 + 新增”。

### 2. 删除 (Delete)
- **禁止**直接使用 `rm` 或 `rm -rf` 操作受 Git 跟踪的文件。
- **强制使用** `git rm <path>` 或 `git rm -r <path>`。
- **理由**:直接从工作区和索引中同步移除,避免残留未跟踪的删除变更。

### 3. 操作前自检流程
当 Agent 准备操作文件时,应遵循以下逻辑:
1. **检查状态**:执行 `git ls-files <path>`。
2. **判断**:
   - 如果有输出(说明文件受控)→ 使用 `git mv` / `git rm`。
   - 如果无输出(说明是未跟踪文件)→ 使用普通 `mv` / `rm`。

## 适用场景
- 重构代码导致的文件目录结构调整。
- 删除过时的文档或代码文件。
- 项目清理。

## 约束
- 严禁在未确认文件状态的情况下盲目使用普通文件管理命令。
- 在执行大规模移动操作前,建议先执行 `git status` 确保工作区是干净的。

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in tools →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.