- name
SKILL.md
स्किल फ़ाइल पब्लिशर की रिपॉज़िटरी में ही रहती है।
कॉपी की गई कमांड टर्मिनल में पेस्ट करें। यह इस SKILL.md को उस एजेंट में इंस्टॉल करती है।
npx skills add omagents/omagents --skill ast-grep -a cursor -yकॉपी की गई कमांड टर्मिनल में पेस्ट करें। यह इस SKILL.md को उस एजेंट में इंस्टॉल करती है।
npx skills add omagents/omagents --skill ast-grep -a claude-code -yकॉपी की गई कमांड टर्मिनल में पेस्ट करें। यह इस SKILL.md को उस एजेंट में इंस्टॉल करती है।
npx skills add omagents/omagents --skill ast-grep -a codex -yकॉपी की गई कमांड टर्मिनल में पेस्ट करें। यह इस SKILL.md को उस एजेंट में इंस्टॉल करती है।
npx skills add omagents/omagents --skill ast-grep -a grok -yकॉपी किया गया संदेश Grok Bot चैट में भेजें। Bot यह SKILL.md GitHub से लाता है और उसे उन स्किल में जोड़ देता है जो आपके सभी Bot साझा करते हैं।
Install this skill: https://github.com/omagents/omagents/tree/HEAD/packages/core/skills/ast-grepपब्लिशर से
Pattern-aware code search using the ast-grep (sg) binary. Matches code by its syntactic structure, not just text.
Check if ast-grep is installed:
sg --version 2>/dev/null || npx ast-grep --version 2>/dev/null
If not installed, fall back to grep with careful regex patterns.
# Find all console.log calls
sg -p 'console.log($$$)' --lang javascript
# Find all function definitions with a specific name pattern
sg -p 'def $NAME($$$):' --lang python
# Find all if statements with a single return
sg -p 'if ($COND) { return $VAL }' --lang typescript
# Preview first (ALWAYS dry-run before applying)
sg -p 'console.log($$$)' -r 'logger.info($$$)' --lang javascript
# Apply (only after verifying preview)
sg -p 'console.log($$$)' -r 'logger.info($$$)' --lang javascript --update-all
# Check if pattern is valid before searching
sg -p 'pattern' --lang python --json=compact 2>&1 | head -5
Examples:
# Python: find all decorators
@$DECORATOR
def $FUNC($$$):
$$$
# TypeScript: find all arrow functions assigned to const
const $NAME = ($$$) => $BODY
# Rust: find all match arms with panic
$PAT => panic!($$$)
ast-grep auto-detects language from file extension. Override with --lang:
sg -p 'pattern' --lang python
sg -p 'pattern' --lang typescript
sg -p 'pattern' --lang rust
sg -p 'pattern' --lang go
Supported: python, javascript, typescript, rust, go, java, c, cpp, csharp, ruby, php, swift, kotlin, scala, html, css, json, yaml, and more.
For project-wide refactoring, use the loop engine to process files one by one:
# Phase 1: Find all matching files
sg -p 'console.log($$$)' --lang javascript --json=compact | jq '.[].path' | sort -u
# Phase 2: Build task queue
loop_engine.py init ast-grep-refactor '[
{"file": "src/index.js", "description": "Replace console.log with logger.info"},
{"file": "src/utils.js", "description": "Replace console.log with logger.info"}
]'
# Phase 3: Loop - for each file:
# 1. Get next task: loop_engine.py next ast-grep-refactor
# 2. Preview: sg -p 'console.log($$$)' -r 'logger.info($$$)' --lang javascript <file>
# 3. Apply: sg -p 'console.log($$$)' -r 'logger.info($$$)' --lang javascript --update-all <file>
# 4. Verify: run tests/linter
# 5. Complete: loop_engine.py complete ast-grep-refactor <id> "Replaced 3 calls"
If ast-grep is not installed, use grep with careful patterns:
# Instead of sg -p 'console.log($$$)' --lang javascript
grep -rn "console\.log(" --include="*.js" --include="*.ts"
# Instead of sg -p 'def $NAME($$$):' --lang python
grep -rn "def .*(" --include="*.py"
Note: grep matches text, not structure. It will match in strings, comments, and produce false positives.
AST-aware code search and rewrite across 25+ languages using the ast-grep (sg) CLI. Trigger when the agent needs structural code matching, pattern-based search, or pattern-based rewriting. Falls back
---name: ast-grepdescription: AST-aware code search and rewrite across 25+ languages using the ast-grep (sg) CLI. Trigger when the agent…---# packages/core/skills/ast-grep/SKILL.mdओवरव्यू
AST-aware code search and rewrite across 25+ languages using the ast-grep (sg) CLI. Trigger when the agent needs structural code matching, pattern-based search, or pattern-based rewriting. Falls back to grep if ast-grep is not installed.
FAQ
पब्लिशर से packages/core/skills/ast-grep/SKILL.md डाउनलोड करें, या पाथ कॉपी करके रिपॉज़िटरी खोलें। PlugMCP स्किल को सूचीबद्ध करता है, फ़ाइल होस्ट नहीं करता।
पब्लिशर इसे https://github.com/omagents/omagents पर रखता है।
Claude, Cursor, Codex और Grok Build वह SKILL.md पढ़ सकते हैं जिसे आप पब्लिशर की रिपॉज़िटरी से जोड़ते हैं। जब आप चैट में स्किल के GitHub फ़ोल्डर का लिंक भेजते हैं, तो Grok Bot उसे इंस्टॉल कर देता है।