ast-query

查询TypeScript代码库结构。用于询问“X包含什么?”、“X在哪里定义?”、“谁调用了X?”或探索类型/接口/函数定义。通过解析实际代码回答结构性问题。

📖 中文导读:查询TypeScript代码库结构。用于询问“X包含什么?”、“X在哪里定义?”、“谁调用了X?”或探索类型/接口/函数定义。通过解析实际代码回答结构性问题。 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。

name: ast-query description: Query TypeScript codebase structure. Use when asking "what does X contain?", "where is X defined?", "what calls X?", or exploring type/interface/function definitions. Answers structural questions by parsing actual code.

AST Query

Query TypeScript code structure without reading files manually.

Usage

# What fields does an interface have?
node crop-api/scripts/ast-query.js "Plan"

# Find a function signature
node crop-api/scripts/ast-query.js "validatePlan"

# Find all matching definitions
node crop-api/scripts/ast-query.js "Bed"

# Find what calls a function
node crop-api/scripts/ast-query.js "validatePlan" --callers

Output

Compact, greppable format:

interface: Plan (src/lib/entities/plan.ts:45)
  id: string
  schemaVersion: number
  metadata: PlanMetadata
  beds: Record<string, Bed>
  cropCatalog: Record<string, CropConfig>
  plantings: Planting[]

When to Use

  • Understanding type structure before modifying code
  • Finding where something is defined
  • Checking function signatures
  • Discovering related types (query "Bed" finds Bed, BedSpanInfo, getBedLength, etc.)