Supabase Patterns
Skill Profile
(Select at least one profile to enable specific modules)
Overview
Supabase is an open-source Firebase alternative that uses PostgreSQL as its core database. It offers a complete feature set including Authentication, Realtime subscriptions, Storage, Edge Functions, and Vector embeddings for AI applications.
Why This Matters
Supabase is critical because:
- PostgreSQL Power: Full SQL with joins, transactions, and extensions
- Open Source: Self-hostable, no vendor lock-in
- Real-time Built-in: Subscriptions and presence
- Row Level Security: Fine-grained access control
- AI Ready: Built-in vector embeddings for RAG
- Developer Experience: Built-in dashboard and tools
- Edge Functions: Serverless compute at the edge
Core Concepts & Rules
1. Core Principles
- Follow established patterns and conventions
- Maintain consistency across codebase
- Document decisions and trade-offs
2. Implementation Guidelines
- Start with the simplest viable solution
- Iterate based on feedback and requirements
- Test thoroughly before deployment
Inputs / Outputs / Contracts
Inputs:
- Supabase project URL
- API keys (anon, service_role)
- Database queries
- Authentication credentials
- Storage files
- Function code
Outputs:
- Query results with TypeScript types
- Authentication tokens
- Storage URLs
- Function execution results
- Vector search results
Contracts:
- API keys must be secured properly
- RLS policies must be enforced
- Storage uploads must have size limits
- Functions must be idempotent
- Queries must use proper indexes
Skill Composition
- Depends on: None
- Compatible with: None
- Conflicts with: None
- Related Skills: None
Quick Start / Implementation Example
- Review requirements and constraints
- Set up development environment
- Implement core functionality following patterns
- Write tests for critical paths
- Run tests and fix issues
- Document any deviations or decisions
# Example implementation following best practices
def example_function():
# Your implementation here
pass
Assumptions / Constraints / Non-goals
- Assumptions:
- Development environment is properly configured
- Required dependencies are available
- Team has basic understanding of domain
- Constraints:
- Must follow existing codebase conventions
- Time and resource limitations
- Compatibility requirements
- Non-goals:
- This skill does not cover edge cases outside scope
- Not a replacement for formal training
Compatibility & Prerequisites
- Supported Versions:
- Python 3.8+
- Node.js 16+
- Modern browsers (Chrome, Firefox, Safari, Edge)
- Required AI Tools:
- Code editor (VS Code recommended)
- Testing framework appropriate for language
- Version control (Git)
- Dependencies:
- Language-specific package manager
- Build tools
- Testing libraries
- Environment Setup:
.env.example keys: API_KEY, DATABASE_URL (no values)
Test Scenario Matrix (QA Strategy)
| Type |
Focus Area |
Required Scenarios / Mocks |
| Unit |
Core Logic |
Must cover primary logic and at least 3 edge/error cases. Target minimum 80% coverage |
| Integration |
DB / API |
All external API calls or database connections must be mocked during unit tests |
| E2E |
User Journey |
Critical user flows to test |
| Performance |
Latency / Load |
Benchmark requirements |
| Security |
Vuln / Auth |
SAST/DAST or dependency audit |
| Frontend |
UX / A11y |
Accessibility checklist (WCAG), Performance Budget (Lighthouse score) |
Technical Guardrails & Security Threat Model
1. Security & Privacy (Threat Model)
- Top Threats: Injection attacks, authentication bypass, data exposure
2. Performance & Resources
3. Architecture & Scalability
4. Observability & Reliability
Agent Directives & Error Recovery
(ข้อกำหนดสำหรับ AI Agent ในการคิดและแก้ปัญหาเมื่อเกิดข้อผิดพลาด)
- Thinking Process: Analyze root cause before fixing. Do not brute-force.
- Fallback Strategy: Stop after 3 failed test attempts. Output root cause and ask for human intervention/clarification.
- Self-Review: Check against Guardrails & Anti-patterns before finalizing.
- Output Constraints: Output ONLY the modified code block. Do not explain unless asked.
Definition of Done (DoD) Checklist
Anti-patterns / Pitfalls
- ⛔ Don't: Log PII, catch-all exception, N+1 queries
- ⚠️ Watch out for: Common symptoms and quick fixes
- 💡 Instead: Use proper error handling, pagination, and logging
Reference Links & Examples
- Internal documentation and examples
- Official documentation and best practices
- Community resources and discussions
Versioning & Changelog
- Version: 1.0.0
- Changelog:
- 2026-02-22: Initial version with complete template structure
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: supabase-patterns3description: Supabase is an open-source Firebase alternative that uses PostgreSQL Use when this capability is needed.4---56# Supabase Patterns78## Skill Profile9*(Select at least one profile to enable specific modules)*10- [ ] **DevOps**11- [x] **Backend**12- [ ] **Frontend**13- [ ] **AI-RAG**14- [ ] **Security Critical**1516## Overview17Supabase is an open-source Firebase alternative that uses PostgreSQL as its core database. It offers a complete feature set including Authentication, Realtime subscriptions, Storage, Edge Functions, and Vector embeddings for AI applications.1819## Why This Matters20Supabase is critical because:21- **PostgreSQL Power**: Full SQL with joins, transactions, and extensions22- **Open Source**: Self-hostable, no vendor lock-in23- **Real-time Built-in**: Subscriptions and presence24- **Row Level Security**: Fine-grained access control25- **AI Ready**: Built-in vector embeddings for RAG26- **Developer Experience**: Built-in dashboard and tools27- **Edge Functions**: Serverless compute at the edge2829## Core Concepts & Rules3031### 1. Core Principles32- Follow established patterns and conventions33- Maintain consistency across codebase34- Document decisions and trade-offs3536### 2. Implementation Guidelines37- Start with the simplest viable solution38- Iterate based on feedback and requirements39- Test thoroughly before deployment404142## Inputs / Outputs / Contracts43**Inputs:**44- Supabase project URL45- API keys (anon, service_role)46- Database queries47- Authentication credentials48- Storage files49- Function code5051**Outputs:**52- Query results with TypeScript types53- Authentication tokens54- Storage URLs55- Function execution results56- Vector search results5758**Contracts:**59- API keys must be secured properly60- RLS policies must be enforced61- Storage uploads must have size limits62- Functions must be idempotent63- Queries must use proper indexes6465## Skill Composition66* **Depends on**: None67* **Compatible with**: None68* **Conflicts with**: None69* **Related Skills**: None7071## Quick Start / Implementation Example72731. Review requirements and constraints742. Set up development environment753. Implement core functionality following patterns764. Write tests for critical paths775. Run tests and fix issues786. Document any deviations or decisions7980```python81# Example implementation following best practices82def example_function():83 # Your implementation here84 pass85```868788## Assumptions / Constraints / Non-goals8990* **Assumptions**:91 - Development environment is properly configured92 - Required dependencies are available93 - Team has basic understanding of domain94* **Constraints**:95 - Must follow existing codebase conventions96 - Time and resource limitations97 - Compatibility requirements98* **Non-goals**:99 - This skill does not cover edge cases outside scope100 - Not a replacement for formal training101102103## Compatibility & Prerequisites104105* **Supported Versions**:106 - Python 3.8+107 - Node.js 16+108 - Modern browsers (Chrome, Firefox, Safari, Edge)109* **Required AI Tools**:110 - Code editor (VS Code recommended)111 - Testing framework appropriate for language112 - Version control (Git)113* **Dependencies**:114 - Language-specific package manager115 - Build tools116 - Testing libraries117* **Environment Setup**:118 - `.env.example` keys: `API_KEY`, `DATABASE_URL` (no values)119120121## Test Scenario Matrix (QA Strategy)122123| Type | Focus Area | Required Scenarios / Mocks |124| :--- | :--- | :--- |125| **Unit** | Core Logic | Must cover primary logic and at least 3 edge/error cases. Target minimum 80% coverage |126| **Integration** | DB / API | All external API calls or database connections must be mocked during unit tests |127| **E2E** | User Journey | Critical user flows to test |128| **Performance** | Latency / Load | Benchmark requirements |129| **Security** | Vuln / Auth | SAST/DAST or dependency audit |130| **Frontend** | UX / A11y | Accessibility checklist (WCAG), Performance Budget (Lighthouse score) |131132133## Technical Guardrails & Security Threat Model134135### 1. Security & Privacy (Threat Model)136* **Top Threats**: Injection attacks, authentication bypass, data exposure137- [ ] **Data Handling**: Sanitize all user inputs to prevent Injection attacks. Never log raw PII138- [ ] **Secrets Management**: No hardcoded API keys. Use Env Vars/Secrets Manager139- [ ] **Authorization**: Validate user permissions before state changes140141### 2. Performance & Resources142- [ ] **Execution Efficiency**: Consider time complexity for algorithms143- [ ] **Memory Management**: Use streams/pagination for large data144- [ ] **Resource Cleanup**: Close DB connections/file handlers in finally blocks145146### 3. Architecture & Scalability147- [ ] **Design Pattern**: Follow SOLID principles, use Dependency Injection148- [ ] **Modularity**: Decouple logic from UI/Frameworks149150### 4. Observability & Reliability151- [ ] **Logging Standards**: Structured JSON, include trace IDs `request_id`152- [ ] **Metrics**: Track `error_rate`, `latency`, `queue_depth`153- [ ] **Error Handling**: Standardized error codes, no bare except154- [ ] **Observability Artifacts**:155 - **Log Fields**: timestamp, level, message, request_id156 - **Metrics**: request_count, error_count, response_time157 - **Dashboards/Alerts**: High Error Rate > 5%158159160## Agent Directives & Error Recovery161*(ข้อกำหนดสำหรับ AI Agent ในการคิดและแก้ปัญหาเมื่อเกิดข้อผิดพลาด)*162163- **Thinking Process**: Analyze root cause before fixing. Do not brute-force.164- **Fallback Strategy**: Stop after 3 failed test attempts. Output root cause and ask for human intervention/clarification.165- **Self-Review**: Check against Guardrails & Anti-patterns before finalizing.166- **Output Constraints**: Output ONLY the modified code block. Do not explain unless asked.167168169## Definition of Done (DoD) Checklist170171- [ ] Tests passed + coverage met172- [ ] Lint/Typecheck passed173- [ ] Logging/Metrics/Trace implemented174- [ ] Security checks passed175- [ ] Documentation/Changelog updated176- [ ] Accessibility/Performance requirements met (if frontend)177178179## Anti-patterns / Pitfalls180181* ⛔ **Don't**: Log PII, catch-all exception, N+1 queries182* ⚠️ **Watch out for**: Common symptoms and quick fixes183* 💡 **Instead**: Use proper error handling, pagination, and logging184185186## Reference Links & Examples187188* Internal documentation and examples189* Official documentation and best practices190* Community resources and discussions191192193## Versioning & Changelog194195* **Version**: 1.0.0196* **Changelog**:197 - 2026-02-22: Initial version with complete template structure198199---200> Converted and distributed by [TomeVault](https://tomevault.io/claim/amnadtaowsoam) — claim your Tome and manage your conversions.201<!-- tomevault:4.0:skill_md:2026-04-13 -->