ast-grep-refactor
Structural refactoring and safe code rewrites with ast-grep across supported languages.
Skill by seruman
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/seruman-ast-grep-refactor
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/ast-grep-refactor
What's inside
- Skill name
ast-grep-refactor- Description
- Structural refactoring and safe code rewrites with ast-grep across supported languages. Use for codemods, removing or replacing AST nodes (imports, docstrings, arguments), pattern-based migrations, and multi-file transformations when plain text search/replace is likely to be unsafe.
- License
- MIT
- Instructions
- 54 lines in SKILL.md · view on GitHub
Files (8)
- SKILL.md
- examples.md · references/
- fix-expand.md · references/
- rewrite.md · references/
- rewriter.md · references/
- rule-basics.md · references/
- transform.md · references/
- troubleshooting.md · references/
SKILL.md (first lines)
# ast-grep Refactor Use ast-grep to refactor by AST, not by text. Keep rules small, test on samples, then scale to the codebase. ## Quick workflow 1. Inspect AST for the target pattern. 2. Write a rule that matches only what you intend. 3. Dry-run on small files and review diffs. 4. Apply at scale only after review or tests. 5. Format and run checks. ```bash ast-grep run --pattern '...' --lang <language> --debug-query=ast path/to/file ast-grep scan -r rule.yml path/to/file ast-grep scan -r rule.yml --update-all path/glob/** ``` Review matches via `ast-grep scan` output, `--interactive`, or `git diff` before `--update-all`. ## Decide the rule shape - Use `pattern` for simple rewrites with metavariables. - Use `kind` plus relational rules (`inside`, `has`, `nthChild`) for structural or positional changes. - Use `fix` string for direct replacement; use `FixConfig` when you must remove punctuation or neighbors. - Use `transform` to change captured strings; use `rewriters` to rewrite different subnodes differently. ## Rule files - Separate multiple rules with `---`. - Keep rules focused and composable. - For repeatable or risky changes, add rule tests and run `ast-grep test`. ## References - Rule basics and selection: `references/rule-basics.md` - Rewrite and `fix`: `references/rewrite.md` - FixConfig expansion: `references/fix-expand.md` - Transformations: `references/transform.md` - Rewriters: `references/rewriter.md` - Troubleshooting: `references/troubleshooting.md` - Examples: `references/examples.md` ## When to skip ast-grep - Very small, one-off edits where manual editing is faster. - Pure text replacement where AST structure does not matter. - Changes requiring type-aware or semantic analysis. ## Links - [ast-grep](https://github.com/ast-grep/ast-grep)
From seruman/pi-things, MIT.
More from seruman/pi-things
- 0.587score
git-wt
seruman
Use for requests to create, locate, list, or remove Git worktrees, including immediately after cloning a repository, or to carry uncommitted work into a…
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
hauntty
seruman
Use hauntty/ht when explicitly requested, when working with existing hauntty sessions, or when Rex is unavailable.
SkillAFreshness: A★ 1Claude Code +9 - 0.579score
rex
seruman
Runs persistent shells, dev servers, long-running commands, and interactive programs in Rex.
SkillAFreshness: A★ 1Claude Code +9 - 0.562score
tdd
seruman
Test-driven development.
SkillAFreshness: A★ 1Claude Code +9 - 0.547score
teteyectl
seruman
Control and inspect a running Teteye terminal through its teteyectl CLI.
SkillBFreshness: B★ 1Claude Code +9 - 0.547score
terminal-browser
seruman
Render a real Chromium browser in the terminal and control terminal-browser-managed tabs through CDP.
SkillBFreshness: B★ 1Claude Code +9 - 0.497score
git-hunks
seruman
Selective hunk-level staging and commits with git-hunks.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
sumocli
seruman
Query Sumo Logic operational logs from the command line using sumocli.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
web-search-guidance
seruman
Use for precise web searches when the user needs better query construction, domain scoping, file-type filtering, recency filtering, language targeting, or…
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
wb-browser
seruman
Use the installed wb CLI for persistent browser automation with compact page JSON and screenshots.
SkillCFreshness: C★ 1Claude Code +9 - 0.477score
diagnosing-bugs
seruman
Diagnosis loop for hard bugs and performance regressions.
SkillCFreshness: C★ 1Claude Code +9 - 0.472score
codebase-design
seruman
Shared vocabulary for designing deep modules.
SkillCFreshness: C★ 1Claude Code +9
Signals
- Stars
- 1
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- May 6, 2026 (5 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/seruman/pi-things
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from seruman
- 0.587score
git-wt
seruman
Use for requests to create, locate, list, or remove Git worktrees, including immediately after cloning a repository, or to carry uncommitted work into a…
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
hauntty
seruman
Use hauntty/ht when explicitly requested, when working with existing hauntty sessions, or when Rex is unavailable.
SkillAFreshness: A★ 1Claude Code +9 - 0.579score
rex
seruman
Runs persistent shells, dev servers, long-running commands, and interactive programs in Rex.
SkillAFreshness: A★ 1Claude Code +9 - 0.562score
tdd
seruman
Test-driven development.
SkillAFreshness: A★ 1Claude Code +9 - 0.547score
teteyectl
seruman
Control and inspect a running Teteye terminal through its teteyectl CLI.
SkillBFreshness: B★ 1Claude Code +9 - 0.547score
terminal-browser
seruman
Render a real Chromium browser in the terminal and control terminal-browser-managed tabs through CDP.
SkillBFreshness: B★ 1Claude Code +9
Cite this page
ast-grep-refactor skill. Agent Mart. https://agentmart.dev/skills/seruman-ast-grep-refactor (last updated 2026-10-24)