ast-query
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.
When & Why to Use This Skill
The ast-query Claude skill is a specialized TypeScript codebase analysis tool designed to streamline code exploration and architectural mapping. By parsing the Abstract Syntax Tree (AST), it allows developers to instantly locate definitions, inspect function signatures, and trace type relationships without manual file searching. This tool is essential for maintaining high productivity in complex TypeScript environments, providing precise structural insights that traditional text search might miss.
Use Cases
- Codebase Onboarding: Rapidly navigate and understand the structure of unfamiliar TypeScript projects by querying key interfaces and core functions.
- Refactoring & Impact Analysis: Identify all callers of a specific function or method to assess the potential impact of structural changes or breaking updates.
- Type Hierarchy Exploration: Discover related types and interface definitions (e.g., finding 'BedSpanInfo' when searching for 'Bed') to ensure type-safe implementations.
- API Signature Verification: Instantly retrieve exact function signatures and parameter requirements to facilitate accurate code integration and debugging.
| 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.)