원클릭으로
ast-grep
Code search, analysis, and refactoring using ast-grep (sg). Use for AST-based code modifications, structural search, and linting.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Code search, analysis, and refactoring using ast-grep (sg). Use for AST-based code modifications, structural search, and linting.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Verbalized Sampling (VS) protocol for intent exploration before planning, mode-aware. Default `exhaustive` runs full VS; `collaborative` runs tip-sharing dialogue; `adversarial` walks the design tree one fork at a time. Auto-detects from phrasing ("help me refine" → collaborative, "poke holes" → adversarial); override via `/askme adversarial|collaborative|exhaustive`. Use for ambiguous tasks or maximum clarifying questions before committing.
Tidy-operations dispatcher. Invoke on "tidy", "clean up", "tidy this file/memory/workspace/git/docs", or when active context (current file, diff, stack, memory directory) has structural rot to resolve before touching behavior. Detects target domain from context and routes to the sibling skill. Requires explicit target or clear active-context signal — do not invoke speculatively.
Read-only codebase exploration: discovery, structural reading, and emission of architecture/pattern/tooling/dependency summaries. Use to understand existing code, map files, trace function flow, locate symbols, or build pre-implementation context. Uses 1/3/5 Explore-agent escalation scaled to scope. Trigger on "explore", "find where X is", "how does X work in the code", "map the codebase", "what files handle Y", or any architecture/pattern/tooling/dependency context request on a local repo — even without naming /explore.
Surface deepening refactors that turn shallow modules into deep ones, informed by `CONTEXT.md` and `docs/adr/`. Use when the user asks to improve architecture, find refactor candidates, raise testability, or make a codebase more agent-navigable. Skip for single localized fixes.
Surface in-task-collaboration protocols when the user describes an AI workflow informally — URL-as-entity-reference, PR-comment threads as session memory. Trigger when the user names entities by colloquial label instead of stable URL, asks "how should I structure this for Claude", or describes a multi-step Claude workflow without a durable handle. Apply reactively, not as a checklist.
Verbosity-reduction response register. Drops redundant clauses, narrative hedging, and ceremony while preserving articles, grammar, and decision-oriented register. Trigger on "caveman", "compact mode", "less tokens", "be brief", or context-window pressure in long sessions.
| name | ast-grep |
| description | Code search, analysis, and refactoring using ast-grep (sg). Use for AST-based code modifications, structural search, and linting. |
ast-grep is a fast and polyglot tool for code searching, linting, and rewriting based on Abstract Syntax Trees (AST). It excels at structural search and replace where regex fails.
foo with 2 arguments") regardless of whitespace.# Search (pattern must be in single quotes)
ast-grep -p '$A + $B' --lang ts
# Rewrite (dry run)
ast-grep -p '$A != null' --rewrite '$A' --lang ts
# Interactive Rewrite
ast-grep -p 'var $A = $B' --rewrite 'const $A = $B' --interactive
$VAR matches any single node.$$$ARGS matches zero or more nodes (list of items).$_ matches any node (non-capturing).$$ matches any list of nodes (non-capturing).See Pattern Syntax for details.
Understanding Named vs Unnamed nodes and Matching Strictness is crucial for precise patterns.
identifier, function_definition (matched by $VAR).(, ), ; (skipped by default in smart mode).smart, cst, ast, relaxed, signature).See Core Concepts for details.
For complex tasks, use YAML configuration files.
id: no-console-log
language: TypeScript
rule:
pattern: console.log($$$ARGS)
inside:
kind: function_declaration
stopBy: end
fix: '' # Remove the log
See Rule Configuration for details.
ast-grep supports complex transformations (regex replace, case conversion) and rewriters for sub-node transformation.
See Rewriting & Transformations for details.
For larger projects, organize rules and tests using sgconfig.yml.
ast-grep new projectsgconfig.yml defines rule and test directories.valid and invalid cases to ensure rule accuracy.See Project Setup & Testing for details.
Reuse logic with local or global utility rules. Enables recursive matching.
utils:
is-literal:
any: [{kind: string}, {kind: number}]
rule:
matches: is-literal
See Utility Rules for details.
Full reference for YAML fields (id, severity, files, ignores) and supported languages.
See Configuration Reference for details.
Common commands: scan, run, new, test, lsp.
See CLI Reference for details.