📦 Safe change

v1.0.1

Map blast radius before shipping — 运行 when editing a 服务, 控制器, hook, or 分享d 实用工具 to surface all 导入ers, affected API 路由s, test gaps,...

0· 0·0 当前·0 累计
0
安全扫描
VirusTotal
无害
查看报告
OpenClaw
安全
high confidence
该技能的代码、说明和要求与其既定目的(映射爆炸半径并限制变更)保持一致;它是只读的静态分析,外加一个预期的验证门,用于运行项目的构建/测试脚本。
评估建议
该技能如其所述:只读影响分析,外加可选的验证门。安装/运行前,请确保 agent 可在安全环境中执行 shell 命令(测试和 npm 脚本会运行任意仓库代码,可能有副作用)。若打算通过 agent 运行验证门,先检查项目的测试/构建脚本是否包含破坏性操作或外网请求。此外,扫描器基于 regex,可能漏计导入(barrel、动态导入、路径别名)——对 Low 分数保守看待,并在高风险区域手动检查 barrel/动态导入。...
详细分析 ▾
用途与能力
The 技能.md, README, and the included scripts implement an impact 扫描器 and a 验证 gate. The 扫描器 only reads project files (package.json and .ts/.tsx files) to build 导入ers, 路由s, env var references, and recent 迁移s. The 验证 gate 运行s tsc/lint/test/build if present. All 请求ed capabilities align with 'map blast radius' and '验证 build integrity'.
指令范围
Instructions confine the 代理 to 运行ning the included 扫描器 and 验证 script and to pausing for an explicit 检查point. The 扫描器 performs project-wide read-only file traversal and regex analysis (expected). The 验证 gate 执行s project commands (npm scripts, tsc) which may 运行 arbitrary repo code (tests/build scripts can have side effects) — this is expected for a 验证 gate but worth noting as an operational risk.
安装机制
无安装说明;该技能为指令 + 脚本已打包在 bundle 中。技能本身不会执行任何外部下载或包安装(scan-impact.mjs 刻意仅使用 Node 标准库)。
凭证需求
The 技能 declares no required 环境 variables or 凭证s. The 扫描器 only locates process.env.* references in source files (it does not read those 环境 values). No unrelated secrets or external 服务 凭证s are 请求ed.
持久化与权限
The 技能 is not forced-always, does not modify other 技能s or global 代理 configuration, and contAIns no code that persistently enables itself. The 验证 gate 运行s local build/test commands but does not change other 技能s or 系统-wide 设置tings.
安全有层次,运行前请审查代码。

运行时依赖

无特殊依赖

安装命令

点击复制
官方npx clawhub@latest install safe-change
镜像加速npx clawhub@latest install safe-change --registry https://cn.longxiaskill.com

技能文档

安全变更 先看清“爆炸半径”再动手。Safe Change 会扫描任何代码变更的影响面——importers、API routes、测试覆盖率、ENV 变量、数据库迁移——给出风险分,等你 go/no-go 才跑 verify gate。它是深度调试的前置保镖:在 bug 上线前拦截,而不是事后救火。

速查表 情境 → 动作 准备改共享服务 → 先跑 scan-impact.mjs 目标文件 风险分 High → 停!读报告,明确 go/no-go 测试缺口 (gap: true) → 先写测试再改代码 发现近期迁移 → 部署前确认迁移兼容 全部通过 → 跑 verify-gate.sh 确认构建 风险分 Low 且测试全绿 → 继续,最后跑 verify gate

何时启用 只要满足以下任一条件:

  • 重命名/抽取被多处引用的函数/类
  • 修改服务方法签名
  • 动 NestJS controller 或 Next.js API route
  • 目标文件被 ≥3 个文件 import
  • 改到读取 process.env 的代码
  • migrations 文件夹存在未部署迁移
  • 同事问“改 X 安全吗?”

别因“改动小”就跳过。多数线上事故都始于“小改动”。

工作原理——6 阶段 阶段1 探测栈:读根目录 package.json,识别 NestJS / Next.js / 纯 TS。 阶段2 构建影响图:执行 scripts/scan-impact.mjs <目标文件>,用正则静态分析收集:

  • Importers:所有 .ts/.tsx 引用
  • API Routes:NestJS @Controller 及动词装饰器;Next.js app/api//route.ts
  • Tests:引用目标的 spec/test 文件;无则置 gap
  • ENV:目标文件内 process.env.X
  • DB 迁移:近 7 天修改的 migrations/ 文件

阶段3 风险分 Low:≤2 importers,无 route,有测试,无 ENV,无近期迁移 Medium:3–7 importers 或 1–2 routes 或测试缺口 或含 ENV High:≥8 importers 或 ≥3 routes 或(测试缺口+ENV+近期迁移)

阶段4 渲染报告:JSON → Markdown,顶部醒目标风险分。 阶段5 强制卡点: “风险分 [Low/Medium/High],是否继续?(yes/no/adjust scope)” 用户确认前绝不继续。

阶段6 验证门: 执行 scripts/verify-gate.sh,顺序跑: tsc --noEmit → lint → test → build 任一失败即停,彩色输出,非零退出。

输出示例

Safe Change Report — src/notifications/notifications.service.ts

Risk Score: MEDIUM Risk factors: 5 importers, 1 API route, test coverage exists

Importers (5)

  • src/users/users.service.ts
  • src/appointments/appointments.service.ts
  • src/billing/billing.service.ts
  • src/reports/reports.service.ts
  • src/audit/audit.service.ts

API Routes Affected

| Controller | Endpoints | |------------|-----------| | NotificationsController | POST /notifications, GET /notifications |

Test Coverage

  • src/notifications/notifications.service.spec.ts ✓
  • Gap: no

ENV Variables Referenced

  • SMTP_HOST
  • SMTP_USER
  • SMTP_PASS

Recent Migrations (last 7 days)

  • None
---
Checkpoint:** Do you want to proceed with this change? (yes / no / adjust scope)

限制 见 references/limitations.md。核心约束:

  • 正则分析:无法识别动态 import(path)
  • barrel re-export 可能少算 importers
  • 自定义装饰器别名检测不到
  • v0.1 仅支持 TypeScript,无 Python/Go/Rust 适配

配套技能

  • deep-debugging:事故后深度排查
  • self-improving-agent:若变更引发事故,将报告记入学习日志

脚本 scripts/scan-impact.mjs — 生成影响图 JSON scripts/verify-gate.sh — 顺序跑 tsc→lint→test→build

目录结构 safe-change/ ├── SKILL.md ├── README.md ├── package.json ├── scripts/ │ ├── scan-impact.mjs │ └── verify-gate.sh

数据来源ClawHub ↗ · 中文优化:龙虾技能库