Skip to content
Kitbay
Skill

ast-grep

MITUpdated on Nov 16, 2026360GitHub stars

A skill from the OmAgents toolkit for searching and rewriting code by its syntax tree with the ast-grep command-line tool, so matches inside strings and comments are not picked up as they would be with plain text search.

What the skill teaches

A skill from the OmAgents toolkit for searching and rewriting code by its syntax tree with the ast-grep command-line tool, so matches inside strings and comments are not picked up as they would be with plain text search. It checks whether sg is installed or can run through npx, explains pattern syntax with metavariables that bind one node or many, and lets the language be detected from file extensions or set explicitly. Rewrites are always previewed before being applied to all files. A refactor mode works one file at a time through a task queue kept by a loop_engine.py script, running tests after each change, and grep equivalents are given when ast-grep is missing.

Capabilities

  • Search code by syntax pattern
  • Preview and apply structural rewrites
  • Refactor file by file with tests after each
  • Fall back to grep when ast-grep is missing