vibes-plug 2.14.1 → 3.9.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.
Files changed (151) hide show
  1. package/.claude/rules/vibes-plug-core.md +5 -0
  2. package/.cursor/rules/vibes-plug-core.mdc +7 -2
  3. package/.cursorrules +8 -2
  4. package/AGENTS.md +23 -2
  5. package/CHANGELOG.md +114 -0
  6. package/CLAUDE.md +10 -3
  7. package/README.md +216 -611
  8. package/bin/vibes.mjs +1104 -0
  9. package/package.json +11 -3
  10. package/plugin.json +4 -3
  11. package/scripts/check-anti-slop.mjs +53 -0
  12. package/scripts/install.js +3 -1
  13. package/scripts/update_skills.js +1 -1
  14. package/scripts/update_skills.mjs +86 -0
  15. package/scripts/validate-skills.mjs +111 -0
  16. package/skills/accessibility-testing-expert/SKILL.md +117 -116
  17. package/skills/affective-computing-emotion-ai/SKILL.md +83 -0
  18. package/skills/agentic-coding-workflow-expert/SKILL.md +297 -0
  19. package/skills/agentic-memory-architect/SKILL.md +52 -0
  20. package/skills/agentic-micro-economy-architect/SKILL.md +92 -0
  21. package/skills/ai-llm-integration-expert/SKILL.md +330 -194
  22. package/skills/ai-media-generation-expert/SKILL.md +173 -172
  23. package/skills/ai-prompt-engineering-expert/SKILL.md +204 -134
  24. package/skills/ai-safety-governance-expert/SKILL.md +223 -0
  25. package/skills/angular-expert/SKILL.md +149 -148
  26. package/skills/anti-slop/SKILL.md +134 -133
  27. package/skills/api-design-expert/SKILL.md +4 -3
  28. package/skills/api-gateway-proxy-expert/SKILL.md +3 -2
  29. package/skills/app-analyzer-optimizer/SKILL.md +4 -3
  30. package/skills/apple-ecosystem-expert/SKILL.md +6 -5
  31. package/skills/astro-framework-expert/SKILL.md +201 -200
  32. package/skills/async-queue-temporal-expert/SKILL.md +218 -217
  33. package/skills/authentication-identity-expert/SKILL.md +174 -173
  34. package/skills/autonomous-red-teamer/SKILL.md +338 -203
  35. package/skills/autonomous-tdd-debugger/SKILL.md +6 -5
  36. package/skills/biome-linter-formatter-expert/SKILL.md +90 -89
  37. package/skills/blockchain-web3-expert/SKILL.md +116 -115
  38. package/skills/brainstorming/SKILL.md +392 -377
  39. package/skills/browser-automation-expert/SKILL.md +260 -222
  40. package/skills/bun-runtime-expert/SKILL.md +5 -4
  41. package/skills/chatbot-messaging-expert/SKILL.md +115 -114
  42. package/skills/ci-cd-devops-architect/SKILL.md +3 -2
  43. package/skills/cloud-hosting-expert/SKILL.md +5 -4
  44. package/skills/coderabbit/SKILL.md +5 -4
  45. package/skills/compliance-gdpr-privacy-expert/SKILL.md +3 -2
  46. package/skills/composable-mach-architect/SKILL.md +338 -0
  47. package/skills/cron-scheduler-expert/SKILL.md +5 -4
  48. package/skills/data-pipeline-etl-expert/SKILL.md +3 -2
  49. package/skills/data-telemetry-expert/SKILL.md +5 -4
  50. package/skills/data-visualization-expert/SKILL.md +155 -154
  51. package/skills/database-orm-expert/SKILL.md +166 -165
  52. package/skills/deep-research-analyst/SKILL.md +182 -136
  53. package/skills/dependency-upgrade-migrator/SKILL.md +11 -10
  54. package/skills/design-system-architect/SKILL.md +4 -3
  55. package/skills/desktop-electron-expert/SKILL.md +129 -128
  56. package/skills/documentation-site-expert/SKILL.md +60 -59
  57. package/skills/doku-mcp-server/SKILL.md +5 -4
  58. package/skills/doku-payment-gateway/SKILL.md +250 -232
  59. package/skills/domain-driven-design-expert/SKILL.md +3 -2
  60. package/skills/e2e-testing-expert/SKILL.md +5 -4
  61. package/skills/ecommerce-expert/SKILL.md +88 -87
  62. package/skills/email-notification-expert/SKILL.md +5 -4
  63. package/skills/ephemeral-generative-ui-architect/SKILL.md +88 -0
  64. package/skills/error-resilience-expert/SKILL.md +14 -13
  65. package/skills/event-driven-architect/SKILL.md +5 -4
  66. package/skills/feature-flag-analytics-expert/SKILL.md +3 -2
  67. package/skills/file-upload-media-expert/SKILL.md +5 -4
  68. package/skills/firebase-security-expert/SKILL.md +5 -4
  69. package/skills/form-validation-expert/SKILL.md +7 -6
  70. package/skills/frontier-ai-models-expert/SKILL.md +116 -0
  71. package/skills/fullstack-expert/SKILL.md +185 -184
  72. package/skills/gemini-agent-booster/SKILL.md +248 -172
  73. package/skills/geospatial-maps-expert/SKILL.md +81 -80
  74. package/skills/global-a11y-i18n-expert/SKILL.md +5 -4
  75. package/skills/glsl-shader-expert/SKILL.md +191 -190
  76. package/skills/go-programming-expert/SKILL.md +5 -4
  77. package/skills/graph-rag-knowledge-expert/SKILL.md +201 -200
  78. package/skills/graphql-apollo-expert/SKILL.md +5 -4
  79. package/skills/headless-cms-expert/SKILL.md +182 -181
  80. package/skills/hig/SKILL.md +5 -4
  81. package/skills/js-backend-expert/SKILL.md +219 -218
  82. package/skills/legacy-code-translator/SKILL.md +6 -5
  83. package/skills/llm-finops-router/SKILL.md +52 -0
  84. package/skills/local-slm-edge-ai-expert/SKILL.md +168 -167
  85. package/skills/logging-error-tracking-expert/SKILL.md +5 -4
  86. package/skills/mcp-server-architect/SKILL.md +315 -307
  87. package/skills/micro-frontend-architect/SKILL.md +5 -4
  88. package/skills/mobile-expo-expert/SKILL.md +5 -4
  89. package/skills/modern-css-native-expert/SKILL.md +190 -189
  90. package/skills/monorepo-architect/SKILL.md +5 -4
  91. package/skills/mpa-orchestrator/SKILL.md +41 -4
  92. package/skills/multi-agent-orchestration/SKILL.md +388 -254
  93. package/skills/mvc-expert/SKILL.md +5 -4
  94. package/skills/n8n-automation-expert/SKILL.md +90 -89
  95. package/skills/nextjs-app-router-expert/SKILL.md +3 -2
  96. package/skills/openapi-swagger-codegen-expert/SKILL.md +4 -3
  97. package/skills/payment-gateway-expert/SKILL.md +131 -128
  98. package/skills/pdf-document-generation-expert/SKILL.md +92 -91
  99. package/skills/performance-web-vitals/SKILL.md +5 -4
  100. package/skills/post-quantum-crypto-migrator/SKILL.md +3 -2
  101. package/skills/prd-architect/SKILL.md +183 -182
  102. package/skills/proactive-background-watcher/SKILL.md +5 -4
  103. package/skills/production-ready-hardener/SKILL.md +10 -9
  104. package/skills/pwa-offline-first-expert/SKILL.md +227 -226
  105. package/skills/pydantic-ai-expert/SKILL.md +162 -161
  106. package/skills/python-programming-expert/SKILL.md +5 -4
  107. package/skills/rate-limit-abuse-prevention/SKILL.md +5 -4
  108. package/skills/realtime-collaboration-expert/SKILL.md +3 -2
  109. package/skills/rich-text-editor-expert/SKILL.md +178 -177
  110. package/skills/rust-programming-expert/SKILL.md +5 -4
  111. package/skills/saas-architect/SKILL.md +155 -154
  112. package/skills/saas-billing/SKILL.md +394 -382
  113. package/skills/saas-multi-tenant/SKILL.md +7 -6
  114. package/skills/scalability-clean-code/SKILL.md +5 -4
  115. package/skills/search-engine-expert/SKILL.md +90 -89
  116. package/skills/self-healing-cloud-orchestrator/SKILL.md +3 -2
  117. package/skills/senior-frontend/SKILL.md +14 -9
  118. package/skills/seo/SKILL.md +4 -4
  119. package/skills/session-memory-manager/SKILL.md +129 -128
  120. package/skills/solidjs-expert/SKILL.md +81 -80
  121. package/skills/spa-orchestrator/SKILL.md +5 -4
  122. package/skills/sse-websocket-streaming-expert/SKILL.md +3 -2
  123. package/skills/state-management-expert/SKILL.md +5 -4
  124. package/skills/supabase-security-expert/SKILL.md +5 -4
  125. package/skills/svelte-sveltekit-expert/SKILL.md +92 -91
  126. package/skills/svg-animation-motion-expert/SKILL.md +3 -2
  127. package/skills/synthetic-data-finetuning-expert/SKILL.md +156 -155
  128. package/skills/tailwind-expert/SKILL.md +62 -5
  129. package/skills/tanstack-query-expert/SKILL.md +5 -4
  130. package/skills/tauri-expert/SKILL.md +5 -4
  131. package/skills/typescript-expert/SKILL.md +5 -4
  132. package/skills/ui-ux-pro-max/SKILL.md +7 -6
  133. package/skills/vector-db-rag-expert/SKILL.md +209 -208
  134. package/skills/vercel-ai-sdk-expert/SKILL.md +226 -181
  135. package/skills/voice-ai-realtime-agent/SKILL.md +243 -242
  136. package/skills/vue-frontend-expert/SKILL.md +5 -4
  137. package/skills/wasm-edge-computing-expert/SKILL.md +3 -2
  138. package/skills/web-3d-graphics-expert/SKILL.md +314 -313
  139. package/skills/web-game-engine-expert/SKILL.md +330 -329
  140. package/skills/web-scraper/SKILL.md +158 -157
  141. package/skills/website-design-cloner/SKILL.md +5 -4
  142. package/skills/webxr-ar-vr-expert/SKILL.md +163 -162
  143. package/skills/wordpress-headless-expert/SKILL.md +145 -144
  144. package/skills/zero-tech-debt-auditor/SKILL.md +115 -0
  145. package/skills/zero-to-prod-orchestrator/SKILL.md +281 -229
  146. package/skills/zero-trust-secret-vault/SKILL.md +3 -2
  147. package/BLUEPRINT.md +0 -319
  148. package/skills/bootstrap-to-modern/SKILL.md +0 -94
  149. package/skills/multiple-entry-points/SKILL.md +0 -91
  150. package/skills/secure-fuzz-testing/SKILL.md +0 -207
  151. package/skills/visual-qa-vision-agent/SKILL.md +0 -71
