hylarucoder/skills-for-vibe-coder
Overview
This skill helps you write AST-based code search and rewrite rules using ast-grep YAML. It focuses on creating precise linting rules, automated rewrites, and API migrations using tree-sitter patterns. The guidance emphasizes practical patterns, constraints, and fix configurations to reduce false positives and enable safe auto-fixes.
How this skill works
It translates desired code patterns into ast-grep YAML rules that match AST nodes via tree-sitter queries. Rules can be pure lint checks (pattern + message) or include a fix field for automated rewrites. It also helps compose composite conditions (all/any/not/has/inside) and capture groups ($VAR, $$$ARGS) to build targeted matches and preserve context during transformation.
When to use it
- You need precise code search across a codebase using AST rather than regex.
- You want to add CI lint rules that detect anti-patterns or deprecated APIs.
- You need automated code migrations or modernizations with safe auto-fixes.
- You are developing editor/IDE diagnostics based on AST patterns.
- You want to reduce false positives by adding structural constraints (has, inside, kind).
Best practices
- Start by exploring patterns interactively: ast-grep -p 'pattern' src/ and use --debug-query to inspect AST nodes.
- Prefer specific node kinds and has/inside constraints to limit scope and avoid overmatching.
- Use capture variables ($VAR, $$$ARGS) to preserve and reuse source fragments in fixes.
- Validate rules with ast-grep scan -r rule.yml src/ before enabling --update-all for rewrites.
- Iterate: add constraints for false positives, and include severity and clear message for CI/editor feedback.
Example use cases
- Replace console.log(...) with logger.log(...) across a JavaScript codebase using pattern and fix with $$$ARGS.
- Create a lint rule that flags use of deprecated API calls and suggests the new API signature.
- Migrate callback-style code to async/await by matching function call structures and applying structured rewrites.
- Enforce coding conventions, e.g., forbid top-level mutable exports by matching export patterns and reporting location.
- Build language-agnostic search rules for cross-language patterns supported by tree-sitter grammars.
FAQ
Run ast-grep scan -r rule.yml src/ to list matches. Use the -p pattern flag interactively and add constraints until matches are correct.
How do I avoid accidental rewrites?
Keep rewrite rules narrow with kind/has/inside, review matches manually, and run --update-all with a branch/CI check. Use severity and messages for staged rollout.
2 skills
This skill helps you craft precise AST-based search and rewrite rules with YAML for linting, refactors, and auto-fix.
This skill analyzes code quality per Clean Code principles, spotting naming, function size, duplication, over-engineering, and magic numbers with actionable