AgentSkillsCN

refactoring-safe

在执行移动与重命名操作前,先追溯依赖关系,从而确保操作的安全性。模拟 IDE 中的“安全移动”功能。

SKILL.md
--- frontmatter
name: refactoring-safe
description: Validates move and rename operations by tracing dependencies first. Mimics IDE "Safe Move".
allowed-tools: Run Command, Grep

Refactoring Safe Skill

Goal: Prevent broken links and missing imports by checking references BEFORE moving files.

Protocol

  1. Identify Target:

    • Source file: src/old/path.py
    • Destination: src/new/path.py
  2. Trace References (Pre-Flight):

    • Use grepai trace callers "path/basename" or grepai search "basename" to find all usages.
    • CRITICAL: If grepai returns > 0 results outside the file itself, STOP and list them.
  3. Execute Move:

    • Only if 0 critical references found OR user explicitly approves after warning.
    • Use git mv (if git repo) or mv.
  4. Post-Move Update:

    • Update known references (imports, includes).
    • Verify: Run grep for the old path to ensure it's gone.

Usage

bash
# Safe Move
/refactor move source.py dest/