sql-generation

Generate PostgreSQL-compatible CTE SQL queries for product analytics questions.

70|34|Updated Apr 7, 2026
One-click install
npx skills add https://github.com/Productfculty-aipm/PM-Copilot-by-Product-Faculty --skill sql-generation-productfculty-aipm
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-generation
Source: https://github.com/Productfculty-aipm/PM-Copilot-by-Product-Faculty/tree/main/skills/sql-generation
Command: npx skills add https://github.com/Productfculty-aipm/PM-Copilot-by-Product-Faculty --skill sql-generation-productfculty-aipm

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill removes the friction of writing correct, production-ready SQL for product analytics by providing template queries, schema assumptions, and guidance so PMs and analysts can get reliable metrics without hand-crafting complex queries.

Core Features & Use Cases

  • Template Queries: Ready-made templates for retention cohorts, activation funnels, weekly active users, churn detection, and feature adoption.
  • Schema Guidance & Assumptions: Prompts to clarify or infer event-table names, key columns, and JSON property handling so queries match the user's warehouse schema.
  • Adaptation & Validation: Replaces placeholders with real event names, applies segment filters, adds explanatory comments, and suggests sanity checks for results.
  • Use Case: Convert a product analytics question like "what is 7-day retention for new users" into a validated, annotated SQL query tuned to your events schema.

Quick Start

Ask the skill to generate a 7-day retention SQL query for the event named app_opened using my events table and include assumptions and a simple validation check.

Frequently Asked Questions about sql-generation

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

FAQPage Schema
How do I generate SQL queries for retention cohorts and funnels from event-based analytics schemas?

You can generate ready-to-run PostgreSQL SQL queries for retention cohorts and funnels by providing natural language product analytics questions. The skill converts your questions into CTE-based templates with JSON property handling and placeholder substitution for your event-table schema.

Can I use this to write PostgreSQL queries for event tables exported from Segment or Amplitude?

Yes, the skill generates PostgreSQL-compatible SQL specifically for event-based analytics schemas exported from tools like Segment, Amplitude, or Mixpanel. It handles JSON properties and event-table structures typical of these platforms to produce valid queries.

How do I calculate weekly active users and churn detection using SQL without writing complex queries?

To calculate weekly active users and churn detection, you provide the metric and your event names. The skill generates annotated, CTE-based PostgreSQL queries with placeholder substitution and segment filtering, along with suggested validation checks for your results.

Does this SQL query generator include validation checks for the analytics metrics it produces?

Yes, the generated SQL includes simple validation checks for assumptions and suggests sanity checks for your results. This ensures the queries for metrics like activation funnels and feature adoption are reliable before you run them against your warehouse.

What is the best way to convert a product analytics question like 7-day retention into a valid SQL query?

The best way to convert a product analytics question into SQL is to specify the metric, event name, and table. The skill then applies schema guidance, replaces placeholders with real event names, adds explanatory comments, and outputs a validated PostgreSQL query.