pg-data
БесплатноБез исполняемых скриптовНе проверенGenerate safe, read-only PostgreSQL queries from natural language. Use when users need to query blog_small, ecommerce_medium, or saas_crm_large databases…
Об этом скилле
PostgreSQL Data Query Generator
Generate safe, production-ready PostgreSQL SELECT queries from natural language descriptions. This skill analyzes user requests, matches them to the appropriate database schema, generates secure SQL, tests execution, and validates results.
When to Use This Skill
Use this skill when the user wants to:
- Query data from blog_small, ecommerce_medium, or saas_crm_large databases
- Analyze data with aggregations, joins, or complex filters
- Generate reports from the available databases
- Explore database content through natural language queries
Available Databases
| Database | Description | Use Cases |
|---|---|---|
| blog_small | Blog platform with users, posts, comments, categories, tags | Content analytics, author stats, engagement metrics |
| ecommerce_medium | E-commerce with products, orders, inventory, reviews | Sales analysis, inventory management, customer insights |
| saas_crm_large | Multi-tenant CRM with leads, deals, accounts, tickets | Pipeline analysis, sales performance, support metrics |
Security Requirements
CRITICAL: All generated SQL must comply with these security rules:
Allowed Operations
SELECTstatements only- Read-only aggregate functions (COUNT, SUM, AVG, MIN, MAX, etc.)
- JOINs, subqueries, CTEs, window functions
- WHERE, GROUP BY, HAVING, ORDER BY, LIMIT clauses
Prohibited Operations
- NO INSERT, UPDATE, DELETE, TRUNCATE, DROP, ALTER, CREATE
- NO EXECUTE, CALL, DO blocks
- NO pg_sleep, pg_terminate_backend, or any system functions
- NO COPY, \copy, or file operations
- NO SET, RESET, or configuration changes
- NO Comments containing sensitive data
- NO Dynamic SQL or string concatenation for queries
- NO Access to pg_catalog system tables (except for metadata queries)
- NO Sensitive data exposure (passwords, API keys, tokens, hashes)
SQL Injection Prevention
- Use parameterized queries when possible
- Validate and sanitize any user-provided values
- Never concatenate user input directly into SQL
- Escape special characters properly
Workflow
Step 1: Analyze User Request
Parse the user's natural language query to determine:
Target database: Which database(s) does this query relate to?
- Blog content, posts, comments, authors →
blog_small - Products, orders, sales, inventory, reviews →
ecommerce_medium - Leads, deals, accounts, contacts, tickets, subscriptions →
saas_crm_large
- Blog content, posts, comments, authors →
Query intent: What data does the user want?
- Listing/searching records
- Aggregation/statistics
- Relationships/joins
- Time-based analysis
Output format: Does the user want SQL only or results?
- If user says "give me the SQL" or "show me the query" → Return SQL only
- Otherwise → Execute and return results (default)
Step 2: Read Database Reference
Read the appropriate reference file(s) to understand the schema:
# Read the reference file for the target database
cat .claude/skills/pg-data/references/<database_name>.md
Reference files contain:
- Table structures with columns and types
- Foreign key relationships
- Available views
- Common query patterns
Step 3: Generate SQL
Generate a SQL query following these guidelines:
- Start with the primary table that best matches the user's intent
- Add JOINs only when necessary for the requested data
- Use appropriate indexes - check the reference for available indexes
- Include sensible defaults:
- Add
LIMIT 100for unbounded queries - Use meaningful column aliases
- Order results logically
- Add
SQL Template
-- Purpose: <brief description of what this query does>
SELECT
<columns with meaningful aliases>
FROM <primary_table> <alias>
[JOIN <related_table> ON <condition>]
[WHERE <filters>]
[GROUP BY <grouping>]
[HAVING <aggregate_filters>]
[ORDER BY <ordering>]
[LIMIT <reasonable_limit>];
Step 4: Validate SQL Safety
Before execution, verify the query:
Check for prohibited keywords:
INSERT, UPDATE, DELETE, DROP, ALTER, CREATE, TRUNCATE, EXECUTE, CALL, DO, COPY, SET, RESET, pg_sleep, pg_terminateVerify read-only nature: Query must only retrieve data
Check for sensitive data exposure: Exclude password_hash, api_key, token fields
Step 5: Execute and Test
Execute the SQL using psql:
PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d <database_name> -c "<SQL_QUERY>"
If execution fails:
- Analyze the error message
- Check for:
- Invalid column/table names
- Type mismatches
- Syntax errors
- Missing JOINs
- Regenerate the SQL with corrections
- Return to Step 5 (max 3 retries)
Step 6: Analyze Results and Score Confidence
Evaluate the query results and assign a confidence score (0-10):
| Score | Meaning | Action |
|---|---|---|
| 10 | Perfect match, expected resul |
Установить pg-data в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл pg-data?
Generate safe, read-only PostgreSQL queries from natural language. Use when users need to query blog_small, ecommerce_medium, or saas_crm_large databases. Supports query generation, execution, and result analysis with confidence scoring.
Как установить скилл pg-data?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл pg-data запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic