Agent skill
git-safety
Git 操作安全与规范。强制要求使用 git 原生命令处理受控文件,防止丢失索引或产生冗余变更。当 Agent 尝试移动、重命名或删除文件时触发。
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/git-safety
SKILL.md
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 准备操作文件时,应遵循以下逻辑:
- 检查状态:执行
git ls-files <path>。 - 判断:
- 如果有输出(说明文件受控)→ 使用
git mv/git rm。 - 如果无输出(说明是未跟踪文件)→ 使用普通
mv/rm。
- 如果有输出(说明文件受控)→ 使用
适用场景
- 重构代码导致的文件目录结构调整。
- 删除过时的文档或代码文件。
- 项目清理。
约束
- 严禁在未确认文件状态的情况下盲目使用普通文件管理命令。
- 在执行大规模移动操作前,建议先执行
git status确保工作区是干净的。
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?