mcpField
G
gitnexus-impact-analysis

gitnexus-impact-analysis

github.com/tony363开发2056 次安装30 周前更新
代码仓库

关于 gitnexus-impact-analysis

通过依赖关系和执行流程分析代码变更影响的 GitNexus 技能,指导开发者在修改或提交前检查符号影响、变更范围与风险。

主要功能

  1. 01追踪符号依赖关系
  2. 02按依赖深度分析影响
  3. 03检查受影响的执行流程
  4. 04将 Git 变更映射到流程
  5. 05评估变更风险

适用场景

  1. 01修改函数前检查调用方
  2. 02提交前检查受影响流程
  3. 03估算代码变更风险

MCP 相关

使用 GitNexus MCP 工具 gitnexus_impact 和 gitnexus_detect_changes,并读取仓库 processes 资源以识别受影响的执行流程。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/tony363/superclaude --skill gitnexus-impact-analysis

安装后在 Claude Code 中输入/gitnexus-impact-analysis确认已加载。

详细介绍

使用 GitNexus 进行影响分析

适用场景

  • “修改这个函数安全吗?”
  • “如果我修改 X,会有什么东西出问题?”
  • “显示影响范围”
  • “哪些地方在使用这段代码?”
  • 进行重要代码更改之前
  • 提交之前——了解更改会影响哪些内容

工作流

1. gitnexus_impact({target: "X", direction: "upstream"})  → What depends on this
2. READ gitnexus://repo/{name}/processes                   → Check affected execution flows
3. gitnexus_detect_changes()                               → Map current git changes to affected flows
4. Assess risk and report to user

如果显示“索引已过期”,请在终端中运行 npx gitnexus analyze。

检查清单

- [ ] gitnexus_impact({target, direction: "upstream"}) to find dependents
- [ ] Review d=1 items first (these WILL BREAK)
- [ ] Check high-confidence (>0.8) dependencies
- [ ] READ processes to check affected execution flows
- [ ] gitnexus_detect_changes() for pre-commit check
- [ ] Assess risk level and report to user

理解输出

深度风险等级含义
d=1将会出问题直接调用方/导入方
d=2可能受到影响间接依赖
d=3可能需要测试传递影响

风险评估

受影响范围风险
<5 个符号,少量流程低
5-15 个符号,2-5 个流程中
>15 个符号或大量流程高
关键路径(身份验证、支付)严重

工具

gitnexus_impact — 用于分析符号影响范围的主要工具:

gitnexus_impact({
  target: "validateUser",
  direction: "upstream",
  minConfidence: 0.8,
  maxDepth: 3
})

→ d=1 (WILL BREAK):
  - loginHandler (src/auth/login.ts:42) [CALLS, 100%]
  - apiMiddleware (src/api/middleware.ts:15) [CALLS, 100%]

→ d=2 (LIKELY AFFECTED):
  - authRouter (src/routes/auth.ts:22) [CALLS, 95%]

gitnexus_detect_changes — 基于 git 差异的影响分析:

gitnexus_detect_changes({scope: "staged"})

→ Changed: 5 symbols in 3 files
→ Affected: LoginFlow, TokenRefresh, APIMiddlewarePipeline
→ Risk: MEDIUM

示例:“如果我修改 validateUser,会有什么东西出问题?”

1. gitnexus_impact({target: "validateUser", direction: "upstream"})
   → d=1: loginHandler, apiMiddleware (WILL BREAK)
   → d=2: authRouter, sessionManager (LIKELY AFFECTED)

2. READ gitnexus://repo/my-app/processes
   → LoginFlow and TokenRefresh touch validateUser

3. Risk: 2 direct callers, 2 processes = MEDIUM

评论

支持 Markdown