postgresql-query-generation
БесплатноЗапускает вложенные скриптыНе проверенGenerate optimized PostgreSQL queries for Entity Framework Core projects. Automatically discovers domain entities, relationships, and conventions to produce…
от 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
- Discovers domain entities by scanning C# entity files
- Analyzes relationships (foreign keys, navigation properties)
- Detects project conventions (multi-tenancy, soft delete, audit fields)
- Generates optimized queries with proper JOINs and WHERE clauses
- Adapts to any domain (ABP, custom DDD, layered monoliths)
Capabilities
Automatic Discovery
- Scans
src/*/Domain/Entities/**/*.csfor entity classes - Inherits properties from base classes (FullAuditedAggregateRoot, SetupEntity, etc.)
- Detects foreign keys by
{EntityName}Idpattern - 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 = @tenantIdfilter - Soft delete: Adds
IsDeleted = falsefilter - 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 |
Установить postgresql-query-generation в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
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 запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
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