ast-grep
Use when searching or replacing code patterns - use ast-grep instead of text search for semantic accuracy
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when searching or replacing code patterns - use ast-grep instead of text search for semantic accuracy
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | ast-grep |
| description | Use when searching or replacing code patterns - use ast-grep instead of text search for semantic accuracy |
Use ast_grep_search and ast_grep_replace for semantic code search/replace. ast-grep understands code structure, not just text.
fetchMetrics($ARGS) not fetchMetricspaths to relevant filesapply: false before apply: truefunction $NAME($$$) { $$$ } not function $NAME(from "$PATH" will NOT match; use grep for import path patterns| Pattern | Matches |
|---|---|
fetchMetrics($ARGS) | Function call with any args |
function $NAME($$$) { $$$ } | Function declaration |
import { $NAMES } from $PATH | Import (any path — no quotes) |
const $X = $Y | Variable declaration |
# console.log inside class methods
pattern: console.log($$$)
inside:
kind: method_definition
stopBy: end
| Use | Example | Matches |
|---|---|---|
| Single | console.log($MSG) | console.log("hi") |
| Multiple | console.log($$$ARGS) | console.log("hi", obj, 42) |
❌ $VAR inside quotes — not a metavariable, matches literal text "$PATH"
from "$PATH" → use grep for wildcard path matching
from "./utils" → ✅ exact string literal works fine
❌ Trailing comma in objects
{ type: $T, } → use { type: $T }
❌ Shorthand property mismatch
{ runnerId: $RID } → won't match { runnerId }
use { runnerId } or { runnerId, $$$REST }
No matches? Simplify and retry: console.log($$$) → console → narrow down.
Fails twice? Fall back to grep.
Add a new Pi package to this pi-packages monorepo. Use when importing, vendoring, forking, or creating a package under packages/* and wiring it into this repo's workspace, Pi manifest, README, validation, and upstream-credit conventions.
Update a vendored or forked Pi package in this pi-packages monorepo from its upstream source using git subtree workflows. Use when refreshing packages/* from upstream repositories while preserving this repo's package, README, Pi manifest, and adaptation conventions.
Navigate code with IDE features - definitions, references, types, call hierarchy. Use as PRIMARY for code intelligence.