outlinedriven/odin-codex-plugin/ast-grep

Claude Code and agent skill by outlinedriven/odin-codex-plugin

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Code search, analysis, and refactoring using ast-grep (sg). Use for AST-based code modifications, structural search, and linting.

Install

npx vskill@latest install outlinedriven/odin-codex-plugin/ast-grep

SKILL.md

ast-grep (sg)

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.

When to use

  • Structural Search: Finding code based on structure (e.g., "all function calls to foo with 2 arguments") regardless of whitespace.
  • Refactoring: Renaming variables, changing function signatures, or transforming code patterns safely.
  • Linting: Creating custom rules to enforce code style or best practices.
  • Code Analysis: Extracting information from codebases.

Quick Start

CLI Basics
bash
# 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
Pattern Syntax
  • Meta-variables: $VAR matches any single node.
  • Multi-meta-variables: $$$ARGS matches zero or more nodes (list of items).
  • Wildcard: $_ matches any node (non-capturing).
  • Anonymous: $$ matches any list of nodes (non-capturing).

See Pattern Syntax for details.

Core Concepts

Understanding Named vs Unnamed nodes and Matching Strictness is crucial for precise patterns.

  • Named Nodes: identifier, function_definition (matched by $VAR).
  • Unnamed Nodes: (, ), ; (skipped by default in smart mode).
  • Strictness: Control matching precision (smart, cst, ast, relaxed, signature).

See Core Concepts for details.

Rule Configuration (YAML)

For complex tasks, use YAML configuration files.

yaml
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.

Advanced Rewriting

ast-grep supports complex transformations (regex replace, case conversion) and rewriters for sub-node transformation.

See Rewriting & Transformations for details.

Project Setup & Testing

For larger projects, organize rules and tests using sgconfig.yml.

  • Scaffold: ast-grep new project
  • Config: sgconfig.yml defines rule and test directories.
  • Testing: Define valid and invalid cases to ensure rule accuracy.

See Project Setup & Testing for details.

Utility Rules

Reuse logic with local or global utility rules. Enables recursive matching.

yaml
utils:
is-literal:
any: [{kind: string}, {kind: number}]
rule:
matches: is-literal

See Utility Rules for details.

Configuration Reference

Full reference for YAML fields (id, severity, files, ignores) and supported languages.

See Configuration Reference for details.

CLI Reference

Common commands: scan, run, new, test, lsp.

See CLI Reference for details.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
11
Repository forks
2
7-day trend score
12

Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 19 Apr 2026, 6 months ago.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/outlinedriven/odin-codex-plugin/ast-grep/badge)](https://verified-skill.com/skills/outlinedriven/odin-codex-plugin/ast-grep)

Something wrong with this skill or its page? Tell us.