structural-search

structural-search is a skill for Claude Code from 0xDarkMatter/claude-mods. It costs 63 tokens per session (907 once invoked), scanned A, original, MIT.

A code-search tool that looks at how code is structured, using its abstract syntax tree (AST), rather than matching text alone.

In plain words
What is it for?
Finding function calls, imports, class definitions, framework patterns, and possible issues such as unsafe eval or direct innerHTML assignments.
Why use it?
It finds code patterns even when formatting or variable names differ, making broad searches and refactors more reliable than regular expressions.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the claude-mods plugin — 112 skills, 3 commands, 3 agents, 4 hooks shipped together

Good fit Finding function calls, imports, class definitions, framework patterns, and possible issues such as unsafe eval or direct innerHTML assignments.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/0xdarkmatter/claude-mods/structural-search
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add 0xDarkMatter/claude-mods --skill structural-search
Clone the repo
git clone --depth 1 https://github.com/0xDarkMatter/claude-mods

Made for: Claude Code.

Or install claude-mods, the plugin that ships this one along with the rest of its 112 skills, 3 commands, 3 agents, 4 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for structural-search

README.md
[![agentmods](https://agentmods.dev/badge/skills/0xdarkmatter/claude-mods/structural-search/github.svg)](https://agentmods.dev/skills/0xdarkmatter/claude-mods/structural-search)
Your own site
<a href="https://agentmods.dev/skills/0xdarkmatter/claude-mods/structural-search"><img src="https://agentmods.dev/badge/skills/0xdarkmatter/claude-mods/structural-search/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for structural-search

Your own site · 80×15
<a href="https://agentmods.dev/skills/0xdarkmatter/claude-mods/structural-search"><img src="https://agentmods.dev/badge/skills/0xdarkmatter/claude-mods/structural-search.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 63 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 907 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00063 $0.00907
Opus 5.5 $0.00025 $0.00363
Sonnet 5.5 $0.00013 $0.00181
Haiku 4.5 $0.00006 $0.00091

Measured 1mo ago against content hash d38682316d95, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

structural-search scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/structural-search/SKILL.md · 102 lines

How it starts

The opening of the file, as written. The whole thing — 102 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Search code by its abstract syntax tree (AST) structure. Finds semantic patterns that regex cannot match reliably.

Tools

Tool Command Use For
ast-grep sg -p 'pattern' AST-aware code search

Pattern Syntax

Pattern Matches Example
$NAME Named identifier function $NAME() {}
$_ Any single node console.log($_)
$$$ Zero or more nodes function $_($$$) {}

Top 10 Essential Patterns

# 1. Find console.log calls
sg -p 'console.log($_)'

# 2. Find React hooks
sg -p 'const [$_, $_] = useState($_)'
sg -p 'useEffect($_, [$$$])'

# 3. Find function definitions
sg -p 'function $NAME($$$) { $$$ }'
sg -p 'def $NAME($$$): $$$' --lang python

# 4. Find imports
sg -p 'import $_ from "$_"'
sg -p 'from $_ import $_' --lang python

# 5. Find async patterns
sg -p 'await $_'
sg -p 'async function $NAME($$$) { $$$ }'

# 6. Find error handling
sg -p 'try { $$$ } catch ($_) { $$$ }'
sg -p 'if err != nil { $$$ }' --lang go

# 7. Find potential issues
sg -p '$_ == $_'           # == instead of ===
sg -p 'eval($_)'           # Security risk
sg -p '$_.innerHTML = $_'  # XSS vector

# 8. Preview refactoring
sg -p 'console.log($_)' -r 'logger.info($_)'

# 9. Apply refactoring
sg -p 'var $NAME = $_' -r 'const $NAME = $_' --rewrite

# 10. Search specific language
sg -p 'pattern' --lang typescript

Quick Reference

Task Command
Find pattern sg -p 'pattern'
Specific language sg -p 'pattern' --lang python
Replace (preview) sg -p 'old' -r 'new'
Replace (apply) sg -p 'old' -r 'new' --rewrite
Show context sg -p 'pattern' -A 3
JSON output sg -p 'pattern' --json
File list only sg -p 'pattern' -l
Count matches sg -p 'pattern' --count
Run YAML rules sg scan

When to Use

  • Finding all usages of a function/method
  • Locating specific code patterns (hooks, API calls)
  • Preparing for large-scale refactoring
  • When regex would match false positives
  • Detecting anti-patterns and security issues
  • Creating custom linting rules

Read the full file on GitHub · 102 lines

Files

What ships with it

7 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 102 lines · 63 tokens per session scan A d38682316d95

Subscribe to this mod's changes

structural-search is a skill published in the GitHub repository 0xDarkMatter/claude-mods (62 stars, last pushed 7d ago), licensed MIT. It adds 63 tokens to every session and 907 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories