Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

postgresql-query-generation

БесплатноЗапускает вложенные скриптыНе проверен

Generate optimized PostgreSQL queries for Entity Framework Core projects. Automatically discovers domain entities, relationships, and conventions to produce…

thapaliyabikendraот thapaliyabikendra★ 25 звёзд на GitHub

Об этом скилле

PostgreSQL Query Generation

Generate production-ready PostgreSQL queries for any .NET project using Entity Framework Core. This skill automatically discovers your domain structure and generates optimized SQL with proper relationships, multi-tenancy, soft delete filters, and ABP Framework conventions.

Quick Start

# Interactive mode (output to stdout)
python scripts/generate_query.py --interactive

# Generate query - automatically saves .sql file in current directory
python scripts/generate_query.py --query "get all applications with workflow stages"

# Generate query with custom output filename
python scripts/generate_query.py --query "get all applications" --output my_query.sql

# Only discover domain (output schema as JSON)
python scripts/generate_query.py --discover-only --output schema.json

What It Does

  1. Discovers domain entities by scanning C# entity files
  2. Analyzes relationships (foreign keys, navigation properties)
  3. Detects project conventions (multi-tenancy, soft delete, audit fields)
  4. Generates optimized queries with proper JOINs and WHERE clauses
  5. Adapts to any domain (ABP, custom DDD, layered monoliths)

Capabilities

Automatic Discovery

  • Scans src/*/Domain/Entities/**/*.cs for entity classes
  • Inherits properties from base classes (FullAuditedAggregateRoot, SetupEntity, etc.)
  • Detects foreign keys by {EntityName}Id pattern
  • Identifies navigation properties (ICollection, T)
  • Maps C# types to PostgreSQL types automatically

Query Patterns Supported

  • ✅ Multi-entity JOIN queries
  • ✅ Many-to-many relationships via join tables
  • ✅ Hierarchical/self-referencing (recursive CTE)
  • ✅ JSONB querying (@>, ?, jsonb_path_query)
  • ✅ Window functions (ROW_NUMBER, FIRST_VALUE, etc.)
  • ✅ Pagination with COUNT
  • ✅ Permission/security queries with complex joins
  • ✅ Aggregations and GROUP BY
  • ✅ Full-text search (ILIKE)
  • ✅ Bulk operations (INSERT/UPDATE with CASE)

Project-Specific Patterns

  • ABP Framework: Auto-detects TenantId, IsDeleted, CreationTime audit fields
  • Multi-tenancy: Always adds TenantId = @tenantId filter
  • Soft delete: Adds IsDeleted = false filter
  • JSONB fields: Optimized queries for InitialData, FormData, JsonSchema, etc.
  • Naming conventions: Uses quoted identifiers (e.g., "SystemName")

Example Output

Request: Get all ApplicationWorkflowInstances with workflow stage, operation, and substage

SELECT
  awi."Id",
  awi."TaskNumber",
  awi."WorkflowStageDate",
  app."Name" as "ApplicationName",
  stage."DisplayName" as "StageName",
  substage."DisplayName" as "SubStageName",
  owf."RequestNumber" as "OperationRequestNumber"
FROM "ApplicationWorkflowInstances" awi
JOIN "OperationWorkflowInstances" owf ON owf."Id" = awi."OperationWorkflowInstanceId"
  AND owf."TenantId" = awi."TenantId"
JOIN "WorkflowStages" stage ON stage."Id" = awi."StageId"
  AND stage."TenantId" = awi."TenantId"
LEFT JOIN "WorkflowSubStages" substage ON substage."Id" = awi."SubStageId"
JOIN "Applications" app ON app."Id" = awi."ApplicationWorkflowConfigurationId"
  AND app."TenantId" = awi."TenantId"
WHERE awi."TenantId" = @tenantId
  AND awi."IsDeleted" = false
  AND stage."IsActive" = true
ORDER BY awi."WorkflowStageDate" DESC
LIMIT @maxResultCount OFFSET @skipCount;

Output Files

Automatic File Generation

When using --query without specifying --output, the skill automatically creates a .sql file in the current working directory with:

  • Auto-generated filename based on the entity name or query keywords (e.g., application_workflow_instance_1678901234.sql)
  • Timestamp to ensure uniqueness
  • Complete, production-ready PostgreSQL queries
  • Proper parameterization (@paramName style)
  • TenantId and soft-delete filters automatically included
  • Optimized JOINs based on foreign keys
  • Comments explaining key patterns

Manual Output

Use --output to specify a custom filename:

python scripts/generate_query.py --query "get all users" --output users_query.sql

The file is saved in the current working directory by default, or you can provide a full path.

Configuration

No configuration needed! The skill adapts automatically. If your project uses:

  • Custom base classes: Automatically inherits their properties
  • Non-standard table names: Detected from [Table("...")] attributes if present
  • Different schemas: Detected from [Schema("...")] attributes
  • Composite keys: Handled as detected

Cross-Project Portability

Works with any EF Core project:

Project Type Detection Adaptation
ABP Framework FullAuditedAggregateRoot, IMultiTenant Auto-add TenantId, IsDeleted filters
Custom DDD AggregateRoot, Entity Respect aggregate boundaries, standard properties
Plain EF Core Entity Basic entity patterns
Multi-tenant TenantId property Always filter by @tenantId
S
Полный SKILL.md на GitHub

Установить postgresql-query-generation в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

assets/example-queries.sqlreferences/entity-discovery.mdreferences/query-examples.mdreferences/query-patterns.mdreferences/troubleshooting.mdreferences/type-mappings.mdscripts/generate_query.pyscripts/get_all_applications_with_1774248867.sql

FAQ

Что делает скилл postgresql-query-generation?

Generate optimized PostgreSQL queries for Entity Framework Core projects. Automatically discovers domain entities, relationships, and conventions to produce production-ready SQL. Use when: 1. You need complex PostgreSQL queries across multiple related entities 2. Working with ABP Framework and need multi-tenancy/soft delete patterns 3. Querying JSONB fields or need recursive CTEs 4. Building analytics/reporting queries with window functions 5. Optimizing existing queries with proper indexes and joins.

Как установить скилл postgresql-query-generation?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл postgresql-query-generation запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить postgresql-query-generation с