class-ai-agent 1.2.3 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent/README.md +33 -0
- package/.agent/SESSION.md +54 -0
- package/.agent/SESSION.template.md +46 -0
- package/.claude/CLAUDE.md +24 -6
- package/.claude/commands/build.md +5 -4
- package/.claude/commands/debug.md +2 -1
- package/.claude/commands/handoff.md +94 -0
- package/.claude/commands/plan.md +1 -0
- package/.claude/commands/publish-npm.md +119 -0
- package/.claude/commands/resume.md +107 -0
- package/.claude/commands/spec.md +2 -1
- package/.claude/references/agent-continuity.md +42 -0
- package/.claude/references/codegraph.md +50 -0
- package/.claude/references/supabase.md +55 -0
- package/.claude/rules/agent-continuity.md +39 -0
- package/.claude/rules/tech-stack.md +2 -1
- package/.claude/skills/agent-continuity/SKILL.md +70 -0
- package/.claude/skills/supabase/SKILL.md +135 -0
- package/.claude/skills/supabase/UPSTREAM.md +16 -0
- package/.claude/skills/supabase/assets/feedback-issue-template.md +17 -0
- package/.claude/skills/supabase/references/skill-feedback.md +17 -0
- package/.claude/skills/supabase-postgres-best-practices/SKILL.md +64 -0
- package/.claude/skills/supabase-postgres-best-practices/UPSTREAM.md +16 -0
- package/.claude/skills/supabase-postgres-best-practices/references/_contributing.md +170 -0
- package/.claude/skills/supabase-postgres-best-practices/references/_sections.md +39 -0
- package/.claude/skills/supabase-postgres-best-practices/references/_template.md +34 -0
- package/.claude/skills/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -0
- package/.claude/skills/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -0
- package/.claude/skills/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -0
- package/.claude/skills/supabase-postgres-best-practices/references/conn-limits.md +44 -0
- package/.claude/skills/supabase-postgres-best-practices/references/conn-pooling.md +41 -0
- package/.claude/skills/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -0
- package/.claude/skills/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -0
- package/.claude/skills/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -0
- package/.claude/skills/supabase-postgres-best-practices/references/data-pagination.md +50 -0
- package/.claude/skills/supabase-postgres-best-practices/references/data-upsert.md +50 -0
- package/.claude/skills/supabase-postgres-best-practices/references/lock-advisory.md +56 -0
- package/.claude/skills/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -0
- package/.claude/skills/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -0
- package/.claude/skills/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -0
- package/.claude/skills/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -0
- package/.claude/skills/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -0
- package/.claude/skills/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -0
- package/.claude/skills/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -0
- package/.claude/skills/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -0
- package/.claude/skills/supabase-postgres-best-practices/references/query-index-types.md +48 -0
- package/.claude/skills/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -0
- package/.claude/skills/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -0
- package/.claude/skills/supabase-postgres-best-practices/references/schema-constraints.md +80 -0
- package/.claude/skills/supabase-postgres-best-practices/references/schema-data-types.md +46 -0
- package/.claude/skills/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -0
- package/.claude/skills/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -0
- package/.claude/skills/supabase-postgres-best-practices/references/schema-partitioning.md +55 -0
- package/.claude/skills/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -0
- package/.claude/skills/supabase-postgres-best-practices/references/security-privileges.md +54 -0
- package/.claude/skills/supabase-postgres-best-practices/references/security-rls-basics.md +50 -0
- package/.claude/skills/supabase-postgres-best-practices/references/security-rls-performance.md +63 -0
- package/.cursor/CURSOR.md +40 -5
- package/.cursor/commands/build.md +5 -4
- package/.cursor/commands/debug.md +2 -1
- package/.cursor/commands/handoff.md +94 -0
- package/.cursor/commands/plan.md +1 -0
- package/.cursor/commands/publish-npm.md +119 -0
- package/.cursor/commands/resume.md +107 -0
- package/.cursor/commands/spec.md +2 -1
- package/.cursor/mcp.json +19 -0
- package/.cursor/references/agent-continuity.md +42 -0
- package/.cursor/references/codegraph.md +87 -0
- package/.cursor/references/supabase.md +55 -0
- package/.cursor/rules/agent-continuity.mdc +44 -0
- package/.cursor/rules/codegraph.mdc +47 -0
- package/.cursor/rules/cursor-overview.mdc +10 -3
- package/.cursor/rules/tech-stack.mdc +2 -1
- package/.cursor/settings.json +6 -1
- package/.cursor/skills/agent-continuity/SKILL.md +70 -0
- package/.cursor/skills/supabase/SKILL.md +135 -0
- package/.cursor/skills/supabase/UPSTREAM.md +16 -0
- package/.cursor/skills/supabase/assets/feedback-issue-template.md +17 -0
- package/.cursor/skills/supabase/references/skill-feedback.md +17 -0
- package/.cursor/skills/supabase-postgres-best-practices/SKILL.md +64 -0
- package/.cursor/skills/supabase-postgres-best-practices/UPSTREAM.md +16 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/_contributing.md +170 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/_sections.md +39 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/_template.md +34 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/conn-limits.md +44 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/conn-pooling.md +41 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/data-pagination.md +50 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/data-upsert.md +50 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/lock-advisory.md +56 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/query-index-types.md +48 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/schema-constraints.md +80 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/schema-data-types.md +46 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/schema-partitioning.md +55 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/security-privileges.md +54 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/security-rls-basics.md +50 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/security-rls-performance.md +63 -0
- package/.kiro/KIRO.md +149 -0
- package/.kiro/agents/backend.md +395 -0
- package/.kiro/agents/code-reviewer.md +110 -0
- package/.kiro/agents/copywriter-seo.md +236 -0
- package/.kiro/agents/frontend.md +384 -0
- package/.kiro/agents/project-manager.md +201 -0
- package/.kiro/agents/qa.md +221 -0
- package/.kiro/agents/security-auditor.md +143 -0
- package/.kiro/agents/systems-architect.md +211 -0
- package/.kiro/agents/test-engineer.md +123 -0
- package/.kiro/agents/ui-ux-designer.md +210 -0
- package/.kiro/commands/build.md +133 -0
- package/.kiro/commands/debug.md +243 -0
- package/.kiro/commands/deploy.md +40 -0
- package/.kiro/commands/fix-issue.md +42 -0
- package/.kiro/commands/handoff.md +94 -0
- package/.kiro/commands/plan.md +126 -0
- package/.kiro/commands/publish-npm.md +119 -0
- package/.kiro/commands/resume.md +107 -0
- package/.kiro/commands/review.md +50 -0
- package/.kiro/commands/simplify.md +222 -0
- package/.kiro/commands/spec.md +96 -0
- package/.kiro/commands/test.md +214 -0
- package/.kiro/references/accessibility-checklist.md +174 -0
- package/.kiro/references/agent-continuity.md +42 -0
- package/.kiro/references/codegraph.md +86 -0
- package/.kiro/references/performance-checklist.md +150 -0
- package/.kiro/references/security-checklist.md +94 -0
- package/.kiro/references/supabase.md +55 -0
- package/.kiro/references/testing-patterns.md +183 -0
- package/.kiro/settings/mcp.json +19 -0
- package/.kiro/settings.json +8 -0
- package/.kiro/skills/agent-continuity/SKILL.md +70 -0
- package/.kiro/skills/code-review/SKILL.md +208 -0
- package/.kiro/skills/deploy/SKILL.md +68 -0
- package/.kiro/skills/deploy/deploy.md +735 -0
- package/.kiro/skills/incremental-implementation/SKILL.md +210 -0
- package/.kiro/skills/security-review/SKILL.md +71 -0
- package/.kiro/skills/supabase/SKILL.md +135 -0
- package/.kiro/skills/supabase/UPSTREAM.md +16 -0
- package/.kiro/skills/supabase/assets/feedback-issue-template.md +17 -0
- package/.kiro/skills/supabase/references/skill-feedback.md +17 -0
- package/.kiro/skills/supabase-postgres-best-practices/SKILL.md +64 -0
- package/.kiro/skills/supabase-postgres-best-practices/UPSTREAM.md +16 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/_contributing.md +170 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/_sections.md +39 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/_template.md +34 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/conn-limits.md +44 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/conn-pooling.md +41 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/data-pagination.md +50 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/data-upsert.md +50 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/lock-advisory.md +56 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/query-index-types.md +48 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/schema-constraints.md +80 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/schema-data-types.md +46 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/schema-partitioning.md +55 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/security-privileges.md +54 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/security-rls-basics.md +50 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/security-rls-performance.md +63 -0
- package/.kiro/skills/tdd/SKILL.md +217 -0
- package/.kiro/skills/ui-ux-pro-max/SKILL.md +288 -0
- package/.kiro/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/.kiro/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/.kiro/skills/ui-ux-pro-max/data/icons.csv +101 -0
- package/.kiro/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/.kiro/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/.kiro/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/.kiro/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
- package/.kiro/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/.kiro/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/.kiro/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/.kiro/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/.kiro/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/.kiro/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/.kiro/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/.kiro/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/.kiro/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/.kiro/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/.kiro/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/.kiro/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/.kiro/skills/ui-ux-pro-max/data/styles.csv +68 -0
- package/.kiro/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/.kiro/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/.kiro/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/.kiro/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/.kiro/skills/ui-ux-pro-max/scripts/core.py +253 -0
- package/.kiro/skills/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/.kiro/skills/ui-ux-pro-max/scripts/search.py +114 -0
- package/.kiro/steering/agent-continuity.md +44 -0
- package/.kiro/steering/api-conventions.md +85 -0
- package/.kiro/steering/clean-code.md +211 -0
- package/.kiro/steering/code-style.md +92 -0
- package/.kiro/steering/codegraph.md +47 -0
- package/.kiro/steering/database.md +66 -0
- package/.kiro/steering/error-handling.md +98 -0
- package/.kiro/steering/git-workflow.md +83 -0
- package/.kiro/steering/kiro-overview.md +38 -0
- package/.kiro/steering/monitoring.md +317 -0
- package/.kiro/steering/naming-conventions.md +266 -0
- package/.kiro/steering/project-structure.md +71 -0
- package/.kiro/steering/security.md +95 -0
- package/.kiro/steering/system-design.md +168 -0
- package/.kiro/steering/tech-stack.md +463 -0
- package/.kiro/steering/testing.md +110 -0
- package/AGENTS.md +13 -7
- package/README.md +126 -18
- package/bin/class-ai-agent.cjs +171 -11
- package/package.json +12 -4
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Supabase reference
|
|
2
|
+
|
|
3
|
+
[class-ai-agent](https://github.com/khoantd/class-ai-agent) bundles official [Supabase Agent Skills](https://github.com/supabase/agent-skills) and wires the **Supabase MCP** server for Cursor and Kiro.
|
|
4
|
+
|
|
5
|
+
## Skills
|
|
6
|
+
|
|
7
|
+
| Skill | Use when |
|
|
8
|
+
|-------|----------|
|
|
9
|
+
| `supabase` | Any Supabase product work: Database, Auth, Edge Functions, Realtime, Storage, CLI, MCP, migrations, RLS, `supabase-js`, `@supabase/ssr` |
|
|
10
|
+
| `supabase-postgres-best-practices` | SQL, schema design, indexes, pooling, RLS performance, query review |
|
|
11
|
+
|
|
12
|
+
Paths: `.cursor/skills/supabase/`, `.cursor/skills/supabase-postgres-best-practices/` (and `.claude/skills/`, `.kiro/skills/` after install).
|
|
13
|
+
|
|
14
|
+
Invoke with **`@`** mention or let the agent load them when the task matches. See each skill’s `SKILL.md` for security checklists and workflow.
|
|
15
|
+
|
|
16
|
+
**Maintainers:** refresh vendored copies with `npm run sync:supabase-skills` (pin in `scripts/supabase-skills.lock.json`).
|
|
17
|
+
|
|
18
|
+
## MCP (Cursor & Kiro)
|
|
19
|
+
|
|
20
|
+
| Tool | MCP config |
|
|
21
|
+
|------|------------|
|
|
22
|
+
| Cursor | `.cursor/mcp.json` → `mcpServers.supabase` |
|
|
23
|
+
| Kiro | `.kiro/settings/mcp.json` → `mcpServers.supabase` |
|
|
24
|
+
|
|
25
|
+
Server URL: `https://mcp.supabase.com/mcp?features=docs` (HTTP, OAuth 2.1).
|
|
26
|
+
|
|
27
|
+
### After install
|
|
28
|
+
|
|
29
|
+
1. **Reload** Cursor or **restart** Kiro so MCP servers connect.
|
|
30
|
+
2. On first use, complete **OAuth** in the browser when prompted (Supabase account).
|
|
31
|
+
3. Health check (expect `401` without a token — server is up):
|
|
32
|
+
```bash
|
|
33
|
+
curl -so /dev/null -w "%{http_code}" "https://mcp.supabase.com/mcp"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Useful MCP tools include `search_docs`, `list_projects`, `list_tables`, `execute_sql`, `get_advisors`, `get_logs`, and migration helpers. Prefer `search_docs` over guessing API behavior.
|
|
37
|
+
|
|
38
|
+
**Note:** Upstream skill text may refer to a project-root `.mcp.json`. In this scaffold, Supabase MCP lives only under `.cursor/mcp.json` and `.kiro/settings/mcp.json` — do not add a duplicate root `.mcp.json`.
|
|
39
|
+
|
|
40
|
+
## Claude Code
|
|
41
|
+
|
|
42
|
+
Skills install to `.claude/skills/`. Claude Code does not get MCP from this package by default. Options:
|
|
43
|
+
|
|
44
|
+
- [Supabase MCP setup](https://supabase.com/docs/guides/getting-started/mcp)
|
|
45
|
+
- [Supabase plugin for Claude Code](https://github.com/supabase/agent-skills)
|
|
46
|
+
|
|
47
|
+
## Secrets
|
|
48
|
+
|
|
49
|
+
Never commit service role keys, secret keys, or project tokens. Use environment variables per `.cursor/rules/security.mdc` (and `.claude/rules/security.md`, `.kiro/steering/security.md`).
|
|
50
|
+
|
|
51
|
+
## Learn more
|
|
52
|
+
|
|
53
|
+
- [Supabase AI skills docs](https://supabase.com/docs/guides/ai-tools/ai-skills)
|
|
54
|
+
- [Upstream repository](https://github.com/supabase/agent-skills)
|
|
55
|
+
- [THIRD_PARTY_NOTICES.md](../../THIRD_PARTY_NOTICES.md) — license and pinned version
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Agent continuity
|
|
2
|
+
|
|
3
|
+
Cross-tool handoff lives in **`.agent/SESSION.md`** (committed). Cursor, Claude Code, and Kiro agents share this file.
|
|
4
|
+
|
|
5
|
+
## Session start
|
|
6
|
+
|
|
7
|
+
1. If **`.agent/SESSION.md`** exists, read it **before** planning or editing code.
|
|
8
|
+
2. When the user says **continue**, **resume**, or **pick up**, use **`.claude/commands/resume.md`**.
|
|
9
|
+
3. Then read **`tasks/todo.md`** and linked **SPEC** paths from SESSION **Pointers**.
|
|
10
|
+
|
|
11
|
+
**Do not** call `codegraph_context` with `query` / `limit` for session resume — that tool requires **`task`** and is for code symbols, not handoff state. For continuity, read `.agent/SESSION.md` (and `tasks/todo.md`); use `codegraph_context` only when you need structural code context for the work described in SESSION.
|
|
12
|
+
|
|
13
|
+
## Session end and phase changes
|
|
14
|
+
|
|
15
|
+
1. Update **`.agent/SESSION.md`** before ending a session or switching tools — use **`.claude/commands/handoff.md`** when possible.
|
|
16
|
+
2. Keep **Done**, **In progress**, and **Next** accurate; do not leave stale **In progress** items.
|
|
17
|
+
3. Sync **`tasks/todo.md`** checkboxes when tasks change.
|
|
18
|
+
|
|
19
|
+
## Security (SESSION.md)
|
|
20
|
+
|
|
21
|
+
**Never** store in `.agent/SESSION.md`:
|
|
22
|
+
|
|
23
|
+
- API keys, passwords, tokens, credentials
|
|
24
|
+
- PII or customer data
|
|
25
|
+
|
|
26
|
+
Use issue links, commit SHAs, and file paths instead.
|
|
27
|
+
|
|
28
|
+
## Workflow integration
|
|
29
|
+
|
|
30
|
+
| Phase | SESSION `phase` value |
|
|
31
|
+
|-------|------------------------|
|
|
32
|
+
| Spec | `spec` |
|
|
33
|
+
| Plan | `plan` |
|
|
34
|
+
| Build | `build` |
|
|
35
|
+
| Test | `test` |
|
|
36
|
+
| Review | `review` |
|
|
37
|
+
| Debug | `debug` |
|
|
38
|
+
|
|
39
|
+
Set **Meta → Tool** to `cursor`, `claude`, or `kiro` as appropriate.
|
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
| **Backend Framework** | Express.js + Node | Fastify | Hapi, Koa |
|
|
18
18
|
| **API Style** | REST (default) | tRPC (fullstack TS) | GraphQL (unless needed) |
|
|
19
19
|
| **Language** | TypeScript (always) | — | Plain JavaScript |
|
|
20
|
-
| **Database** | PostgreSQL |
|
|
20
|
+
| **Database** | PostgreSQL | Supabase (managed Postgres + bundled `supabase` skills) | MySQL (prefer PG) |
|
|
21
21
|
| **ORM** | Prisma | Drizzle | Sequelize, TypeORM |
|
|
22
|
+
| **BaaS (Auth, DB, Storage, Realtime)** | — | Supabase | Firebase |
|
|
22
23
|
| **Cache** | Redis (ioredis) | Upstash Redis | Memcached |
|
|
23
24
|
| **Queue — Simple jobs** | BullMQ (Redis-backed) | — | — |
|
|
24
25
|
| **Queue — Enterprise/Microservices** | RabbitMQ | Kafka (high-throughput streams) | — |
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Agent Continuity
|
|
3
|
+
description: Cross-tool session handoff and resume via .agent/SESSION.md
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Agent Continuity Skill
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
Keep **Cursor**, **Claude Code**, and **Kiro** aligned on the same in-flight work using committed **`.agent/SESSION.md`**.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## When to apply
|
|
15
|
+
|
|
16
|
+
| Situation | Action |
|
|
17
|
+
|-----------|--------|
|
|
18
|
+
| New chat, same feature | **Resume** — read SESSION first |
|
|
19
|
+
| End of session | **Handoff** — update SESSION |
|
|
20
|
+
| Switch IDE/tool | **Handoff** then **Resume** in new tool |
|
|
21
|
+
| Switch persona | Update Meta `persona`; handoff notes for next role |
|
|
22
|
+
| Phase change (plan → build) | Update Meta `phase` |
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Handoff checklist
|
|
27
|
+
|
|
28
|
+
- [ ] Meta: date, phase, tool, persona
|
|
29
|
+
- [ ] Goal still accurate (one paragraph)
|
|
30
|
+
- [ ] Done: bullets with paths/commits
|
|
31
|
+
- [ ] In progress + blockers
|
|
32
|
+
- [ ] Next: numbered for next agent
|
|
33
|
+
- [ ] Decisions: non-obvious choices
|
|
34
|
+
- [ ] Gotchas: failures, test commands, env
|
|
35
|
+
- [ ] Pointers: spec, tasks, branch, key files
|
|
36
|
+
- [ ] `tasks/todo.md` synced
|
|
37
|
+
- [ ] No secrets or PII in SESSION
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Resume checklist
|
|
42
|
+
|
|
43
|
+
- [ ] Read `.agent/SESSION.md`
|
|
44
|
+
- [ ] Read `tasks/todo.md` if linked
|
|
45
|
+
- [ ] Read SPEC if linked
|
|
46
|
+
- [ ] `git status` vs SESSION expectations
|
|
47
|
+
- [ ] Run sanity build/test if Gotchas say so
|
|
48
|
+
- [ ] Post resumption summary to user
|
|
49
|
+
- [ ] Execute first **Next** step via workflow command
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## SESSION schema
|
|
54
|
+
|
|
55
|
+
See **`.agent/SESSION.template.md`** for the canonical sections.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Commands
|
|
60
|
+
|
|
61
|
+
| Command | File |
|
|
62
|
+
|---------|------|
|
|
63
|
+
| `/handoff` | `.cursor/commands/handoff.md` (`.claude/`, `.kiro/`) |
|
|
64
|
+
| `/resume` | `.cursor/commands/resume.md` |
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Optional history
|
|
69
|
+
|
|
70
|
+
Copy SESSION to `.agent/history/YYYY-MM-DD-slug.md` at milestones; commit for audit trail.
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: supabase
|
|
3
|
+
description: "Use when doing ANY task involving Supabase. Triggers: Supabase products (Database, Auth, Edge Functions, Realtime, Storage, Vectors, Cron, Queues); client libraries and SSR integrations (supabase-js, @supabase/ssr) in Next.js, React, SvelteKit, Astro, Remix; auth issues (login, logout, sessions, JWT, cookies, getSession, getUser, getClaims, RLS); Supabase CLI or MCP server; schema changes, migrations, security audits, Postgres extensions (pg_graphql, pg_cron, pg_vector)."
|
|
4
|
+
metadata:
|
|
5
|
+
author: supabase
|
|
6
|
+
version: "0.1.2"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Supabase
|
|
10
|
+
|
|
11
|
+
## Core Principles
|
|
12
|
+
|
|
13
|
+
**1. Supabase changes frequently — verify against changelog and current docs before implementing.**
|
|
14
|
+
Do not rely on training data for Supabase features. Function signatures, config.toml settings, and API conventions change between versions.
|
|
15
|
+
|
|
16
|
+
First, fetch `https://supabase.com/changelog.md` (a lightweight summary index — not a heavy pull), scan for `breaking-change` tags relevant to your task, and follow the linked page for any that apply. Then look up the relevant topic using the documentation access methods below.
|
|
17
|
+
|
|
18
|
+
**2. Verify your work.**
|
|
19
|
+
After implementing any fix, run a test query to confirm the change works. A fix without verification is incomplete.
|
|
20
|
+
|
|
21
|
+
**3. Recover from errors, don't loop.**
|
|
22
|
+
If an approach fails after 2-3 attempts, stop and reconsider. Try a different method, check documentation, inspect the error more carefully, and review relevant logs when available. Supabase issues are not always solved by retrying the same command, and the answer is not always in the logs, but logs are often worth checking before proceeding.
|
|
23
|
+
|
|
24
|
+
**4. Exposing tables to the Data API:** Depending on the user's [Data API settings](https://supabase.com/dashboard/project/<ref>/integrations/data_api/settings), newly created tables may not be automatically exposed via the Data (REST) API. If this is the case, `anon` and `authenticated` roles will need to be explicitly granted access.
|
|
25
|
+
|
|
26
|
+
> Note that this is separate from RLS, which controls which _rows_ are visible once a table is accessible, not whether the table is accessible at all.
|
|
27
|
+
|
|
28
|
+
When a user reports a SQL-created table is unexpectedly inaccessible, check their Data API settings and whether the roles have been granted access via explicit `GRANT` SQL. When granting public (`anon`/`authenticated`) access, always enable RLS too. See [Exposing a Table to the Data API](https://supabase.com/docs/guides/api/securing-your-api.md) for the full setup workflow.
|
|
29
|
+
|
|
30
|
+
**5. RLS in exposed schemas.**
|
|
31
|
+
Enable RLS on every table in any exposed schema, which includes `public` by default. This is critical in Supabase because tables in exposed schemas can be reachable through the Data API when the `anon`/`authenticated` roles have access (see [Exposing a Table to the Data API](https://supabase.com/docs/guides/api/securing-your-api.md)). For private schemas, prefer RLS as defense in depth. After enabling RLS, create policies that match the actual access model rather than defaulting every table to the same `auth.uid()` pattern.
|
|
32
|
+
|
|
33
|
+
**6. Security checklist.**
|
|
34
|
+
When working on any Supabase task that touches auth, RLS, views, storage, or user data, run through this checklist. These are Supabase-specific security traps that silently create vulnerabilities:
|
|
35
|
+
|
|
36
|
+
- **Auth and session security**
|
|
37
|
+
- **Never use `user_metadata` claims in JWT-based authorization decisions.** In Supabase, `raw_user_meta_data` is user-editable and can appear in `auth.jwt()`, so it is unsafe for RLS policies or any other authorization logic. Store authorization data in `raw_app_meta_data` / `app_metadata` instead.
|
|
38
|
+
- **Deleting a user does not invalidate existing access tokens.** Sign out or revoke sessions first, keep JWT expiry short for sensitive apps, and for strict guarantees validate `session_id` against `auth.sessions` on sensitive operations.
|
|
39
|
+
- **If you use `app_metadata` or `auth.jwt()` for authorization, remember JWT claims are not always fresh until the user's token is refreshed.**
|
|
40
|
+
|
|
41
|
+
- **API key and client exposure**
|
|
42
|
+
- **Never expose the `service_role` or secret key in public clients.** Prefer publishable keys for frontend code. Legacy `anon` keys are only for compatibility. In Next.js, any `NEXT_PUBLIC_` env var is sent to the browser.
|
|
43
|
+
|
|
44
|
+
- **RLS, views, and privileged database code**
|
|
45
|
+
- **Views bypass RLS by default.** In Postgres 15 and above, use `CREATE VIEW ... WITH (security_invoker = true)`. In older versions of Postgres, protect your views by revoking access from the `anon` and `authenticated` roles, or by putting them in an unexposed schema.
|
|
46
|
+
- **UPDATE requires a SELECT policy.** In Postgres RLS, an UPDATE needs to first SELECT the row. Without a SELECT policy, updates silently return 0 rows — no error, just no change.
|
|
47
|
+
- **`auth.role()` is deprecated — use the `TO` clause instead.** Supabase has deprecated `auth.role()` in favour of specifying the target role directly on the policy with `TO authenticated` or `TO anon`. Beyond deprecation, `auth.role() = 'authenticated'` breaks silently when anonymous sign-ins are enabled, because anonymous users carry the `authenticated` Postgres role and pass the check regardless of whether the user is genuinely signed in.
|
|
48
|
+
```sql
|
|
49
|
+
-- Deprecated (do not use)
|
|
50
|
+
create policy "example" on table_name for select
|
|
51
|
+
using ( auth.role() = 'authenticated' );
|
|
52
|
+
```
|
|
53
|
+
- **`TO authenticated` alone is authentication without authorization (BOLA / IDOR).** Using `TO authenticated` only checks the role — it does not restrict which rows a user can access. The correct pattern combines `TO authenticated` with an ownership predicate in `USING`:
|
|
54
|
+
```sql
|
|
55
|
+
create policy "example" on table_name for select
|
|
56
|
+
to authenticated
|
|
57
|
+
using ( (select auth.uid()) = user_id );
|
|
58
|
+
```
|
|
59
|
+
- **UPDATE policies require both `USING` and `WITH CHECK`.** Without `WITH CHECK`, a user can reassign a row's `user_id` to another user:
|
|
60
|
+
```sql
|
|
61
|
+
create policy "example" on table_name for update
|
|
62
|
+
to authenticated
|
|
63
|
+
using ( (select auth.uid()) = user_id )
|
|
64
|
+
with check ( (select auth.uid()) = user_id );
|
|
65
|
+
```
|
|
66
|
+
- **`SECURITY DEFINER` functions bypass RLS.** A `SECURITY DEFINER` function runs with its creator's privileges — typically a role with `bypassrls` (e.g., `postgres`). Never add `SECURITY DEFINER` to resolve a permission error; it silently removes access control without fixing the underlying cause. Prefer `SECURITY INVOKER`.
|
|
67
|
+
- **`SECURITY DEFINER` functions in `public` are callable by all roles.** Postgres grants `EXECUTE` to `PUBLIC` by default for every new function, so any `SECURITY DEFINER` function in `public` is a public API endpoint callable by `anon` and `authenticated` (which inherit from `PUBLIC`) without any additional grant. When `SECURITY DEFINER` is genuinely needed (e.g., bypassing RLS on an internal lookup table), keep the function in a non-exposed schema, always include an `auth.uid()` check in the function body, and run `supabase db advisors` after making changes.
|
|
68
|
+
|
|
69
|
+
- **Storage access control**
|
|
70
|
+
- **Storage upsert requires INSERT + SELECT + UPDATE.** Granting only INSERT allows new uploads but file replacement (upsert) silently fails. You need all three.
|
|
71
|
+
|
|
72
|
+
- **Dependency and supply-chain security**
|
|
73
|
+
- **Always pin package versions and commit lockfiles** when installing Supabase packages (`supabase-js`, `@supabase/ssr`, `supabase-py`, etc.). See the [npm security guide](https://supabase.com/docs/guides/security/npm-security.md) for the full checklist.
|
|
74
|
+
|
|
75
|
+
For any security concern not covered above, fetch the Supabase product security index: `https://supabase.com/docs/guides/security/product-security.md`
|
|
76
|
+
|
|
77
|
+
## Supabase CLI
|
|
78
|
+
|
|
79
|
+
Always discover commands via `--help` — never guess. The CLI structure changes between versions.
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
supabase --help # All top-level commands
|
|
83
|
+
supabase <group> --help # Subcommands (e.g., supabase db --help)
|
|
84
|
+
supabase <group> <command> --help # Flags for a specific command
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Supabase CLI Known gotchas:**
|
|
88
|
+
|
|
89
|
+
- `supabase db query` requires **CLI v2.79.0+** → use MCP `execute_sql` or `psql` as fallback
|
|
90
|
+
- `supabase db advisors` requires **CLI v2.81.3+** → use MCP `get_advisors` as fallback
|
|
91
|
+
- When you need a new migration SQL file, **always** create it with `supabase migration new <name>` first. Never invent a migration filename or rely on memory for the expected format.
|
|
92
|
+
|
|
93
|
+
**Version check and upgrade:** Run `supabase --version` to check. For CLI changelogs and version-specific features, consult the [CLI documentation](https://supabase.com/docs/reference/cli/introduction) or [GitHub releases](https://github.com/supabase/cli/releases).
|
|
94
|
+
|
|
95
|
+
## Supabase MCP Server
|
|
96
|
+
|
|
97
|
+
For setup instructions, server URL, and configuration, see the [MCP setup guide](https://supabase.com/docs/guides/getting-started/mcp).
|
|
98
|
+
|
|
99
|
+
**Troubleshooting connection issues** — follow these steps in order:
|
|
100
|
+
|
|
101
|
+
1. **Check if the server is reachable:**
|
|
102
|
+
`curl -so /dev/null -w "%{http_code}" https://mcp.supabase.com/mcp`
|
|
103
|
+
A `401` is expected (no token) and means the server is up. Timeout or "connection refused" means it may be down.
|
|
104
|
+
|
|
105
|
+
2. **Check `.mcp.json` configuration:**
|
|
106
|
+
Verify the project root has a valid `.mcp.json` with the correct server URL. If missing, create one pointing to `https://mcp.supabase.com/mcp`.
|
|
107
|
+
|
|
108
|
+
3. **Authenticate the MCP server:**
|
|
109
|
+
If the server is reachable and `.mcp.json` is correct but tools aren't visible, the user needs to authenticate. The Supabase MCP server uses OAuth 2.1 — tell the user to trigger the auth flow in their agent, complete it in the browser, and reload the session.
|
|
110
|
+
|
|
111
|
+
## Supabase Documentation
|
|
112
|
+
|
|
113
|
+
Before implementing any Supabase feature, find the relevant documentation. Use these methods in priority order:
|
|
114
|
+
|
|
115
|
+
1. **MCP `search_docs` tool** (preferred — returns relevant snippets directly)
|
|
116
|
+
2. **Fetch docs pages as markdown** — any docs page can be fetched by appending `.md` to the URL path.
|
|
117
|
+
3. **Web search** for Supabase-specific topics when you don't know which page to look at.
|
|
118
|
+
|
|
119
|
+
## Making and Committing Schema Changes
|
|
120
|
+
|
|
121
|
+
**To make schema changes, use `execute_sql` (MCP) or `supabase db query` (CLI).** These run SQL directly on the database without creating migration history entries, so you can iterate freely and generate a clean migration when ready.
|
|
122
|
+
|
|
123
|
+
Do NOT use `apply_migration` to change a local database schema — it writes a migration history entry on every call, which means you can't iterate, and `supabase db diff` / `supabase db pull` will produce empty or conflicting diffs. If you use it, you'll be stuck with whatever SQL you passed on the first try.
|
|
124
|
+
|
|
125
|
+
**When ready to commit** your changes to a migration file:
|
|
126
|
+
|
|
127
|
+
1. **Run advisors** → `supabase db advisors` (CLI v2.81.3+) or MCP `get_advisors`. Fix any issues.
|
|
128
|
+
2. **Review the Security Checklist above** if your changes involve views, functions, triggers, or storage.
|
|
129
|
+
3. **Generate the migration** → `supabase db pull <descriptive-name> --local --yes`
|
|
130
|
+
4. **Verify** → `supabase migration list --local`
|
|
131
|
+
|
|
132
|
+
## Reference Guides
|
|
133
|
+
|
|
134
|
+
- **Skill Feedback** → [references/skill-feedback.md](references/skill-feedback.md)
|
|
135
|
+
**MUST read when** the user reports that this skill gave incorrect guidance or is missing information.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Upstream
|
|
2
|
+
|
|
3
|
+
| Field | Value |
|
|
4
|
+
|-------|-------|
|
|
5
|
+
| Repository | [supabase/agent-skills](https://github.com/supabase/agent-skills) |
|
|
6
|
+
| Ref | `v0.1.5` |
|
|
7
|
+
| Commit | `30e4d716faf4b459291d607783fe866a70d0f4e9` |
|
|
8
|
+
| License | MIT |
|
|
9
|
+
|
|
10
|
+
Vendored by [class-ai-agent](https://github.com/khoantd/class-ai-agent). Refresh:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm run sync:supabase-skills
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Copyright (c) Supabase — see [upstream LICENSE](https://github.com/supabase/agent-skills/blob/v0.1.5/LICENSE).
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
## What happened
|
|
2
|
+
|
|
3
|
+
**Task:** <!-- e.g., "Set up MFA on patient records" -->
|
|
4
|
+
|
|
5
|
+
**Skill said:** <!-- e.g., "Use auth.jwt()->'app_metadata' in the RLS policy" -->
|
|
6
|
+
|
|
7
|
+
**Expected:** <!-- e.g., "The function also needs SECURITY DEFINER + grant to supabase_auth_admin" -->
|
|
8
|
+
|
|
9
|
+
## Source
|
|
10
|
+
|
|
11
|
+
**File:** <!-- e.g., references/security-model.md -->
|
|
12
|
+
|
|
13
|
+
**Section:** <!-- e.g., "Trust Boundaries > user_metadata vs app_metadata" -->
|
|
14
|
+
|
|
15
|
+
## Fix suggestion
|
|
16
|
+
|
|
17
|
+
<!-- Leave blank if unsure -->
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Skill Feedback
|
|
2
|
+
|
|
3
|
+
Use this when the user reports that the skill gave incorrect guidance, is missing information, or could be improved. This is about the skill (agent instructions), not about Supabase the product.
|
|
4
|
+
|
|
5
|
+
## Steps
|
|
6
|
+
|
|
7
|
+
1. **Ask permission** — Ask the user if they'd like to submit feedback to the skill maintainers. If they decline, move on.
|
|
8
|
+
|
|
9
|
+
2. **Draft the issue** — Use the template at [assets/feedback-issue-template.md](../assets/feedback-issue-template.md) to structure the feedback. Fill in the fields based on the conversation. Always identify which specific reference file and section caused the problem.
|
|
10
|
+
|
|
11
|
+
3. **Submit** — Create a GitHub Issue on the `supabase/agent-skills` repository using the draft as the issue body. The title must follow this format: `user-feedback: <summary of the problem>`.
|
|
12
|
+
|
|
13
|
+
4. **Share the result** — Share the issue URL with the user after submission. If submission fails, give the user this link to create the issue manually:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
https://github.com/supabase/agent-skills/issues/new
|
|
17
|
+
```
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: supabase-postgres-best-practices
|
|
3
|
+
description: Postgres performance optimization and best practices from Supabase. Use this skill when writing, reviewing, or optimizing Postgres queries, schema designs, or database configurations.
|
|
4
|
+
license: MIT
|
|
5
|
+
metadata:
|
|
6
|
+
author: supabase
|
|
7
|
+
version: "1.1.1"
|
|
8
|
+
organization: Supabase
|
|
9
|
+
date: January 2026
|
|
10
|
+
abstract: Comprehensive Postgres performance optimization guide for developers using Supabase and Postgres. Contains performance rules across 8 categories, prioritized by impact from critical (query performance, connection management) to incremental (advanced features). Each rule includes detailed explanations, incorrect vs. correct SQL examples, query plan analysis, and specific performance metrics to guide automated optimization and code generation.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Supabase Postgres Best Practices
|
|
14
|
+
|
|
15
|
+
Comprehensive performance optimization guide for Postgres, maintained by Supabase. Contains rules across 8 categories, prioritized by impact to guide automated query optimization and schema design.
|
|
16
|
+
|
|
17
|
+
## When to Apply
|
|
18
|
+
|
|
19
|
+
Reference these guidelines when:
|
|
20
|
+
- Writing SQL queries or designing schemas
|
|
21
|
+
- Implementing indexes or query optimization
|
|
22
|
+
- Reviewing database performance issues
|
|
23
|
+
- Configuring connection pooling or scaling
|
|
24
|
+
- Optimizing for Postgres-specific features
|
|
25
|
+
- Working with Row-Level Security (RLS)
|
|
26
|
+
|
|
27
|
+
## Rule Categories by Priority
|
|
28
|
+
|
|
29
|
+
| Priority | Category | Impact | Prefix |
|
|
30
|
+
|----------|----------|--------|--------|
|
|
31
|
+
| 1 | Query Performance | CRITICAL | `query-` |
|
|
32
|
+
| 2 | Connection Management | CRITICAL | `conn-` |
|
|
33
|
+
| 3 | Security & RLS | CRITICAL | `security-` |
|
|
34
|
+
| 4 | Schema Design | HIGH | `schema-` |
|
|
35
|
+
| 5 | Concurrency & Locking | MEDIUM-HIGH | `lock-` |
|
|
36
|
+
| 6 | Data Access Patterns | MEDIUM | `data-` |
|
|
37
|
+
| 7 | Monitoring & Diagnostics | LOW-MEDIUM | `monitor-` |
|
|
38
|
+
| 8 | Advanced Features | LOW | `advanced-` |
|
|
39
|
+
|
|
40
|
+
## How to Use
|
|
41
|
+
|
|
42
|
+
Read individual rule files for detailed explanations and SQL examples:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
references/query-missing-indexes.md
|
|
46
|
+
references/query-partial-indexes.md
|
|
47
|
+
references/_sections.md
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Each rule file contains:
|
|
51
|
+
- Brief explanation of why it matters
|
|
52
|
+
- Incorrect SQL example with explanation
|
|
53
|
+
- Correct SQL example with explanation
|
|
54
|
+
- Optional EXPLAIN output or metrics
|
|
55
|
+
- Additional context and references
|
|
56
|
+
- Supabase-specific notes (when applicable)
|
|
57
|
+
|
|
58
|
+
## References
|
|
59
|
+
|
|
60
|
+
- https://www.postgresql.org/docs/current/
|
|
61
|
+
- https://supabase.com/docs
|
|
62
|
+
- https://wiki.postgresql.org/wiki/Performance_Optimization
|
|
63
|
+
- https://supabase.com/docs/guides/database/overview
|
|
64
|
+
- https://supabase.com/docs/guides/auth/row-level-security
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Upstream
|
|
2
|
+
|
|
3
|
+
| Field | Value |
|
|
4
|
+
|-------|-------|
|
|
5
|
+
| Repository | [supabase/agent-skills](https://github.com/supabase/agent-skills) |
|
|
6
|
+
| Ref | `v0.1.5` |
|
|
7
|
+
| Commit | `30e4d716faf4b459291d607783fe866a70d0f4e9` |
|
|
8
|
+
| License | MIT |
|
|
9
|
+
|
|
10
|
+
Vendored by [class-ai-agent](https://github.com/khoantd/class-ai-agent). Refresh:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm run sync:supabase-skills
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Copyright (c) Supabase — see [upstream LICENSE](https://github.com/supabase/agent-skills/blob/v0.1.5/LICENSE).
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Writing Guidelines for Postgres References
|
|
2
|
+
|
|
3
|
+
This document provides guidelines for creating effective Postgres best
|
|
4
|
+
practice references that work well with AI agents and LLMs.
|
|
5
|
+
|
|
6
|
+
## Key Principles
|
|
7
|
+
|
|
8
|
+
### 1. Concrete Transformation Patterns
|
|
9
|
+
|
|
10
|
+
Show exact SQL rewrites. Avoid philosophical advice.
|
|
11
|
+
|
|
12
|
+
**Good:** "Use `WHERE id = ANY(ARRAY[...])` instead of
|
|
13
|
+
`WHERE id IN (SELECT ...)`" **Bad:** "Design good schemas"
|
|
14
|
+
|
|
15
|
+
### 2. Error-First Structure
|
|
16
|
+
|
|
17
|
+
Always show the problematic pattern first, then the solution. This trains agents
|
|
18
|
+
to recognize anti-patterns.
|
|
19
|
+
|
|
20
|
+
```markdown
|
|
21
|
+
**Incorrect (sequential queries):** [bad example]
|
|
22
|
+
|
|
23
|
+
**Correct (batched query):** [good example]
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### 3. Quantified Impact
|
|
27
|
+
|
|
28
|
+
Include specific metrics. Helps agents prioritize fixes.
|
|
29
|
+
|
|
30
|
+
**Good:** "10x faster queries", "50% smaller index", "Eliminates N+1"
|
|
31
|
+
**Bad:** "Faster", "Better", "More efficient"
|
|
32
|
+
|
|
33
|
+
### 4. Self-Contained Examples
|
|
34
|
+
|
|
35
|
+
Examples should be complete and runnable (or close to it). Include `CREATE TABLE`
|
|
36
|
+
if context is needed.
|
|
37
|
+
|
|
38
|
+
```sql
|
|
39
|
+
-- Include table definition when needed for clarity
|
|
40
|
+
CREATE TABLE users (
|
|
41
|
+
id bigint PRIMARY KEY,
|
|
42
|
+
email text NOT NULL,
|
|
43
|
+
deleted_at timestamptz
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
-- Now show the index
|
|
47
|
+
CREATE INDEX users_active_email_idx ON users(email) WHERE deleted_at IS NULL;
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 5. Semantic Naming
|
|
51
|
+
|
|
52
|
+
Use meaningful table/column names. Names carry intent for LLMs.
|
|
53
|
+
|
|
54
|
+
**Good:** `users`, `email`, `created_at`, `is_active`
|
|
55
|
+
**Bad:** `table1`, `col1`, `field`, `flag`
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Code Example Standards
|
|
60
|
+
|
|
61
|
+
### SQL Formatting
|
|
62
|
+
|
|
63
|
+
```sql
|
|
64
|
+
-- Use lowercase keywords, clear formatting
|
|
65
|
+
CREATE INDEX CONCURRENTLY users_email_idx
|
|
66
|
+
ON users(email)
|
|
67
|
+
WHERE deleted_at IS NULL;
|
|
68
|
+
|
|
69
|
+
-- Not cramped or ALL CAPS
|
|
70
|
+
CREATE INDEX CONCURRENTLY USERS_EMAIL_IDX ON USERS(EMAIL) WHERE DELETED_AT IS NULL;
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Comments
|
|
74
|
+
|
|
75
|
+
- Explain _why_, not _what_
|
|
76
|
+
- Highlight performance implications
|
|
77
|
+
- Point out common pitfalls
|
|
78
|
+
|
|
79
|
+
### Language Tags
|
|
80
|
+
|
|
81
|
+
- `sql` - Standard SQL queries
|
|
82
|
+
- `plpgsql` - Stored procedures/functions
|
|
83
|
+
- `typescript` - Application code (when needed)
|
|
84
|
+
- `python` - Application code (when needed)
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## When to Include Application Code
|
|
89
|
+
|
|
90
|
+
**Default: SQL Only**
|
|
91
|
+
|
|
92
|
+
Most references should focus on pure SQL patterns. This keeps examples portable.
|
|
93
|
+
|
|
94
|
+
**Include Application Code When:**
|
|
95
|
+
|
|
96
|
+
- Connection pooling configuration
|
|
97
|
+
- Transaction management in application context
|
|
98
|
+
- ORM anti-patterns (N+1 in Prisma/TypeORM)
|
|
99
|
+
- Prepared statement usage
|
|
100
|
+
|
|
101
|
+
**Format for Mixed Examples:**
|
|
102
|
+
|
|
103
|
+
````markdown
|
|
104
|
+
**Incorrect (N+1 in application):**
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
for (const user of users) {
|
|
108
|
+
const posts = await db.query("SELECT * FROM posts WHERE user_id = $1", [
|
|
109
|
+
user.id,
|
|
110
|
+
]);
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
````
|
|
114
|
+
|
|
115
|
+
**Correct (batch query):**
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
const posts = await db.query("SELECT * FROM posts WHERE user_id = ANY($1)", [
|
|
119
|
+
userIds,
|
|
120
|
+
]);
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Impact Level Guidelines
|
|
126
|
+
|
|
127
|
+
| Level | Improvement | Use When |
|
|
128
|
+
|-------|-------------|----------|
|
|
129
|
+
| **CRITICAL** | 10-100x | Missing indexes, connection exhaustion, sequential scans on large tables |
|
|
130
|
+
| **HIGH** | 5-20x | Wrong index types, poor partitioning, missing covering indexes |
|
|
131
|
+
| **MEDIUM-HIGH** | 2-5x | N+1 queries, inefficient pagination, RLS optimization |
|
|
132
|
+
| **MEDIUM** | 1.5-3x | Redundant indexes, query plan instability |
|
|
133
|
+
| **LOW-MEDIUM** | 1.2-2x | VACUUM tuning, configuration tweaks |
|
|
134
|
+
| **LOW** | Incremental | Advanced patterns, edge cases |
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Reference Standards
|
|
139
|
+
|
|
140
|
+
**Primary Sources:**
|
|
141
|
+
|
|
142
|
+
- Official Postgres documentation
|
|
143
|
+
- Supabase documentation
|
|
144
|
+
- Postgres wiki
|
|
145
|
+
- Established blogs (2ndQuadrant, Crunchy Data)
|
|
146
|
+
|
|
147
|
+
**Format:**
|
|
148
|
+
|
|
149
|
+
```markdown
|
|
150
|
+
Reference:
|
|
151
|
+
[Postgres Indexes](https://www.postgresql.org/docs/current/indexes.html)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Review Checklist
|
|
157
|
+
|
|
158
|
+
Before submitting a reference:
|
|
159
|
+
|
|
160
|
+
- [ ] Title is clear and action-oriented
|
|
161
|
+
- [ ] Impact level matches the performance gain
|
|
162
|
+
- [ ] impactDescription includes quantification
|
|
163
|
+
- [ ] Explanation is concise (1-2 sentences)
|
|
164
|
+
- [ ] Has at least 1 **Incorrect** SQL example
|
|
165
|
+
- [ ] Has at least 1 **Correct** SQL example
|
|
166
|
+
- [ ] SQL uses semantic naming
|
|
167
|
+
- [ ] Comments explain _why_, not _what_
|
|
168
|
+
- [ ] Trade-offs mentioned if applicable
|
|
169
|
+
- [ ] Reference links included
|
|
170
|
+
- [ ] `pnpm test` passes
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Section Definitions
|
|
2
|
+
|
|
3
|
+
This file defines the rule categories for Postgres best practices. Rules are automatically assigned to sections based on their filename prefix.
|
|
4
|
+
|
|
5
|
+
Take the examples below as pure demonstrative. Replace each section with the actual rule categories for Postgres best practices.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Query Performance (query)
|
|
10
|
+
**Impact:** CRITICAL
|
|
11
|
+
**Description:** Slow queries, missing indexes, inefficient query plans. The most common source of Postgres performance issues.
|
|
12
|
+
|
|
13
|
+
## 2. Connection Management (conn)
|
|
14
|
+
**Impact:** CRITICAL
|
|
15
|
+
**Description:** Connection pooling, limits, and serverless strategies. Critical for applications with high concurrency or serverless deployments.
|
|
16
|
+
|
|
17
|
+
## 3. Security & RLS (security)
|
|
18
|
+
**Impact:** CRITICAL
|
|
19
|
+
**Description:** Row-Level Security policies, privilege management, and authentication patterns.
|
|
20
|
+
|
|
21
|
+
## 4. Schema Design (schema)
|
|
22
|
+
**Impact:** HIGH
|
|
23
|
+
**Description:** Table design, index strategies, partitioning, and data type selection. Foundation for long-term performance.
|
|
24
|
+
|
|
25
|
+
## 5. Concurrency & Locking (lock)
|
|
26
|
+
**Impact:** MEDIUM-HIGH
|
|
27
|
+
**Description:** Transaction management, isolation levels, deadlock prevention, and lock contention patterns.
|
|
28
|
+
|
|
29
|
+
## 6. Data Access Patterns (data)
|
|
30
|
+
**Impact:** MEDIUM
|
|
31
|
+
**Description:** N+1 query elimination, batch operations, cursor-based pagination, and efficient data fetching.
|
|
32
|
+
|
|
33
|
+
## 7. Monitoring & Diagnostics (monitor)
|
|
34
|
+
**Impact:** LOW-MEDIUM
|
|
35
|
+
**Description:** Using pg_stat_statements, EXPLAIN ANALYZE, metrics collection, and performance diagnostics.
|
|
36
|
+
|
|
37
|
+
## 8. Advanced Features (advanced)
|
|
38
|
+
**Impact:** LOW
|
|
39
|
+
**Description:** Full-text search, JSONB optimization, PostGIS, extensions, and advanced Postgres features.
|