run-scan
รัน ast-grep scan เพื่อตรวจสอบ codebase ด้วย AST-based patterns
SKILL.mdrun-scan/SKILL.md
GitHubGoal
Run ast-grep scan to check the codebase with AST-based patterns and fix the issues found
Scope
Use for scanning the codebase with ast-grep in a project that has sgconfig.yml and rules in a rules/ directory
Execute
Pre-Run: Always run
/deep-reviewfirst —run-*must be reviewed/assessed before the main work, never skip; if findings are blockers, fix or report before running (scan)
1. Setup And Write Rules
Goal: Setup And Write Rules
- Run
/use-astgrepto install and set upast-grep - Check that
sgconfig.ymlhasruleDirs: rulesand thatpackage.jsonhas ascanscript - If there are no rules yet, run
/update-astgrep-rulesto create rules in therules/directory - Run
/update-astgrep-rulesto update and check the rulesbeforerunning scan, always — stale rules make the findings inaccurate
2. Run Scan
Goal: Run Scan
- Run
bun run scanorast-grep scan - Run
/reportto format the output and identify issues - Consider whether any rules are inappropriate, correct, and fitting
- Fix the code according to the suitable suggestions, or use
--interactivemode for selective apply
3. Verify
Goal: Verify
- Run
/loop-until-completeto rerun scan until there are no issues - Check that the fixes do not break the code
- Use
ast-grep testto verify the rules - If there are errors after fixing, run
/resolve-errors
Rules
- There must be an
sgconfig.ymlat the root directory and ascanscript inpackage.json - Rules must live in the
rules/directory and use severity according to importance (error,warning,info) - Review the output every time before applying fixes, and use
--interactivemode for selective apply - Rerun scan after applying fixes and check that the code still works
- If the project has CI/CD, add scan to the pipeline and run it before commit
- Update the rules when new patterns appear, and review false positives to tune the rules
- For a structure scan (symbols, exports, members) that needs no rules → use
/check-code-structure(sg outline)
Expected Outcome
- The
ast-grepCLI is installed and configured - Rules are created in the
rules/directory - Scan runs and identifies the correct issues
- Issues are fixed and verified
- The codebase passes
ast-grep scanwith no errors