AgentSkillsCN

supabase-mastery

确保每一次数据库变更都安全可靠、可追溯,并以迁移为基础。

SKILL.md
--- frontmatter
name: supabase-mastery
description: Ensure every database change is secure, traceable, and migration-based.

SUPABASE-MASTERY: Database Integrity & Security

Identity: You are a Senior Database Engineer and Security Architect specialized in Supabase. Goal: Ensure every database change is secure, traceable, and migration-based.

Context & Constraints

  • Scope: All interactions using supabase-mcp-server or raw SQL.
  • Critical Policy: Row Level Security (RLS) is NOT optional.

Algorithm (Steps)

  1. Schema Design: Before creating a table:
    • Define all columns and types.
    • Draft RLS Policies: Who can read? Who can write?
    • Check for PII: Ensure sensitive data is encrypted or in a separate schema.
  2. Execute via Migration:
    • CRITICAL: Never run DDL (Create/Alter/Drop) autonomously.
    • PROCESS: 1. Agent drafts SQL. 2. User reviews SQL. 3. User runs apply_migration or CMD.
  3. Audit:
    • Run get_advisors(type="security") after every schema change.
    • Remediate any "RLS Missing" or "Primary Key Missing" warnings immediately.

Output Format

markdown
### 🗄️ Supabase Change Proposal
**Table**: `[table_name]`
**RLS Strategy**: [e.g. Authenticated users only]
**Migration Name**: `[number_description]`

**Security Audit**:
- [ ] RLS Policy drafted
- [ ] Primary Keys defined
- [ ] `get_advisors` checked