structural-search

Search codebases by AST patterns using ast-grep and Bash.

29|6|Updated Nov 27, 2025
One-click install
npx skills add https://github.com/0xDarkMatter/claude-mods --skill structural-search
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: structural-search
Source: https://github.com/0xDarkMatter/claude-mods/tree/main/skills/structural-search
Command: npx skills add https://github.com/0xDarkMatter/claude-mods --skill structural-search

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires ast-grep.

What problem does it solve?

This Skill enables semantic code search using AST patterns instead of regex, finding exactly what you need without false positives.

Frequently Asked Questions about structural-search

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find code patterns by structure instead of text matching?

Structural search uses AST (Abstract Syntax Tree) patterns to identify code by its structure rather than regex. ast-grep enables this by parsing code into syntax trees, then matching patterns like function calls, imports, and class definitions across multi-language codebases without false positives from text-based searches.

Can I use ast-grep to locate all usages of a specific function across my codebase?

Yes. ast-grep identifies function calls by their structural definition in the AST, allowing you to find exact usages without regex noise. You define patterns using syntax tokens like $NAME and $_ to match function calls, then search across your entire codebase to locate all occurrences.

What's the best way to find code refactoring targets in a large codebase?

Structural search identifies refactoring targets by matching anti-patterns and code structures that need updating. ast-grep lets you define patterns for deprecated APIs, unsafe patterns, or style violations, then find all instances across multiple files and languages for systematic refactoring.

Does ast-grep work with multiple programming languages?

Yes. ast-grep parses code into language-agnostic AST structures, so a single pattern definition can match equivalent code structures across different languages. This enables you to search for similar patterns in polyglot codebases without writing language-specific regex.

How do I replace code patterns after finding them with structural search?

After identifying patterns with ast-grep's search functionality, you can apply replacements using the same pattern syntax. The Skill supports replace operations through Bash workflows, letting you update matched code structures and export results in JSON or YAML format for validation.

What are the limitations of structural search compared to regex-based grep?

Structural search requires ast-grep tooling and pattern syntax learning, but eliminates false positives that regex causes. The trade-off is setup complexity for precision: you gain exact semantic matching at the cost of regex's simplicity, making it best for large codebases where false positives are costly.