Sql Generation logo

Sql Generation

Community
Productfculty-aipm
sql-generation

Use this skill when the user asks to "write a SQL query", "help me query this data", "how do I get this metric from the database", "generate SQL for", "query for retention", "SQL to find churned users", "write a query for my analytics", or needs SQL to answer a specific product analytics question. This skill generates standard SQL for product analytics use cases — it assumes a typical event-based analytics schema.

Overview

PublisherProductfculty-aipm
RepositoryPM-Copilot-by-Product-Faculty
Skill namesql-generation
Stars
80
Forks
34
Bundled files
Instructions only
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by Productfculty-aipm on GitHub. Read the source before you install it.

Installation

Install the Sql Generation AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/Productfculty-aipm/PM-Copilot-by-Product-Faculty/tree/main/skills/sql-generation
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Productfculty-aipm/PM-Copilot-by-Product-Faculty.git /tmp/PM-Copilot-by-Product-Faculty
mkdir -p .claude/skills
cp -r /tmp/PM-Copilot-by-Product-Faculty/skills/sql-generation .claude/skills/sql-generation
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Sql Generation in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Sql Generation on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Sql Generation is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

SQL Generation for Product Analytics

You are generating SQL queries for product analytics use cases. The queries are designed to work with standard event-based analytics schemas (similar to Segment, Amplitude, Mixpanel raw exports, or most data warehouse setups).

Step 1 — Load Context

Read memory/user-profile.md for analytics tool and any database or schema information the user has provided. Read context/company/analytics-baseline.md for metric definitions that should inform the query.

Step 2 — Clarify the Schema

Ask (or infer from context):

  • What is the main events table called? (e.g., events, tracking_events, user_events)
  • What are the key columns? (e.g., user_id, event_name, timestamp, properties)
  • Is the properties column a JSON field? (Common in event-based schemas)
  • Are there separate user-level or session-level tables?

If the user hasn't specified, use this standard schema and note the assumption:

sql
-- Assumed schema
-- events(user_id, event_name, timestamp, properties JSONB)
-- users(user_id, created_at, plan, segment)

Step 3 — Common Product Analytics Queries

Generate the appropriate query for the requested use case:

User Retention Cohort (N-day retention):

sql
-- D7 retention: % of users who performed an event 7 days after their first event
WITH first_events AS (
  SELECT user_id, MIN(DATE(timestamp)) AS cohort_date
  FROM events
  WHERE event_name = 'app_opened'  -- or signup event
  GROUP BY user_id
),
day_7_events AS (
  SELECT DISTINCT e.user_id
  FROM events e
  JOIN first_events f ON e.user_id = f.user_id
  WHERE DATE(e.timestamp) = f.cohort_date + INTERVAL '7 days'
    AND e.event_name = 'app_opened'  -- or core action
)
SELECT
  f.cohort_date,
  COUNT(DISTINCT f.user_id) AS cohort_size,
  COUNT(DISTINCT d.user_id) AS retained_users,
  ROUND(100.0 * COUNT(DISTINCT d.user_id) / COUNT(DISTINCT f.user_id), 1) AS d7_retention_pct
FROM first_events f
LEFT JOIN day_7_events d ON f.user_id = d.user_id
GROUP BY f.cohort_date
ORDER BY f.cohort_date;

Activation Funnel:

sql
-- Users completing each step of the activation flow
WITH users AS (SELECT DISTINCT user_id FROM events WHERE event_name = 'signed_up')
SELECT
  'Step 1: Signed Up' AS step, COUNT(DISTINCT user_id) AS users FROM users
UNION ALL
SELECT 'Step 2: Connected Tool', COUNT(DISTINCT e.user_id)
FROM events e JOIN users u ON e.user_id = u.user_id WHERE e.event_name = 'connected_tool'
UNION ALL
SELECT 'Step 3: Completed Core Action', COUNT(DISTINCT e.user_id)
FROM events e JOIN users u ON e.user_id = u.user_id WHERE e.event_name = 'core_action_completed';

Weekly Active Users (Core Action):

sql
SELECT
  DATE_TRUNC('week', timestamp) AS week,
  COUNT(DISTINCT user_id) AS weekly_active_users
FROM events
WHERE event_name = 'core_action_completed'
  AND timestamp >= CURRENT_DATE - INTERVAL '90 days'
GROUP BY 1
ORDER BY 1;

Churned Users (last 30 days):

sql
WITH last_seen AS (
  SELECT user_id, MAX(timestamp) AS last_active
  FROM events
  GROUP BY user_id
)
SELECT
  user_id,
  last_active,
  CURRENT_TIMESTAMP - last_active AS days_since_active
FROM last_seen
WHERE last_active < CURRENT_TIMESTAMP - INTERVAL '30 days'
ORDER BY last_active;

Feature Adoption Rate:

sql
SELECT
  DATE_TRUNC('week', e.timestamp) AS week,
  COUNT(DISTINCT e.user_id) AS feature_users,
  COUNT(DISTINCT all_users.user_id) AS total_active_users,
  ROUND(100.0 * COUNT(DISTINCT e.user_id) / COUNT(DISTINCT all_users.user_id), 1) AS adoption_pct
FROM events e
CROSS JOIN (
  SELECT DISTINCT user_id FROM events
  WHERE event_name = 'app_opened' AND timestamp >= CURRENT_DATE - INTERVAL '7 days'
) all_users
WHERE e.event_name = 'feature_x_used'
  AND e.timestamp >= CURRENT_DATE - INTERVAL '90 days'
GROUP BY 1
ORDER BY 1;

Step 4 — Adapt to the User's Request

Take the specific metric or question the user wants to answer and:

  1. Select or adapt the nearest template query
  2. Replace all placeholder values with the user's actual event names, table names, and timeframes
  3. Add appropriate WHERE clauses for segment filtering if requested
  4. Add comments explaining what each section does

Step 5 — Output

Provide:

  • The SQL query, fully adapted to the user's request
  • Brief explanation of how the query works (especially for complex CTEs)
  • Assumptions made (which these can be changed)
  • A validation check the user can run: "If this returns [sanity check result], the query is probably correct"

Frequently asked questions

What does the Sql Generation AI skill do?

Use this skill when the user asks to "write a SQL query", "help me query this data", "how do I get this metric from the database", "generate SQL for", "query for retention", "SQL to find churned users", "write a query for my analytics", or needs SQL to answer a specific product analytics question. This skill generates standard SQL for product analytics use cases — it assumes a typical event-based analytics schema.

Why use Sql Generation on TypingMind?

Because you install it once and use it with any model. Sql Generation is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Sql Generation in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Productfculty-aipm/PM-Copilot-by-Product-Faculty/tree/main/skills/sql-generation. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Sql Generation?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Sql Generation?

As many as you like. As long as a model supports skills, you can use Sql Generation with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Sql Generation AI skill free?

It is published on GitHub by Productfculty-aipm. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