hylarucoder/skills-for-vibe-coder/ast-grep-rule-crafter
Claude Code and agent skill by hylarucoder/skills-for-vibe-coder
- community
Checking that the SKILL.md file is still in the repository.
Write AST-based code search and rewrite rules using ast-grep YAML. Create linting rules, code modernizations, and API migrations with auto-fix. Use when the user mentions ast-grep, tree-sitter patterns, code search rules, lint rules with YAML, AST matching, or code refactoring patterns.
Install
npx vskill@latest install hylarucoder/skills-for-vibe-coder/ast-grep-rule-crafterSKILL.md
ast-grep Rule Crafter
ast-grep uses tree-sitter to parse code into AST, enabling precise pattern matching. Rules are defined in YAML for linting, searching, and rewriting code.
Quick Start
Project Configuration
项目级扫描需要 sgconfig.yml 配置文件:
典型项目结构:
运行项目扫描:
注意:ast-grep scan命令必须有sgconfig.yml,而ast-grep run -p可单独使用。
Rule Workflow
Lint Rule (常见)
只检查不修复,用于 CI/编辑器提示:
验证:
Rewrite Rule (可选)
需要自动修复时添加 fix:
应用修复:
开发流程
调试 AST 结构:
Essential Syntax
| Element | Syntax | Example | |
|---|---|---|---|
| Single node | $VAR | console.log($MSG) | |
| Multiple nodes | $$$ARGS | fn($$$ARGS) | |
| Same content | Use same name | $A == $A | |
| Non-capturing | $_VAR | $_FN($_FN) |
Core Rules Quick Reference
| Type | Purpose | Example | |
|---|---|---|---|
pattern | Match code structure | pattern: if ($COND) {} | |
kind | Match AST node type | kind: function_declaration | |
all | Match ALL conditions | all: [pattern: X, kind: Y] | |
any | Match ANY condition | any: [pattern: var $A, pattern: let $A] | |
not | Exclude matches | not: {pattern: safe_call()} | |
has | Must have child | has: {kind: return_statement} | |
inside | Must be in ancestor | inside: {kind: class_body} |
Detailed References
Complete syntax guide: See references/rule-syntax.md
- Atomic rules (pattern, kind, regex, nthChild, range)
- Composite rules (all, any, not, matches)
- Relational rules (has, inside, follows, precedes)
- Transform and fixConfig
Language-specific patterns: See references/common-patterns.md
- JavaScript/TypeScript examples
- Python examples
- Go and Rust examples
Supported Languages
Bash, C, Cpp, CSharp, Css, Elixir, Go, Haskell, Hcl, Html, Java, JavaScript, Json, Kotlin, Lua, Nix, Php, Python, Ruby, Rust, Scala, Solidity, Swift, Tsx, TypeScript, Yaml
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/ast-grep-rule-crafter/SKILL.md
Popularity
- Repository stars
- 52
- Repository forks
- 5
- 7-day trend score
- 20
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 18 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/hylarucoder/skills-for-vibe-coder/ast-grep-rule-crafter)