diff --git a/AGENTS.md b/AGENTS.md index a15b55d..5b2a7be 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -5,15 +5,9 @@ etc.) when working with code in this repository. ## Repository Overview -A collection of Postgres best practices skills for AI coding agents, -maintained by Supabase. Skills are packaged instructions that extend agent -capabilities for database optimization. - -## Installation - -```bash -npx skills add supabase/agent-skills -``` +A collection of Postgres best practices skills for AI coding agents, maintained +by Supabase. Skills are packaged instructions that extend agent capabilities for +database optimization. ## Creating a New Rule @@ -65,7 +59,6 @@ tags: relevant, keywords -- Comment explaining what's wrong [Bad SQL example] ``` -```` **Correct (description):** @@ -73,12 +66,8 @@ tags: relevant, keywords -- Comment explaining why this is better [Good SQL example] ``` - -**Supabase Note:** [Optional platform-specific guidance] - -Reference: [Link](url) - ```` + ### Best Practices for Context Efficiency Skills are loaded on-demand. To minimize context usage: @@ -98,7 +87,7 @@ cd packages/postgres-best-practices-build npm install npm run validate # Check rule format npm run build # Generate AGENTS.md -```` +``` ### Impact Levels @@ -123,4 +112,3 @@ npm run build # Generate AGENTS.md | `data-` | Data Access Patterns | 6 (MEDIUM) | | `monitor-` | Monitoring & Diagnostics | 7 (LOW-MEDIUM) | | `advanced-` | Advanced Features | 8 (LOW) | - diff --git a/packages/postgres-best-practices-build/src/build.ts b/packages/postgres-best-practices-build/src/build.ts index d1a13fe..152c152 100644 --- a/packages/postgres-best-practices-build/src/build.ts +++ b/packages/postgres-best-practices-build/src/build.ts @@ -202,10 +202,6 @@ function buildAgents(): void { } } - if (rule.supabaseNotes) { - output.push(`**Supabase Note:** ${rule.supabaseNotes}\n`); - } - if (rule.references && rule.references.length > 0) { if (rule.references.length === 1) { output.push(`Reference: ${rule.references[0]}\n`); diff --git a/packages/postgres-best-practices-build/src/parser.ts b/packages/postgres-best-practices-build/src/parser.ts index ddca1cc..5fbc9fb 100644 --- a/packages/postgres-best-practices-build/src/parser.ts +++ b/packages/postgres-best-practices-build/src/parser.ts @@ -194,14 +194,6 @@ function extractReferences(body: string): string[] { return references; } -/** - * Extract Supabase notes - */ -function extractSupabaseNotes(body: string): string | undefined { - const match = body.match(/\*\*Supabase Note:\*\*\s*(.+?)(?=\n\n|\n\*\*|$)/s); - return match ? match[1].trim() : undefined; -} - /** * Parse a rule file and return structured data */ @@ -237,8 +229,7 @@ export function parseRuleFile(filePath: string): ParseResult { // Extract other fields const explanation = extractExplanation(body); const examples = extractExamples(body); - const references = extractReferences(body); - const supabaseNotes = extractSupabaseNotes(body); + const tags = frontmatter.tags?.split(",").map((t) => t.trim()) || []; // Validation warnings @@ -258,9 +249,8 @@ export function parseRuleFile(filePath: string): ParseResult { impactDescription: frontmatter.impactDescription, explanation, examples, - references: references.length > 0 ? references : undefined, + references: extractReferences(body), tags: tags.length > 0 ? tags : undefined, - supabaseNotes, }; return { success: true, rule, errors, warnings }; diff --git a/skills/postgres-best-practices/rules/_contributing.md b/skills/postgres-best-practices/rules/_contributing.md index 975364a..99686a9 100644 --- a/skills/postgres-best-practices/rules/_contributing.md +++ b/skills/postgres-best-practices/rules/_contributing.md @@ -27,12 +27,12 @@ to recognize anti-patterns. Include specific metrics. Helps agents prioritize fixes. -**Good:** "10x faster queries", "50% smaller index", "Eliminates N+1" **Bad:** -"Faster", "Better", "More efficient" +**Good:** "10x faster queries", "50% smaller index", "Eliminates N+1" +**Bad:** "Faster", "Better", "More efficient" ### 4. Self-Contained Examples -Examples should be complete and runnable (or close to it). Include CREATE TABLE +Examples should be complete and runnable (or close to it). Include `CREATE TABLE` if context is needed. ```sql @@ -51,8 +51,8 @@ CREATE INDEX users_active_email_idx ON users(email) WHERE deleted_at IS NULL; Use meaningful table/column names. Names carry intent for LLMs. -**Good:** `users`, `email`, `created_at`, `is_active` **Bad:** `table1`, `col1`, -`field`, `flag` +**Good:** `users`, `email`, `created_at`, `is_active` +**Bad:** `table1`, `col1`, `field`, `flag` --- @@ -120,7 +120,6 @@ const posts = await db.query("SELECT * FROM posts WHERE user_id = ANY($1)", [ ]); ``` -```` --- ## Impact Level Guidelines @@ -136,24 +135,6 @@ const posts = await db.query("SELECT * FROM posts WHERE user_id = ANY($1)", [ --- -## Supabase-Specific Notes - -**When to Add:** -- Supavisor pooling configuration -- Dashboard features (index monitoring, query stats) -- RLS patterns specific to Supabase auth -- PostgREST implications - -**Format:** -```markdown -**Supabase Note:** The Dashboard > Database > Indexes page shows index usage statistics. -```` - -**Balance:** ~10% of content should be Supabase-specific. Core rules should work -on any Postgres. - ---- - ## Reference Standards **Primary Sources:**