@@ -1,165 +1,166 @@
1
- ---
2
- name: database-orm-expert
3
- description: "Updated to be the unified database skill covering ORM, migrations, edge DBs, and Supabase CLI / Keahlian database terpadu untuk ORM, migrasi, edge DB, dan Supabase CLI."
4
- author: "Roedy Rustam"
5
- ---
6
-
7
- # Unified Database & ORM Expert
8
-
9
- [English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
10
-
11
- ---
12
-
13
- <a name="english"></a>
14
- ## English
15
-
16
- ### Description
17
- Design schemas, select ORMs, execute zero-downtime migrations, optimize queries, and implement edge serverless databases. Covers Prisma 6, Drizzle ORM, TypeORM, Supabase CLI workflows, and Edge DBs (Neon, Cloudflare D1, Turso, Upstash).
18
-
19
- ### Trigger Conditions
20
- - Designing or migrating a production schema (blue-green, canary).
21
- - Choosing between Prisma, Drizzle ORM, or TypeORM.
22
- - Writing complex queries with joins, aggregations, or pagination.
23
- - Optimizing slow queries or N+1 problems.
24
- - Building edge-compatible serverless database connections.
25
- - Executing Supabase migrations and RLS patterns.
26
- - Managing backward-compatible massive data backfills.
27
-
28
- ## Orchestration & Integration
29
- - `js-backend-expert`: For Node/Bun/Deno backend implementations integrating these ORMs.
30
- - `ci-cd-devops-architect`: For automated migration deployment steps.
31
- - `supabase-security-expert`: For Supabase RLS and security.
32
- - `cloud-hosting-expert`: For infrastructure integration.
33
-
34
- ---
35
-
36
- ### Core ORM & Query Strategies
37
-
38
- #### ORM Selection Guide
39
- | Criteria | Prisma 6 | Drizzle ORM | TypeORM |
40
- |---|---|---|---|
41
- | **Type Safety** | Schema-generated types | SQL-like, inferred types | Decorator-based |
42
- | **Bundle Size** | Heavy (binary client) | Lightweight (<35KB) | Medium |
43
- | **Query Style** | Fluent ORM API | SQL-first, composable | ActiveRecord / QueryBuilder |
44
- | **Edge Runtime** | Prisma Accelerate needed | Native edge support | No |
45
- | **Migrations** | `prisma migrate dev` | `drizzle-kit push/migrate` | `synchronize` (dev only) |
46
-
47
- **Recommendation**: Use **Drizzle ORM** for edge-compatible apps and performance-critical systems. Use **Prisma 6** for teams preferring a schema-first DX.
48
-
49
- #### Prisma 6 Best Practices
50
- - Use `$transaction` for atomic operations.
51
- - Avoid N+1 queries by using `select` and `include` (with Prisma 5.7+ relationJoins preview) rather than looping over `findMany`.
52
-
53
- #### Drizzle ORM Best Practices
54
- - Use `drizzle-kit generate` for generating SQL and `drizzle-kit migrate` for deployment.
55
- - Utilize native edge support and type-safe query builders with `drizzle-orm`.
56
-
57
- #### Query Optimization Principles
58
- 1. **Always index foreign keys** and columns used in `WHERE`, `ORDER BY`, and `JOIN`.
59
- 2. **Use `EXPLAIN ANALYZE`** to detect sequential scans.
60
- 3. **Cursor-based pagination** over offset for large datasets.
61
- 4. **Avoid `SELECT *`**. Batch inserts where possible.
62
- 5. **Connection Pooling**: Use PgBouncer, Supabase's built-in pooler, or Prisma Accelerate for standard TCP to avoid exhausting connection limits. Alternatively, use HTTP/WebSocket drivers for edge queries.
63
-
64
- ---
65
-
66
- ### Zero-Downtime Migrations & Versioning
67
-
68
- #### 1. Zero-Downtime Migration Pattern (Expand and Contract)
69
- Never make breaking changes in a single deployment.
70
- - **Phase 1 (Expand)**: Add the new schema element (column, table) without removing the old one.
71
- - **Phase 2 (Migrate)**: Update app to write to *both* and read from the new element (with fallback).
72
- - **Phase 3 (Backfill)**: Run background script to backfill data to new element.
73
- - **Phase 4 (Contract)**: Remove old application code.
74
- - **Phase 5 (Cleanup)**: Drop old schema element in next deployment.
75
-
76
- #### 2. Backward Compatibility Rules
77
- - **Never `DROP` or `RENAME`** a column/table in active use.
78
- - **Add `DEFAULT` values** to new `NOT NULL` columns.
79
-
80
- #### 3. Migration Mechanics & Safe Data Backfilling
81
- - **Never run `prisma db push` or `synchronize: true`** in production. Always use immutable version-controlled scripts (e.g., `20260814_add_user_status.sql`).
82
- - Write idempotent scripts (`CREATE TABLE IF NOT EXISTS`).
83
- - **Chunking**: For large tables, perform updates in batches (using `LIMIT` and sleep intervals) to prevent table locking. Use background jobs (BullMQ/Inngest).
84
-
85
- ---
86
-
87
- ### Edge & Serverless Drivers
88
-
89
- Exploit serverless DBs for ultra-low latency:
90
- - **Neon & Cloudflare D1**: Serverless autoscaling Postgres with instant branching; Distributed edge SQLite.
91
- - **Embedded Replicas**: Sync edge SQLite read-replicas with central cloud DBs.
92
- - **HTTP/WebSocket Proxy Pooling**: Use `neon-http` or similar when querying databases from Edge Workers/Functions.
93
- - **Upstash Redis Edge Caching**:
94
- ```typescript
95
- import { Redis } from '@upstash/redis';
96
- const redis = new Redis({ url: process.env.UPSTASH_REDIS_REST_URL!, token: process.env.UPSTASH_REDIS_REST_TOKEN! });
97
- export async function getCachedData(key: string) {
98
- let data = await redis.get(key);
99
- if (!data) {
100
- data = await fetchFromDB();
101
- await redis.set(key, data, { ex: 3600 });
102
- }
103
- return data;
104
- }
105
- ```
106
-
107
- ---
108
-
109
- ### Supabase CLI & MCP Workflow
110
-
111
- 1. **Check Environment**: Ensure `supabase/migrations` directory exists.
112
- 2. **Review Available MCP Commands**:
113
- - List existing migrations: `mcp_supabase-mcp-server_list_migrations` with `project_id`.
114
- - Confirm SQL before executing via server directly.
115
- 3. **Execute Command**:
116
- - Write SQL script locally: `npx supabase migration new [name]` -> writes to `supabase/migrations/<timestamp>_[name].sql`.
117
- - Test locally: `npx supabase migration up` or `npx supabase db reset`.
118
- - Apply remote: `npx supabase db push` (or use remote MCP `apply_migration`).
119
- 4. **Final Step**: If using RLS, explicitly add policies to new tables. Confirm completion with user.
120
-
121
- ---
122
-
123
- <a name="bahasa-indonesia"></a>
124
- ## Bahasa Indonesia
125
-
126
- ### Deskripsi
127
- Rancang skema, pilih ORM, eksekusi migrasi tanpa downtime, optimalkan query, dan implementasikan edge serverless DB. Mencakup Prisma 6, Drizzle, TypeORM, Supabase CLI, dan Edge DBs (Neon, Cloudflare D1, Turso, Upstash).
128
-
129
- ### Kondisi Pemicu
130
- - Merancang atau memigrasikan skema produksi (blue-green, canary).
131
- - Memilih antara Prisma, Drizzle, atau TypeORM.
132
- - Mengoptimalkan query lambat atau masalah N+1.
133
- - Membuat koneksi serverless kompatibel dengan edge.
134
- - Mengeksekusi migrasi Supabase dan pola RLS.
135
- - Mengelola backfill data besar secara backward-compatible.
136
-
137
- ## Integrasi Orkestrasi
138
- - `js-backend-expert`: Untuk implementasi Node/Bun/Deno.
139
- - `ci-cd-devops-architect`: Untuk otomatisasi langkah deployment migrasi.
140
- - `supabase-security-expert`: Untuk RLS dan keamanan Supabase.
141
- - `cloud-hosting-expert`: Untuk integrasi infrastruktur.
142
-
143
- ### Strategi Inti ORM & Query
144
- - **Drizzle ORM** direkomendasikan untuk aplikasi edge, **Prisma 6** untuk DX schema-first.
145
- - Gunakan `$transaction` dan batasi `SELECT *`.
146
- - Selalu indeks foreign key dan gunakan pagination berbasis cursor (Cursor-based pagination).
147
- - **Connection Pooling**: Gunakan pooler bawaan Supabase, PgBouncer, Prisma Accelerate, atau driver HTTP (seperti `neon-http`) untuk request edge.
148
-
149
- ### Migrasi Tanpa Downtime & Versioning
150
- - **Pola Expand and Contract**: Jangan pernah melakukan breaking change dalam satu rilis. Tambah kolom baru, update kode untuk memakai keduanya, backfill data, hapus kode lama, lalu drop kolom lama.
151
- - Jangan gunakan `DROP` atau `RENAME` pada kolom aktif. Kolom `NOT NULL` baru harus memiliki nilai `DEFAULT`.
152
- - **Jangan jalankan `prisma db push` atau `synchronize: true`** di produksi. Gunakan skrip migrasi bertahap (idempoten).
153
- - **Backfill Aman**: Gunakan pemrosesan batch/chunking dengan background job untuk tabel raksasa agar tidak menyebabkan table lock.
154
-
155
- ### Driver Edge & Serverless
156
- - Manfaatkan Neon Serverless Postgres, Cloudflare D1, Turso, atau Upstash Redis (caching).
157
- - Gunakan driver berbasis HTTP/WebSocket di lingkungan Edge Workers untuk mencegah habisnya batas koneksi TCP.
158
-
159
- ### Alur Kerja Supabase CLI & MCP
160
- 1. Pastikan folder `supabase/migrations` ada.
161
- 2. Periksa migrasi dengan `mcp_supabase-mcp-server_list_migrations`.
162
- 3. Buat file migrasi lokal dengan `npx supabase migration new [nama]`.
163
- 4. Uji lokal dengan `npx supabase migration up`.
164
- 5. Deploy remote dengan `npx supabase db push` atau melalui MCP.
165
- 6. Tambahkan kebijakan RLS jika diperlukan. Konfirmasikan sukses ke pengguna.
1
+ ---
2
+ name: database-orm-expert
3
+ description: "Updated to be the unified database skill covering ORM, migrations, edge DBs, and Supabase CLI / Keahlian database terpadu untuk ORM, migrasi, edge DB, dan Supabase CLI."
4
+ author: "Roedy Rustam"
5
+ version: "3.0.0"
6
+ ---
7
+
8
+ # Unified Database & ORM Expert
9
+
10
+ [English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
11
+
12
+ ---
13
+
14
+ <a name="english"></a>
15
+ ## English
16
+
17
+ ### Description
18
+ Design schemas, select ORMs, execute zero-downtime migrations, optimize queries, and implement edge serverless databases. Covers Prisma 6, Drizzle ORM, TypeORM, Supabase CLI workflows, and Edge DBs (Neon, Cloudflare D1, Turso, Upstash).
19
+
20
+ ### Trigger Conditions
21
+ - Designing or migrating a production schema (blue-green, canary).
22
+ - Choosing between Prisma, Drizzle ORM, or TypeORM.
23
+ - Writing complex queries with joins, aggregations, or pagination.
24
+ - Optimizing slow queries or N+1 problems.
25
+ - Building edge-compatible serverless database connections.
26
+ - Executing Supabase migrations and RLS patterns.
27
+ - Managing backward-compatible massive data backfills.
28
+
29
+ ## Orchestration & Integration
30
+ - `js-backend-expert`: For Node/Bun/Deno backend implementations integrating these ORMs.
31
+ - `ci-cd-devops-architect`: For automated migration deployment steps.
32
+ - `supabase-security-expert`: For Supabase RLS and security.
33
+ - `cloud-hosting-expert`: For infrastructure integration.
34
+
35
+ ---
36
+
37
+ ### Core ORM & Query Strategies
38
+
39
+ #### ORM Selection Guide
40
+ | Criteria | Prisma 6 | Drizzle ORM | TypeORM |
41
+ |---|---|---|---|
42
+ | **Type Safety** | Schema-generated types | SQL-like, inferred types | Decorator-based |
43
+ | **Bundle Size** | Heavy (binary client) | Lightweight (<35KB) | Medium |
44
+ | **Query Style** | Fluent ORM API | SQL-first, composable | ActiveRecord / QueryBuilder |
45
+ | **Edge Runtime** | Prisma Accelerate needed | Native edge support | No |
46
+ | **Migrations** | `prisma migrate dev` | `drizzle-kit push/migrate` | `synchronize` (dev only) |
47
+
48
+ **Recommendation**: Use **Drizzle ORM** for edge-compatible apps and performance-critical systems. Use **Prisma 6** for teams preferring a schema-first DX.
49
+
50
+ #### Prisma 6 Best Practices
51
+ - Use `$transaction` for atomic operations.
52
+ - Avoid N+1 queries by using `select` and `include` (with Prisma 5.7+ relationJoins preview) rather than looping over `findMany`.
53
+
54
+ #### Drizzle ORM Best Practices
55
+ - Use `drizzle-kit generate` for generating SQL and `drizzle-kit migrate` for deployment.
56
+ - Utilize native edge support and type-safe query builders with `drizzle-orm`.
57
+
58
+ #### Query Optimization Principles
59
+ 1. **Always index foreign keys** and columns used in `WHERE`, `ORDER BY`, and `JOIN`.
60
+ 2. **Use `EXPLAIN ANALYZE`** to detect sequential scans.
61
+ 3. **Cursor-based pagination** over offset for large datasets.
62
+ 4. **Avoid `SELECT *`**. Batch inserts where possible.
63
+ 5. **Connection Pooling**: Use PgBouncer, Supabase's built-in pooler, or Prisma Accelerate for standard TCP to avoid exhausting connection limits. Alternatively, use HTTP/WebSocket drivers for edge queries.
64
+
65
+ ---
66
+
67
+ ### Zero-Downtime Migrations & Versioning
68
+
69
+ #### 1. Zero-Downtime Migration Pattern (Expand and Contract)
70
+ Never make breaking changes in a single deployment.
71
+ - **Phase 1 (Expand)**: Add the new schema element (column, table) without removing the old one.
72
+ - **Phase 2 (Migrate)**: Update app to write to *both* and read from the new element (with fallback).
73
+ - **Phase 3 (Backfill)**: Run background script to backfill data to new element.
74
+ - **Phase 4 (Contract)**: Remove old application code.
75
+ - **Phase 5 (Cleanup)**: Drop old schema element in next deployment.
76
+
77
+ #### 2. Backward Compatibility Rules
78
+ - **Never `DROP` or `RENAME`** a column/table in active use.
79
+ - **Add `DEFAULT` values** to new `NOT NULL` columns.
80
+
81
+ #### 3. Migration Mechanics & Safe Data Backfilling
82
+ - **Never run `prisma db push` or `synchronize: true`** in production. Always use immutable version-controlled scripts (e.g., `20260814_add_user_status.sql`).
83
+ - Write idempotent scripts (`CREATE TABLE IF NOT EXISTS`).
84
+ - **Chunking**: For large tables, perform updates in batches (using `LIMIT` and sleep intervals) to prevent table locking. Use background jobs (BullMQ/Inngest).
85
+
86
+ ---
87
+
88
+ ### Edge & Serverless Drivers
89
+
90
+ Exploit serverless DBs for ultra-low latency:
91
+ - **Neon & Cloudflare D1**: Serverless autoscaling Postgres with instant branching; Distributed edge SQLite.
92
+ - **Embedded Replicas**: Sync edge SQLite read-replicas with central cloud DBs.
93
+ - **HTTP/WebSocket Proxy Pooling**: Use `neon-http` or similar when querying databases from Edge Workers/Functions.
94
+ - **Upstash Redis Edge Caching**:
95
+ ```typescript
96
+ import { Redis } from '@upstash/redis';
97
+ const redis = new Redis({ url: process.env.UPSTASH_REDIS_REST_URL!, token: process.env.UPSTASH_REDIS_REST_TOKEN! });
98
+ export async function getCachedData(key: string) {
99
+ let data = await redis.get(key);
100
+ if (!data) {
101
+ data = await fetchFromDB();
102
+ await redis.set(key, data, { ex: 3600 });
103
+ }
104
+ return data;
105
+ }
106
+ ```
107
+
108
+ ---
109
+
110
+ ### Supabase CLI & MCP Workflow
111
+
112
+ 1. **Check Environment**: Ensure `supabase/migrations` directory exists.
113
+ 2. **Review Available MCP Commands**:
114
+ - List existing migrations: `mcp_supabase-mcp-server_list_migrations` with `project_id`.
115
+ - Confirm SQL before executing via server directly.
116
+ 3. **Execute Command**:
117
+ - Write SQL script locally: `npx supabase migration new [name]` -> writes to `supabase/migrations/<timestamp>_[name].sql`.
118
+ - Test locally: `npx supabase migration up` or `npx supabase db reset`.
119
+ - Apply remote: `npx supabase db push` (or use remote MCP `apply_migration`).
120
+ 4. **Final Step**: If using RLS, explicitly add policies to new tables. Confirm completion with user.
121
+
122
+ ---
123
+
124
+ <a name="bahasa-indonesia"></a>
125
+ ## Bahasa Indonesia
126
+
127
+ ### Deskripsi
128
+ Rancang skema, pilih ORM, eksekusi migrasi tanpa downtime, optimalkan query, dan implementasikan edge serverless DB. Mencakup Prisma 6, Drizzle, TypeORM, Supabase CLI, dan Edge DBs (Neon, Cloudflare D1, Turso, Upstash).
129
+
130
+ ### Kondisi Pemicu
131
+ - Merancang atau memigrasikan skema produksi (blue-green, canary).
132
+ - Memilih antara Prisma, Drizzle, atau TypeORM.
133
+ - Mengoptimalkan query lambat atau masalah N+1.
134
+ - Membuat koneksi serverless kompatibel dengan edge.
135
+ - Mengeksekusi migrasi Supabase dan pola RLS.
136
+ - Mengelola backfill data besar secara backward-compatible.
137
+
138
+ ## Integrasi Orkestrasi
139
+ - `js-backend-expert`: Untuk implementasi Node/Bun/Deno.
140
+ - `ci-cd-devops-architect`: Untuk otomatisasi langkah deployment migrasi.
141
+ - `supabase-security-expert`: Untuk RLS dan keamanan Supabase.
142
+ - `cloud-hosting-expert`: Untuk integrasi infrastruktur.
143
+
144
+ ### Strategi Inti ORM & Query
145
+ - **Drizzle ORM** direkomendasikan untuk aplikasi edge, **Prisma 6** untuk DX schema-first.
146
+ - Gunakan `$transaction` dan batasi `SELECT *`.
147
+ - Selalu indeks foreign key dan gunakan pagination berbasis cursor (Cursor-based pagination).
148
+ - **Connection Pooling**: Gunakan pooler bawaan Supabase, PgBouncer, Prisma Accelerate, atau driver HTTP (seperti `neon-http`) untuk request edge.
149
+
150
+ ### Migrasi Tanpa Downtime & Versioning
151
+ - **Pola Expand and Contract**: Jangan pernah melakukan breaking change dalam satu rilis. Tambah kolom baru, update kode untuk memakai keduanya, backfill data, hapus kode lama, lalu drop kolom lama.
152
+ - Jangan gunakan `DROP` atau `RENAME` pada kolom aktif. Kolom `NOT NULL` baru harus memiliki nilai `DEFAULT`.
153
+ - **Jangan jalankan `prisma db push` atau `synchronize: true`** di produksi. Gunakan skrip migrasi bertahap (idempoten).
154
+ - **Backfill Aman**: Gunakan pemrosesan batch/chunking dengan background job untuk tabel raksasa agar tidak menyebabkan table lock.
155
+
156
+ ### Driver Edge & Serverless
157
+ - Manfaatkan Neon Serverless Postgres, Cloudflare D1, Turso, atau Upstash Redis (caching).
158
+ - Gunakan driver berbasis HTTP/WebSocket di lingkungan Edge Workers untuk mencegah habisnya batas koneksi TCP.
159
+
160
+ ### Alur Kerja Supabase CLI & MCP
161
+ 1. Pastikan folder `supabase/migrations` ada.
162
+ 2. Periksa migrasi dengan `mcp_supabase-mcp-server_list_migrations`.
163
+ 3. Buat file migrasi lokal dengan `npx supabase migration new [nama]`.
164
+ 4. Uji lokal dengan `npx supabase migration up`.
165
+ 5. Deploy remote dengan `npx supabase db push` atau melalui MCP.
166
+ 6. Tambahkan kebijakan RLS jika diperlukan. Konfirmasikan sukses ke pengguna.