code-generation

Generate TypeScript AST code and PostgreSQL keyword lists from protobuf definitions.

232|33|Updated Jun 17, 2020
One-click install
npx skills add https://github.com/constructive-io/pgsql-parser --skill code-generation-constructive-io
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-generation
Source: https://github.com/constructive-io/pgsql-parser/tree/main/.agents/skills/code-generation
Command: npx skills add https://github.com/constructive-io/pgsql-parser --skill code-generation-constructive-io

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill eliminates the tedious and error-prone manual maintenance of generated TypeScript code, AST type definitions, and PostgreSQL keyword lists for the pgsql-parser monorepo, which must stay in sync with PostgreSQL version updates, new SQL fixtures, and source keyword changes.

Core Features & Use Cases

  • Protobuf-Based Code Generation: Automatically generate package-specific TypeScript AST helpers, runtime schemas, and traversal utilities from a single PostgreSQL protobuf definition for all core pgsql-parser packages.
  • Automated Type Inference: Generate narrowed TypeScript union types for AST nodes by analyzing actual usage patterns across the project's SQL test fixtures, replacing generic Node types with precise, type-safe alternatives.
  • Keyword and Deparser Generation: Extract typed PostgreSQL keyword sets from official PostgreSQL source headers and generate version-specific AST deparsers to support query deparsing for older PostgreSQL releases.
  • Use Case: When upgrading pgsql-parser to support a new PostgreSQL version, use this Skill to automatically regenerate all package artifacts, updated type definitions, and new keyword sets with a single set of documented commands.

Quick Start

Use the code-generation skill to automatically regenerate all TypeScript code, narrowed AST types, and PostgreSQL keyword lists after updating the protobuf fixture or adding new SQL test fixtures.

Frequently Asked Questions about code-generation

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

FAQPage Schema
How do I generate TypeScript AST types from PostgreSQL protobuf definitions?

You can generate TypeScript AST types from PostgreSQL protobuf definitions by automating code generation to create package-specific runtime schemas and traversal utilities across the pgsql-parser monorepo. This ensures generated artifacts align with source protobuf definitions without manual editing.

What is the best way to update AST type definitions when upgrading PostgreSQL versions?

The best way to update AST type definitions during a PostgreSQL version upgrade is to use automated type inference. This analyzes actual usage patterns across SQL test fixtures to generate narrowed TypeScript union types, replacing generic Node types with precise, type-safe alternatives.

How does automated type inference work for pgsql-parser AST nodes?

Automated type inference works by analyzing observed SQL usage patterns across project test fixtures. It generates narrowed TypeScript union types for AST nodes, ensuring type-safe alternatives that align with actual query structures instead of relying on generic Node types.

Can I automatically extract PostgreSQL keyword sets for version-specific AST deparsers?

Yes, you can extract typed PostgreSQL keyword sets directly from official PostgreSQL source headers. This process generates version-specific AST deparsers to support query deparsing for older PostgreSQL releases across all pgsql-parser packages.

Do I need to manually edit generated TypeScript code when adding new SQL test fixtures?

No, manual editing is not needed when adding new SQL fixtures. The code-generation process automatically regenerates all TypeScript code, narrowed AST types, and PostgreSQL keyword lists, ensuring artifacts stay synchronized with the new fixture data.

What are the limitations of using protobuf-based code generation for PostgreSQL AST parsing?

A limitation is that generated artifacts must strictly align with the source PostgreSQL protobuf definitions. If the protobuf schema or official PostgreSQL keyword classifications change, you must trigger a full regeneration to keep all pgsql-parser package artifacts synchronized.