write-postgres-sql

Generate PostgreSQL SQL queries with schema validation and explicit JOINs.

1|Updated Mar 15, 2026
One-click install
npx skills add https://github.com/ly0o0o/lyoo-ai-productivity --skill write-postgres-sql
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: write-postgres-sql
Source: https://github.com/ly0o0o/lyoo-ai-productivity/tree/main/backend/write-postgres-sql
Command: npx skills add https://github.com/ly0o0o/lyoo-ai-productivity --skill write-postgres-sql

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Generates correct, efficient, and safe PostgreSQL SQL queries tailored to data analysis, reporting, migrations, and optimization tasks, freeing users from manual SQL construction and error-prone drafting.

Core Features & Use Cases

  • Stage 1 — understand_request: analyzes intent, schema, and filters to avoid mistakes.
  • Stage 2 — generate_sql: logical planning including table/field selection, join relationships, and needed aggregations.
  • Stage 3 — validate_sql: verifies syntax, avoids SELECT *, ensures WHERE clauses for large tables, and aligns with PostgreSQL conventions.
  • Schema-driven: fetches actual schema from Prisma migrations or ORM models if not provided.
  • Safety and guardrails: explicit JOINs, proper typing, and safeguards for write operations.

Quick Start

Describe your data schema and the query goal, and I will generate ready-to-run PostgreSQL SQL.

Frequently Asked Questions about write-postgres-sql

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

FAQPage Schema
How do I generate PostgreSQL queries for data analysis without writing SQL manually?

You can generate PostgreSQL queries by describing your data schema and query goal. The system analyzes intent, plans joins and aggregations, and outputs ready-to-run PostgreSQL SQL, freeing you from manual construction.

Can I use Prisma migrations to generate PostgreSQL queries automatically?

Yes, the system fetches actual schema from Prisma migrations or ORM models if not provided. It enforces real-table and field usage to ensure generated PostgreSQL queries align with your database structure.

What's the best way to optimize slow PostgreSQL queries for reporting?

To optimize slow PostgreSQL queries, the system validates syntax, avoids SELECT *, ensures WHERE clauses for large tables, and aligns with PostgreSQL conventions, generating efficient SQL for reporting tasks.

How does explicit JOIN generation improve PostgreSQL query safety?

Explicit JOIN generation improves PostgreSQL query safety by enforcing proper type matching and safe write operations with WHERE clauses, preventing accidental full-table scans and ensuring logical join relationships.

Does the generated PostgreSQL SQL work for data migrations?

Yes, the generated PostgreSQL SQL works for data migrations. The system applies safeguards for write operations, ensuring safe execution with proper WHERE clauses and explicit JOINs across your schema.

What happens if I don't provide a schema for PostgreSQL query generation?

If schema is not provided, the system fetches actual schema from Prisma migrations or ORM models. This ensures generated PostgreSQL SQL uses real tables and fields, avoiding errors from incorrect assumptions.