skills/ast-grep/SKILL.md
Explore and transform large codebases with ast-grep using AST-aware search, rule-based scanning, and safe codemod workflows. Use when requests involve structural code search beyond regex, writing/testing ast-grep YAML rules, reducing noisy matches by syntax, or applying multi-file rewrites with controlled rollout.
npx skillsauth add hayatosc/dotfiles ast-grepInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use ast-grep for syntax-aware exploration and rewrite that stays resilient in large or mixed-language repositories.
ast-grep is installed.run) or rule-driven scan (scan).--globs, path) before changing strictness.--debug-query when matches are missing.--interactive or --update-all.Use command examples from:
references/command-cookbook.mdast-grep new ....id, language, rule, and optional constraints/fix.files/ignores in YAML.ast-grep test.scan --filter or bounded paths.Use authoring details from:
references/rule-authoring.mdRun scripts/sg_safe_rewrite.py to enforce preview-first rewrites for large codebases.
python scripts/sg_safe_rewrite.py \
--pattern 'console.log($$$ARGS)' \
--rewrite 'logger.info($$$ARGS)' \
--lang TypeScript \
--glob 'src/**/*.ts' \
--mode interactive
Modes:
preview: show rewrite diff onlyinteractive: review and accept changes selectivelyapply: apply all matched rewrites (--update-all)--lang, AST pattern shape) before adding broad regex-like workarounds.scan --inline-rules for quick hypothesis tests; promote stable logic to YAML files.--json=stream for large output pipelines; avoid pretty JSON for machine processing.--inspect summary to debug unexpected file/rule discovery behavior.tools
Recommend a modern TypeScript toolchain. Use when choosing or updating a TypeScript stack for Node or CLI projects, libraries or packages, and web apps or APIs; selecting tsgo as the primary typechecker with tsc as compatibility fallback; recommending Hono, tsx, tsdown, Vite, Vitest, oxlint, oxlint-tsgolint, oxfmt, or deciding between bun and pnpm.
development
Implement, review, and refactor TypeScript code with a strong bias toward type safety. Use to fix TypeScript errors, remove `any` or unsafe `as`, review type safety, tighten TypeScript or lint settings, and ship ESM-first code that passes the repository's typecheck without weakening types.
development
Self-review, improve, commit, and push code that Claude has just written. Use this skill when the user asks Claude to "self-ship", "review and ship", "review then commit and push", or wants Claude to autonomously review its own output, apply improvements, and publish the changes to the remote repository. Triggered by: "self-ship", "ship it", "review and push", "review my changes and commit", or similar requests to complete the full write → review → commit → push cycle.
development
Analyze and execute behavior-preserving refactors in small, verified steps. Use when the user asks to refactor, clean up code structure, extract functions or modules, reduce duplication, improve maintainability, or modernize code without changing external behavior.