Command Palette

Search for a command to run...

Назад к скиллам
скилл № 98715

ast-grep

Use `code_search` and `code_rewrite` for syntax-aware code search and refactors when structure matters.

БесплатноБез исполняемых скриптов
rcarmoот rcarmo★ 25 звёзд на GitHub

Установить ast-grep в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

AST Grep

Use this skill when text search would be noisy or unsafe.

Tools

  • code_search(pattern, lang, path?, limit?) — find code by AST pattern
  • code_rewrite(pattern, rewrite, lang, path?, dry_run?) — structural find-and-replace

Examples

  • console.log($MSG) — find all console.log calls
  • var $NAME = $VAL → const $NAME = $VAL — modernize var declarations
  • catch ($ERR) { } — find empty catch blocks
  • import $X from "lodash" — find imports from a specific module

Workflow

  1. code_search(pattern, lang, path, limit=20) — narrow path, sample first
  2. Inspect matches — verify pattern catches what you want
  3. code_rewrite(pattern, rewrite, lang, path, dry_run=true) — preview changes
  4. Review the dry run output
  5. code_rewrite(pattern, rewrite, lang, path, dry_run=false) — apply
  6. Read changed files, run formatting/tests

Prefer other tools when

  • You need plain text, comments, or strings → grep
  • You need type/symbol-aware results → LSP/symbol tools if available

Safety

  • Always run dry_run=true before applying any rewrite
  • Scope with path to avoid unintended matches in vendored/generated code
  • Supported lang values: typescript, javascript, tsx, jsx, python, rust, go, java, c, cpp, csharp, ruby, swift, kotlin, lua, html, css, json, yaml
  • After applying rewrites, read changed files and run tests/formatting before moving on

Troubleshooting

  • No matches: verify lang is correct (e.g. typescript not ts), broaden pattern
  • Too many matches: narrow path, add more structure to pattern, lower limit
  • Pattern error: simplify — patterns must be valid syntax in the target language
  • Wrong language: typescript ≠ tsx, javascript ≠ jsx — run separate passes

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл ast-grep?

Use `code_search` and `code_rewrite` for syntax-aware code search and refactors when structure matters.

Как установить скилл ast-grep?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл ast-grep запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить ast-grep с