Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计异常

code-structural-search代码结构搜索

Agent Skill

code-structural-search 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

1,640

周安装

67

GitHub Stars

25

下载量

525
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:code-structural-search(代码结构搜索)
来源仓库:https://github.com/oimiragieo/agent-studio
仓库路径:skills/code-structural-search
安装命令:
npx skills add https://github.com/oimiragieo/agent-studio --skill code-structural-search
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/oimiragieo/agent-studio --skill code-structural-search

简介

用于基于 AST 的结构化代码模式匹配。

  • 支持 20+ 语言如 JavaScript、TypeScript、Python、Go 等。
  • 适用于精确查找函数参数数、类继承关系等结构特征。
  • 推荐用于重构与接口变更影响分析。code-structural-search 属于研究检索类 Skill,可作为该场景下的辅助能力补充。
  • 需确保 Node.js v18+ 已安装以运行 ast-grep。

SKILL.md

Code Structural Search

Use ast-grep for AST-based code pattern matching.

When to Use

  • Find code by structure, not keywords
  • "Find all functions with 3 arguments"
  • "Find all classes that extend X"
  • "Find all database queries"
  • "Find all error handling patterns"
  • Precise code refactoring (change exact patterns)

Interface

Skill({ skill: 'code-structural-search', args: 'pattern-here --lang ts' });

Language Support

ast-grep supports 20+ languages via tree-sitter:

LanguageFlagFile Extensions
JavaScript--lang js.js,.jsx
TypeScript--lang ts.ts,.tsx
Python--lang py.py,.pyi
Go--lang go.go
Rust--lang rs.rs
Java--lang java.java
C--lang c.c,.h
C++--lang cpp.cpp,.cc,.hpp,.hh
C#--lang cs.cs
Kotlin--lang kt.kt,.kts
Swift--lang swift.swift
PHP--lang php.php
Ruby--lang rb.rb
Lua--lang lua.lua
Elixir--lang ex.ex,.exs
HTML--lang html.html,.htm
CSS--lang css.css
JSON--lang json.json
Bash--lang bash.sh,.bash
Thrift--lang thrift.thrift

Pattern Examples

JavaScript/TypeScript

Find all functions:

function $NAME($ARGS) { $$ }

Find functions with exactly 2 arguments:

function $NAME($A, $B) { $$ }

Find async functions:

async function $NAME($ARGS) { $$ }

Find class methods:

class $NAME {
  $METHOD($ARGS) { $$ }
}

Find arrow functions:

const $NAME = ($ARGS) => { $$ }

Find console.log statements:

console.log($$$)

Find try-catch blocks:

try { $$ } catch ($ERR) { $$ }

Python

Find all functions:

def $NAME($ARGS): $$$

Find class definitions:

class $NAME: $$$

Find async functions:

async def $NAME($ARGS): $$$

Find imports:

import $MODULE

Find from imports:

from $MODULE import $$$

Go

Find all functions:

func $NAME($ARGS) $RETURN { $$ }

Find struct definitions:

type $NAME struct { $$$ }

Find interface definitions:

type $NAME interface { $$$ }

Rust

Find all functions:

fn $NAME($ARGS) -> $RETURN { $$ }

Find impl blocks:

impl $NAME { $$$ }

Find pub functions:

pub fn $NAME($ARGS) -> $RETURN { $$ }

Java

Find all methods:

public $RETURN $NAME($ARGS) { $$ }

Find class definitions:

public class $NAME { $$$ }

Find interface definitions:

public interface $NAME { $$$ }

Pattern Syntax

SymbolMeaningExample
$NAMESingle node/identifierfunction $NAME() {}
$$$Zero or more statements/nodesclass $NAME {$$$}
$$Zero or more statements (block)if ($COND) {$$}
$_Anonymous wildcard (discard)console.log($_)

Performance

  • Speed: <50ms per search (typical)
  • Best combined with semantic search (Phase 1)
  • Use ripgrep first for initial file discovery

vs Other Tools

vs Ripgrep (grep):

  • Ripgrep: Fast text search, finds keywords
  • ast-grep: Structural search, finds exact code patterns
  • Use ripgrep first → then ast-grep to refine

vs Semantic Search (Phase 1):

  • Semantic: Understands code meaning
  • ast-grep: Understands code structure
  • Combined: Best results (Phase 2)

Usage Workflow

  1. Broad search with ripgrep: Skill({skill: 'ripgrep', args: 'authenticate --type ts'})
  2. Structural refinement with ast-grep: Skill({skill: 'code-structural-search', args: 'function authenticate($$$) {$$} --lang ts'})
  3. Semantic understanding with Phase 1: Skill({skill: 'code-semantic-search', args: 'authentication logic'})

Common Use Cases

Security Patterns

Find unvalidated inputs:

router.post($PATH, ($REQ, $RES) => { $$ })

Find SQL queries (potential injection):

db.query(`SELECT * FROM ${$VAR}`)

Find eval usage:

eval($$$)

Code Quality Patterns

Find deeply nested functions:

function $NAME($ARGS) {
  if ($COND) {
    if ($COND2) {
      if ($COND3) { $$ }
    }
  }
}

Find long parameter lists (>5 params):

function $NAME($A, $B, $C, $D, $E, $F, $$$) { $$ }

Find unused variables:

const $NAME = $VALUE;

Refactoring Patterns

Find old API usage:

oldAPI.deprecatedMethod($$$)

Find callback patterns (convert to async/await):

$FUNC($ARGS, ($ERR, $DATA) => { $$ })

Find React class components (convert to hooks):

class $NAME extends React.Component { $$$ }

Iron Laws

  1. ALWAYS specify the language with --lang flag — without a language flag, ast-grep applies heuristics that produce false positives; specify --lang ts, --lang py, etc. for accurate AST parsing.
  2. ALWAYS use ripgrep/keyword search first to narrow the target set — structural search over the whole codebase is slow; use ripgrep to find candidate files first, then apply ast-grep for precise matching.
  3. NEVER use regex for structural code patterns — regex breaks on formatting differences, nested structures, and multi-line code; AST patterns are format-independent and semantically precise.
  4. ALWAYS test patterns on a known match before running project-wide — patterns with incorrect syntax silently match nothing; verify the pattern finds at least one known example before broad application.
  5. **ALWAYS use $$$ for variable argument lists, not * or .** — ast-grep uses metavariable syntax ($NAME, $$$, $$); regex or glob syntax in patterns produces silent failures.

Anti-Patterns

Anti-PatternWhy It FailsCorrect Approach
No --lang flagWrong parser applied; produces false positives and missesAlways specify --lang ts, --lang py, etc.
Running project-wide without ripgrep pre-filterSlow on large codebases; many irrelevant resultsUse ripgrep to identify candidate files first
Regex for structural matchingBreaks on multi-line, whitespace variations, nestingUse ast-grep AST patterns ($NAME, $$$, etc.)
Untested pattern on full codebaseIncorrect patterns silently return nothingTest on one known match first
Using * or . for wildcardsNot valid ast-grep syntax; ignored or errorsUse $NAME for single node, $$$ for sequences

Memory Protocol (MANDATORY)

Before starting: Read .claude/context/memory/learnings.md

After completing:

  • New pattern → .claude/context/memory/learnings.md
  • Issue found → .claude/context/memory/issues.md
  • Decision made → .claude/context/memory/decisions.md
ASSUME INTERRUPTION: If it's not in memory, it didn't happen.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

38.42%
按下载量换算202

Claude

29.25%
按下载量换算154

Cursor

18.83%
按下载量换算99

Gemini CLI

11.2%
按下载量换算59

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

未通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills