بنقرة واحدة
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 المهني
Navigate code with IDE features and run proactive LSP diagnostics on files/folders/batches. Use as PRIMARY for code intelligence and type/error checks.
Use when writing a new pi-lens ast-grep rule YAML file — covers schema, drop path, gotchas, and NAPI runner constraints
Use when writing a new pi-lens tree-sitter query rule YAML file — covers schema, S-expression syntax, capture names, predicates, and gotchas
Anthropic Claude Pro/Max OAuth compatibility workflow for this repo. Use when debugging Anthropic OAuth failures, misleading extra-usage errors, Pi request shaping, prompt fingerprinting, or deciding between hook-based fixes and deeper provider overrides.
Aggressive design-polish skill for making websites feel authored, editorial, image-led, and typographically intentional. Use when a page looks too generic, safe, same-font, SaaS-like, cluttered, or visually under-authored.
TypeScript conventions, code design principles (SOLID, self-documenting code, file organization), structural design heuristics (dependency width, LoD, output arguments), pnpm rules, ES2024 target, and Pi SDK patterns. Load during implementation, refactoring, or code review.
| 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 filespaths, then fall back to grepapply: false before apply: truefunction $NAME($$$) { $$$ } not function $NAME(selector unless expert — narrows to AST node kind; does not extract metavariablesfrom "$PATH" matches literal "$PATH", not a wildcard| Syntax | Matches | Named? |
|---|---|---|
$X | single node | yes — captures the node |
$$$ | zero or more nodes | no — unnamed wildcard |
$$$ARGS | zero or more nodes | yes — captures the list |
Use $$$ when you don't need the captured value; $$$NAME when you do.
| Pattern | Matches |
|---|---|
fetchMetrics($ARGS) | call with any single arg |
fetchMetrics($$$ARGS) | call with any number of args |
function $NAME($$$) { $$$ } | function declaration |
import { $NAMES } from $PATH | named import (no quotes on path) |
const $X = $Y | variable declaration |
Use these instead of writing raw YAML:
| Parameter | What it does |
|---|---|
insideKind | Only match inside an ancestor of this node kind |
hasKind | Only match nodes that contain a descendant of this kind |
follows | Only match nodes preceded by a sibling matching this pattern |
precedes | Only match nodes followed by a sibling matching this pattern |
# console.log only inside functions
ast_grep_search pattern="console.log($MSG)" lang="typescript" insideKind="function_declaration"
# replace var with let, scoped to functions only
ast_grep_replace pattern="var $X" rewrite="let $X" lang="javascript" insideKind="function_declaration"
These synthesize a YAML rule automatically. Use rule: for the full DSL when you need all/any/not, nthChild, regex, or other advanced constraints.
rule: parameter)Pass a complete ast-grep YAML rule to unlock the full DSL:
ast_grep_search rule="id: my-rule
language: TypeScript
rule:
pattern: console.log($MSG)
inside:
kind: function_declaration
stopBy: end" lang="typescript"
ast_dumpWhen a pattern returns zero matches and you don't know the correct node kind or field name, use ast_dump to inspect the AST:
ast_dump source="function foo() { return 1; }" lang="typescript"
Returns the full indented AST with node kinds and positions. Then use the correct kind in your pattern or insideKind.
# console.log inside a class method
pattern: console.log($$$)
inside:
kind: method_definition
stopBy: end
Use kind: directly when you want to match a node type without a pattern:
# any arrow function
kind: arrow_function
❌ $VAR inside quotes — matches literal "$VAR", not a metavar
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 }
❌ Unnamed $$$ when you need the value
foo($$$) → captures nothing; use foo($$$ARGS) to inspect matches
❌ Multiple top-level statements — triggers "Multiple AST nodes are detected"
Two shapes, two fixes:
1. Sequence inside a block — wrap in braces:
foo(); bar(); → { foo(); bar(); }
2. Cross-context (module-level + block-level together, e.g. an import AND a call) —
wrapping in {} makes the pattern invalid (imports can't live inside a block).
Use two searches: find files containing the import, then scope the call search
to those paths. Or use a YAML `inside:`/`has:` rule (see Composite section above).
No matches?
strictness: relaxed — ignores unnamed punctuation (trailing commas, semicolons) that smart mode requiresast_dump on a sample snippet to verify the correct node kindgrep or lsp_navigationMetavar captures appear automatically below each match line:
src/foo.ts:1:1: const x = foo(a, b)
$VAR=x $$$ARGS=a,b
Named captures ($X, $$$NAME) are shown; unnamed wildcards ($$$) are not.
Pagination — use skip: N when results are truncated (next-page hint appears in output).