ast-grep
Use `code_search` and `code_rewrite` for syntax-aware code search and refactors when structure matters.
от 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 patterncode_rewrite(pattern, rewrite, lang, path?, dry_run?)— structural find-and-replace
Examples
console.log($MSG)— find all console.log callsvar $NAME = $VAL→const $NAME = $VAL— modernize var declarationscatch ($ERR) { }— find empty catch blocksimport $X from "lodash"— find imports from a specific module
Workflow
code_search(pattern, lang, path, limit=20)— narrow path, sample first- Inspect matches — verify pattern catches what you want
code_rewrite(pattern, rewrite, lang, path, dry_run=true)— preview changes- Review the dry run output
code_rewrite(pattern, rewrite, lang, path, dry_run=false)— apply- 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=truebefore applying any rewrite - Scope with
pathto avoid unintended matches in vendored/generated code - Supported
langvalues: 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
langis correct (e.g.typescriptnotts), broaden pattern - Too many matches: narrow
path, add more structure to pattern, lowerlimit - 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), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…