Install any skill in seconds. Free to start, no credit card required.
Get Started Free →nousresearch/ast-grep
AST-aware structural code search and rewrite via ast-grep.
Passed 17 of 20 test cases with the skill, and 7 of 20 without it.
and 13 more in the full report
12 fixed8 passed either way4 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 12 test cases the skill fixed. Same model, same prompt, with and without the skill.
I tested a dry run of replacing `console.log($MSG)` with `logger.info($MSG)` using `ast_grep_helper.py replace` and verified the preview. What flag must be added to actually execute the mutation on disk?
| Checked | Without skill | With skill |
|---|---|---|
| Specifies adding `--apply` flag. | Missed | Passed |
The instructions your model reads when the skill loads.
ast-grep (binary also named sg) is an AST-aware search and rewrite tool across 25 languages. It treats your pattern as code, parses it the same way it parses your project, and matches structurally. It is the right tool whenever your question depends on code shape rather than text bytes.
This skill ships a Python wrapper at scripts/ast_grep_helper.py and platform install scripts at install.sh (POSIX) and install.ps1 (Windows). The helper adds offline pattern validation, the two-pass write trick, and binary auto-resolution. Use it as your default entry point.
Upstream source: vendored from code-yeongyu/ast-grep-skill (MIT), as shipped in oh-my-openagent's shared-skills bundle.
Use it whenever the question is about code structure, not bytes:
Request parameter."console.log(x) to logger.info(x)."as any cast."require(...) with import across the repo."Optional[X] to X | None."Switch to search_files (or plain rg) when the question is text-shaped (string literal contents, comments, license headers, file names, cross-language regex). When in doubt, ask: "does the answer depend on the language's syntax tree, or just on the file's bytes?" If the former, ast-grep. If the latter, search_files.
Hermes integration notes:
sg through the terminal tool. Single-quote every pattern so the shell never expands $VAR.--json-out and process with execute_code rather than piping through interpreters.patch tool: patch is for targeted edits you author; ast-grep is for pattern-driven bulk rewrites across many sites.The wildcards are $VAR (one AST node) and $$$ (zero or more nodes). Regex syntax fails silently:
| You wrote | What ast-grep saw | What you wanted |
|---|
test cases passed, vs 7 / 20 without
Published skills whose descriptions closely match this one, with their headline benchmark lift.
More skills from the same source and nearby in the registry, with their headline benchmark lift.