feature: improve postgres best practices and add evals #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces PostgreSQL version awareness and a comprehensive evaluation framework to the postgres-best-practices skill. The changes ensure AI agents only recommend rules compatible with the target PostgreSQL version and available extensions.
Changes
1. Rule Version & Extension Metadata
Added version constraints and extension requirements to rules that depend on specific PostgreSQL features:
query-covering-indexes.mdminVersion: "11"schema-partitioning.mdminVersion: "10"data-upsert.mdminVersion: "9.5"lock-skip-locked.mdminVersion: "9.5"advanced-jsonb-indexing.mdminVersion: "9.4"monitor-pg-stat-statements.mdextensions: pg_stat_statements2. Profile System
Introduced deployment profiles to customize rule filtering based on environment constraints:
Profiles Added:
supabase.json: Supabase platform (PG15+, rich extension support including pg_stat_statements, pgjwt, pg_graphql)aurora.json: AWS Aurora PostgreSQL (PG13-16, limited extensions, pg_cron/timescaledb unavailable)self-hosted.json: Generic self-hosted (PG12+, all extensions installable)Each profile specifies:
3. Build System Enhancements
profiles.tsmodule with version comparison and compatibility checkingisRuleCompatibleWithProfile()function filters rules based on version and extension requirementsAGENTS.supabase.md,AGENTS.aurora.md,AGENTS.self-hosted.md4. SKILL.md Documentation
Added runtime detection guidance for agents:
pg_available_extensionspg_settingsEvaluation Scenarios
A comprehensive eval framework was added to test agent behavior with version and extension constraints.
Framework
skills/postgres-best-practices/evals/npm run eval(requiresANTHROPIC_API_KEY)Scenarios by Category
Category 1: Core Query Patterns
missing-index-detectionn-plus-one-detectioncovering-index-suggestionCategory 2: Version Constraints
version-constraint-pg10-no-coveringversion-constraint-pg93-no-upsertCategory 3: Extension Requirements
extension-available-pg-stat-statementsextension-unavailable-no-pg-stat-statements