code-yeongyu

Ast Grep Skill — AI skill for Claude Code

AI community

LLM-neutral skill for AST-aware search and rewrite across 25 languages, wrapping ast-grep (sg) with offline pattern validation, two-pass writes, and per-OS install scripts.

How to install Ast Grep Skill

This entry records only its repository, not the path inside it, so there is no exact command to give. Open code-yeongyu/ast-grep-skill and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Ast Grep Skill does

LLM-neutral skill for AST-aware search and rewrite across 25 languages, wrapping ast-grep (sg) with offline pattern validation, two-pass writes, and per-OS install scripts.

Alternatives in AI

  • Jcodemunch MCP — Cut AI token costs 95%+ on code exploration 2.6k ★
  • Empryo — Empryo issue tracker + SoulForge (v2) 1.1k ★
  • Humanize Ppt — AST-based outline director for human-centered AI presentation workflows 934 ★

README

ast-grep-skill

LLM-neutral skill for **AST-aware search and rewrite** across 25 languages. Wraps the [`ast-grep`](https://ast-grep.github.io/) (`sg`) CLI with offline pattern validation, the two-pass write trick, binary auto-resolution, and a per-OS installer.

Same shape as [`web-fetch`](https://github.com/code-yeongyu/web-fetch) and [`web-search`](https://github.com/code-yeongyu/web-search), packaged as a standalone skill that any Bash-capable agent (Claude Code, OpenCode, pi, hermes, openclaw) can load.

Install

git clone https://github.com/code-yeongyu/ast-grep-skill ~/.agents/skills/ast-grep
bash ~/.agents/skills/ast-grep/install.sh        # installs the ast-grep binary

That is it. The wrapper script is single-file Python 3 stdlib; no `pip install` needed. The installer tries `brew` → `npm` → `cargo` → `pip` → `nix` → `mise` → GitHub release in priority order, picks the first that works, and falls back to a cached binary at `/bin/sg`.

Symlink for active development

ln -s /path/to/your/clone ~/.agents/skills/ast-grep

Other agents

  • Claude Code / OpenCode: drop the directory under ~/.agents/skills/ (or ~/.config/opencode/skills/) and the skill auto-registers via the name + description in SKILL.md frontmatter.
  • pi (~/.senpi/agent): not a pi extension — this is a skill. Pi consumes skills via ~/.agents/skills/ symlinks; the actual pi-ast-grep extension is at https://github.com/code-yeongyu/pi-extensions.
  • Direct CLI use: python3 ~/.agents/skills/ast-grep/scripts/ast_grep_helper.py .

Usage

# Search by AST pattern (the helper validates patterns offline first)
python3 scripts/ast_grep_helper.py search 'console.log($MSG)' --lang ts src/

# Rewrite (dry-run preview by default)
python3 scripts/ast_grep_helper.py replace 'console.log($MSG)' 'logger.info($MSG)' --lang ts src/

# Apply the rewrite (two-pass: preview JSON + then --update-all)
python3 scripts/ast_gr