Know exactly what breaks before you touch it.
Safe Change maps the blast radius of any code change — importers, API routes, test coverage, ENV vars, database migrations — then gives you a risk score and waits for your go/no-go before running the verify gate.
It is the proactive companion to deep-debugging: catch impact before the bug ships, not after.
SituationActionAbout to edit a shared service→ Run scan-impact.mjs on the target file firstRisk score is High→ Stop, read the impact report, get explicit go/no-goTest gap detected ( gap: true)→ Write tests before changing, not afterRecent migrations found→ Confirm migration compatibility before deployingAll checks pass→ Run verify-gate.sh to confirm build integrityRisk score is Low, tests green→ Proceed, run verify gate at end
Activate this skill whenever:
process.envDo not skip this step for "small" changes. Most production incidents start as changes that felt small.
The agent reads package.json at the project root to determine:
Run scripts/scan-impact.mjs <target-file> from the project root.
The script uses regex-based static analysis (no AST compiler, zero install friction) to collect:
DimensionWhat is collectedImportersAll .ts/ .tsx files that import the targetAPI RoutesNestJS @Controller + HTTP verb decorators; Next.js app/api/**/route.tsTestsSpec/test files that import the target; gap flag when none existENV varsAll process.env.X references in the target fileDB migrationsFiles in migrations/ modified in the last 7 days
Heuristic scoring (see table below). The agent reads the JSON output and renders it as a human-readable report.
ScoreConditionsLow≤2 importers, no API routes, tests exist, no ENV vars, no recent migrationsMedium3–7 importers OR 1–2 routes OR test gap OR ENV vars presentHigh≥8 importers OR ≥3 routes OR test gap + ENV vars + recent migration
The agent formats the JSON from scan-impact.mjs into a Markdown report (see Output Format below). It presents the report and explicitly states the risk score at the top.
After presenting the report the agent must pause and ask:
"Risk score is [Low/Medium/High]. Do you want to proceed with this change? (yes / no / adjust scope)"
Do not proceed until the user confirms. This is the core safety gate.
After the change is made, run scripts/verify-gate.sh from the project root.
The gate runs in order:
tsc --noEmit — type-checknpm run lint (if script exists)npm test (if script exists)npm run build (if script exists)Stops on first failure. Color-coded output. Non-zero exit on failure.
The agent renders the JSON from scan-impact.mjs as:
markdown
## 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)
See references/limitations.md for the full list. Key constraints:
import(path)) are not detectedindex.ts) may undercount importers@Route() wrapping @Controller) are not detectedScriptPurposescripts/scan-impact.mjsBuilds impact map, outputs JSONscripts/verify-gate.shRuns tsc → lint → test → build in sequence
text
safe-change/
├── SKILL.md # This file
├── README.md # Marketing overview
├── package.json # ClawHub metadata
├── scripts/
│ ├── scan-impact.mjs # Impact analyzer (Node ESM, no deps)
│ └── verify-gate.sh # Verify gate (bash)
├── references/
│ ├── example-impact-report.md # Full SMTP swap example
│ ├── usage.md # How agent invokes the scripts
│ └── limitations.md # Known limitations + trade-offs
└── assets/
└── SKILL-TEMPLATE.md # Template for creating similar skills