Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add usefulmove/enso --skill ast-grep-refactorgit clone --depth 1 https://github.com/usefulmove/ensoWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/usefulmove/enso/ast-grep-refactor)<a href="https://agentmods.dev/skills/usefulmove/enso/ast-grep-refactor"><img src="https://agentmods.dev/badge/skills/usefulmove/enso/ast-grep-refactor/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/usefulmove/enso/ast-grep-refactor"><img src="https://agentmods.dev/badge/skills/usefulmove/enso/ast-grep-refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00091 | $0.01436 |
| Opus 5.5 | $0.00036 | $0.00574 |
| Sonnet 5.5 | $0.00018 | $0.00287 |
| Haiku 4.5 | $0.00009 | $0.00144 |
Grade A, and why
ast-grep-refactor scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 174 lines — stays where its author put it; the contents beside it link to each section on GitHub.
When to Use
Load this skill when:
- Renaming a prop, type, function, or symbol across many files where text-replace would be ambiguous
- Migrating an API pattern (e.g., deprecated import path → new path, callback style → async/await)
- Enforcing a code convention at scale (e.g.,
console.log→logger.debugeverywhere) - The agent would otherwise reach for
sed,awk, or a custom Python parser to modify source files - The change touches 5+ files where broken syntax would be hard to detect without running the compiler
Do not use for single-file edits — use the Edit tool directly. This skill is for codebase-scale changes.
Prerequisites
Verify ast-grep is installed before starting:
sg --version
# Expected: ast-grep 0.x.x
If missing:
npm install -g @ast-grep/cli
# Then ensure ~/.npm-global/bin is on PATH
export PATH="$HOME/.npm-global/bin:$PATH"
Language Reference
| Language | --lang flag |
File extensions |
|---|---|---|
| TypeScript | ts |
.ts |
| TSX (React) | tsx |
.tsx |
| JavaScript | js |
.js, .jsx |
| C++ | cpp |
.cpp, .h, .hpp |
Omit --lang to let ast-grep infer from file extensions (safe for single-language directories).
Pattern Syntax
Patterns look like the code you want to match. Replace variable parts with metavariables.
| Metavariable | Matches | Example |
|---|---|---|
$VAR |
Any single AST node | $OBJ.$METHOD() |
$$$ARGS |
Zero or more nodes (variadic) | foo($$$ARGS) |
$_ |
Any node (unnamed/throwaway) | if ($_ ) { $$$ } |
Common Patterns for TS/TSX/JS
| Goal | Pattern | Rewrite |
|---|---|---|
| Rename function call | oldFn($$$ARGS) |
newFn($$$ARGS) |
| Rename method on any object | $OBJ.oldMethod($$$ARGS) |
$OBJ.newMethod($$$ARGS) |
| Replace import path | import $X from 'old-path' |
import $X from 'new-path' |
| Replace named import | import { oldName } from '$MOD' |
import { newName } from '$MOD' |
| Null guard → optional chaining | $X && $X.$METHOD() |
$X?.$METHOD() |
| JSX prop rename | <$C $OLD={$V} /> |
<$C $NEW={$V} /> |
| console.log → logger | console.log($$$ARGS) |
logger.debug($$$ARGS) |
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3mo ago First seen · 174 lines · 91 tokens per session scan A 724288aa715f
ast-grep-refactor is a skill published in the GitHub repository usefulmove/enso (2 stars, last pushed 5mo ago), licensed MIT. It adds 91 tokens to every session and 1,436 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
ast-grep-refactor compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| ast-grep-refactorusefulmove/enso | Skill | 2 | 5mo ago | MIT | A | 91 | Claude Code, Codex |
| last30Dayschaitanyagiri/munder-difflin | Skill | 10k | 2d ago | MIT | A | 83 | Claude Code |
| thisQuarterchaitanyagiri/munder-difflin | Skill | 10k | 2d ago | MIT | A | 78 | Claude Code |
| thisWeekchaitanyagiri/munder-difflin | Skill | 10k | 2d ago | MIT | A | 77 | Claude Code |
| md-fetch-summarizechaitanyagiri/munder-difflin | Skill | 10k | 2d ago | MIT | A | 93 | Claude Code |
| harnessrevfactory/harness | Skill | 9.4k | 2mo ago | Apache-2.0 | A | 184 | Claude Code |
| brainstorminghuiliyi37/Tianshu-harness | Skill | 1.4k | 4d ago | Apache-2.0 | A | 37 | Claude Code, Codex |