constructive-ioconstructive-ioOfficialยท2 Agent Skills Included

pgsql-parser

PostgreSQL SQL parsing, deparsing, and AST traversal

Parses PostgreSQL SQL and PL/pgSQL into typed syntax trees and converts them back into clean SQL. Walks, rewrites, and validates queries programmatically without brittle string manipulation or regex hacks. Includes linting, fixture testing, and code generation workflows to keep database tooling reliable across PostgreSQL versions.
npx skills add constructive-io/pgsql-parser --all -g -y
Available:

Directs the agent to the right sub-skill for AST traversal, fixture testing, code generation, or SQL linting, and defines the build and test commands for each package in the monorepo.

All Skills in This Repository (2)

Pure Emerald Level Indicators

Frequently Asked Questions

FAQPage Schema
How to install pgsql-parser?โ–ผ

Run `npx skills add constructive-io/pgsql-parser --all -g -y` in your terminal to install all skills in this suite globally.

How to parse PostgreSQL SQL into an AST?โ–ผ

Use the parse function from pgsql-parser, which runs the real PostgreSQL parser via WebAssembly and returns a fully typed syntax tree. You can then modify the tree and deparse it back into valid SQL.

How to walk or rewrite a SQL syntax tree?โ–ผ

Use the walk function from @pgsql/traverse with visitor callbacks keyed by node type, or walkSql from plpgsql-parser when starting from raw SQL text. Field-level edits like renaming schemas work directly on the visited nodes.

Can it lint SQL and PL/pgSQL code?โ–ผ

Yes. The pgsql-lint skill checks source files for issues like unqualified table references, dynamic SQL, and search_path dependencies, with configurable severity and inline suppressions.

Does pgsql-parser support multiple PostgreSQL versions?โ–ผ

Yes. It handles AST transformation across PostgreSQL versions 13 through 17, so you can parse and deparse queries written for older database versions.

Related Repositories in Software Engineering

View All in Software Engineeringโ†’