Skill: node-verify-import
Scans .js and .ts files for require() / import statements and verifies every local
path actually exists on disk. Reports broken imports with file name and line number so they
can be fixed immediately.
Step 1 — Detect Language
Check the user's message language:
- Vietnamese → respond in Vietnamese ("Anh/chị")
- English → respond in English
- Default → English
Step 2 — Determine Scan Target
Ask the user which directory to scan only if it's not already clear from context.
Use AskUserQuestion with these options:
| Option | Description |
|---|---|
srv/ (Recommended) |
Standard CAP backend folder |
src/ |
Typical frontend / other Node project |
| Whole project | Scan everything (slower) |
| Custom | Let user type a path |
If the user already mentioned a path (e.g., "check imports in lib/"), skip this step and
use that path directly.
Step 3 — Run the Verification Script
Run the bundled script using the Bash tool:
node <skill_dir>/scripts/verify-imports.js [--dir <target_dir>] [--ext js,ts] [--skip node_modules,generated,dist]
Full example:
node /path/to/skill/scripts/verify-imports.js --dir srv
The script auto-detects the project root as process.cwd(). It resolves --dir relative
to that root, so run the command from the project root (or use an absolute path for --dir).
CLI flags (all optional):
| Flag | Default | Description |
|---|---|---|
--dir |
srv |
Directory to scan |
--ext |
js,ts |
File extensions to check (comma-separated) |
--skip |
node_modules,generated,service-specifications,dist,.git |
Dirs to exclude |
--json |
off | Output machine-readable JSON instead of human text |
Step 4 — Interpret and Report Results
If 0 broken imports:
"✅ Tất cả imports hợp lệ! / ✅ All imports are valid!" Show total files scanned and total requires checked.
If broken imports found:
Group errors by file for readability. Show:
- Relative file path + line number
- The broken
require("...")path - What path it resolved to (to help the user understand what's wrong)
Then suggest likely causes:
- File was renamed but require wasn't updated
- Wrong relative path (
../vs./) - Missing
.jsextension in the require path - File exists as
.tsbut required as.js
Step 5 — Offer to Fix (Optional)
If broken imports were found, offer:
- Show fix suggestions — list the corrected require paths side-by-side
- Auto-fix — update the files using Edit tool (ask confirmation first)
- Skip — user just wanted the report
Important Notes for All Agents
- Always run the script via
node, not by executing it directly - The script uses only Node.js built-ins (
fs,path) — nonpm installneeded - If the scan directory doesn't exist, the script exits with code 0 and prints a warning (not an error) — this is intentional for CI use
- Exit code 1 = broken imports found; exit code 0 = all good
- The script skips comment lines (
//,*) to avoid false positives - It checks three candidate paths for each require:
path,path.js,path/index.js