amlkshoot-hub

Legacy Change Impact — AI skill for Claude Code

AI community

在改老代码之前摸清影响面:三层引用扫描(L1/L2/L3)、P0-P3 定级、回归清单与回滚点.

How to install Legacy Change Impact

This entry records only its repository, not the path inside it, so there is no exact command to give. Open amlkshoot-hub/legacy-change-impact and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Legacy Change Impact does

在改老代码之前摸清影响面:三层引用扫描(L1/L2/L3)、P0-P3 定级、回归清单与回滚点。给 AI 编码助手用的 skill。

Alternatives in AI

  • Semble Rs — Fast, AI-agent-native code search in Rust — hybrid BM25 + semantic, Tree-sitter AST chunking, dependency & imp 210 ★
  • Component To Release Agent — Chains design-to-code, accessibility and token-compliance checks (three release gates), then the AI descriptio 194 ★
  • GPT 5.5 Prompt Enhancement — Use when a prompt explicitly requests GPT-5.5 style — pointer stub 176 ★

README

legacy-change-impact

改老代码之前,先摸清会炸到哪。

A skill for AI coding agents: before you modify legacy code, map every reference — including the ones the compiler cannot see — and produce a graded impact report with a regression checklist and rollback points.


问题

在老项目里把一个字段名改掉,编译照样通过,测试也绿,然后线上静默出错。

因为真正的引用不在 import 里,而在这些地方:

  • @TableName("user_profile") 这种字符串映射
  • MyBatis XML 里手写的 FROM user_profile
  • 配置文件的 key、*.properties、*.yml
  • 已经执行过的迁移脚本
  • 定时任务名、消息 topic、缓存 key
  • 前端硬编码的接口路径

模型默认的行为是 grep 一下符号名就停手,正好漏掉全部这些。这个技能就是补这个洞。

它做什么

五步流程,产出三样东西:

  1. 拆锚点 —— 把"我要改什么"拆成 3~8 个可搜索的符号
  2. 三层扫描 —— 见下表,脚本负责找得到
  3. 补扫隐式引用 —— 反射、DI、ORM 约定、序列化、调度,脚本扫不到的部分
  4. 定级 —— P0 静默出错 / P1 运行才崩 / P2 编译即红 / P3 无影响
  5. 产出 —— 影响面表(带 file:line 证据)+ 可执行回归清单 + 回滚点
层 内容 出错时机
L1 普通代码里的引用 编译或启动直接报错,风险最低
L2 字符串内引用、同源命名 不报错,静默出错
L3 sql / yml / xml 等数据契约 改完不可回滚,坏在别人那边

事故几乎全部落在 L2 和 L3。所以分析的时间花在这两层,不是花在找 import 上。

快速开始

需要 PowerShell 5.1 或 7(Windows 自带),git 可选。

git clone https://github.com/amlkshoot-hub/legacy-change-impact.git
cd legacy-change-impact

.\scripts\scan-refs.ps1 -Root .\examples\demo-repo -Symbol user_profile,nick_name

不用准备真实项目,`examples/demo-repo` 里埋了常见的坑,直接能看到效果。输出样例见 [`examples/sample-output.txt`](examples/sample-output.txt)。

用你自己的仓库:

.\scripts\scan-refs.ps1 -Root D:\code\your-legacy-project -Symbol 旧函数名,表名

**符号只写一个就够。** 脚本会自动派生命名变体:

输入 自动一起扫
WlwCardApplication wlw_card_application、wlw-card-application、WLW_CARD_APPLICATION、wlwCardApplication、wlwcardapplication

所以给一个 Java 类名,就能同时带出数据库表名、迁移脚本和 MyBatis XML 里的引用——这正是手工 grep 最容易漏掉的一层。

只知道改了什么文件?

那就别猜符号,直接让脚本从 git diff 里提取:

.\scripts\scan-refs.ps1 -Root D:\code\your-project -Diff HEAD~1   # 某个提交范围
.\scripts\scan-refs.ps1 -Root D:\code\your-project -Diff working  # 当前未提交的改动
.\scripts\scan-refs.ps1 -Root D:\code\your-project -Diff staged   # 已暂存