qmetrics.net

ast-grep

Structural code search, lint, and rewrite CLI

ast-grep screenshot

ast-grep (sg) is a command-line tool for structural search, linting, and rewriting across many programming languages. It matches abstract syntax tree patterns instead of plain text.

Overview

ast-grep searches and replaces code using patterns written like ordinary source code. Wildcards such as $MATCH stand in for single AST nodes, similar in role to regex dots but syntax-aware. The engine is built on tree-sitter parsing and is implemented in Rust for parallel execution across large codebases.

Beyond one-off search and replace, ast-grep can scan projects as a linter with YAML-defined rules and readable error output. A Node.js binding exposes syntax trees with jQuery-style traversal for programmatic use, with optional type safety. The project also documents interactive codemods, a language server, and testing utilities.

Dozens of languages are supported out of the box, and custom tree-sitter parsers can be registered via dynamic loading. Install paths include npm, pip, cargo, Homebrew, Scoop, Mise, and MacPorts, with an online playground for trying patterns. Typical roles include library migration codemods, team style enforcement, and security rule authoring.

Key features

  • AST pattern search and replace
  • YAML lint rule configuration
  • Multi-language tree-sitter parsing
  • Parallel Rust execution
  • CLI scan and rewrite modes
  • Node.js programmatic API
  • Wildcard metavariable patterns
  • Custom parser registration

Use cases

  • Large-scale codemods
  • Custom lint rules
  • Breaking API migration assists
  • Security pattern matching
  • Interactive structural rewrites

Tags

Similar software

REA

MCP and CLI reverse-engineering toolkit for agents

REA connects coding agents and terminals to local analysis tools for binaries, Electron apps, websites, .NET, and Android targets. Setup registers MCP access and investigation skills via npm.

★ 480.8k⟳ todayMIT

Graphify

Codebase knowledge graph skill for AI coding assistants

Graphify maps a project’s code, docs, and media into a queryable local knowledge graph and installs as a skill for assistants such as Cursor and Claude Code.

★ 154.2k⟳ yesterdayApache-2.0

TypeScript

Typed JavaScript language with compile-time checks

TypeScript adds optional static types to JavaScript and compiles to standard JavaScript. It targets application-scale code on browsers, Node.js, and other JavaScript runtimes.

★ 111.9k⟳ yesterdayApache-2.0

Ghidra

NSA software reverse engineering and disassembly analysis suite

Ghidra is an NSA Research Directorate SRE framework with disassembly, decompilation, graphing, and scripting for analyzing compiled code on Windows, macOS, and Linux.

★ 101.5k⟳ yesterdayApache-2.0

Understand Anything

Interactive codebase knowledge graph for AI assistants

A multi-platform plugin that scans a project, builds a knowledge graph of structure and dependencies, and opens a searchable web dashboard. It supports domain views, guided tours, and diff impact analysis.

★ 94.7k⟳ 3 days agoMIT

Open Code Review

CLI agent for precise LLM-powered code review

Open Code Review reads Git diffs, applies deterministic review pipelines, and posts line-accurate comments via a tool-using LLM agent.

★ 56.9k⟳ 2 days agoApache-2.0
Open Source Alternative to:Greptile