Help us improve
Share bugs, ideas, or general feedback.
From odin
Performs AST-based code search, analysis, and refactoring using ast-grep (sg). Useful for structural search and replace, custom linting, and safe code transformations.
npx claudepluginhub outlinedriven/odin-claude-plugin --plugin odinHow this skill is triggered — by the user, by Claude, or both
Slash command
/odin:ast-grepThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
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.
Provides ast-grep CLI syntax, metavariable patterns, and examples for structural code search and rewriting in JavaScript/TypeScript, Python, Go, Rust.
Guides writing ast-grep rules for AST-based structural code search to find patterns like unhandled async functions or specific constructs beyond text matching.
Finds and replaces code patterns structurally using ast-grep by matching AST structure, for functions with specific signatures, API refactors across files, and regex-resistant anti-patterns.
Share bugs, ideas, or general feedback.
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.