スキル一覧に戻る
cityfish91159

backend-safeguard

by cityfish91159

0🍴 0📅 2026年1月24日
GitHubで見るManusで実行

SKILL.md


name: backend_safeguard description: Supabase schema validation, RLS enforcement, and API security best practices. allowed-tools: Read, Edit, Write

Backend Safeguard Protocol (Supabase + Vercel API)

1. Database Schema & Migration Safety

  • Migrations:
    • NEVER edit a previous migration. Always create a new one.
    • Migration files must be numbered/timestamped sequentially.
    • Destructive changes (DROP COLUMN) require explicit user confirmation.
  • Supabase Specifics:
    • Use pg_jsonschema (if available) or CHECK constraints for complex JSON data.
    • Indexes: Ensure Foreign Keys have indices if used in JOINs frequentyl.

2. RLS (Row Level Security) "Ironclad" Rules

  • Enablement: ALTER TABLE "table_name" ENABLE ROW LEVEL SECURITY; is MANDATORY.
  • Policies:
    • Must have separate policies for SELECT, INSERT, UPDATE, DELETE (unless absolutely identical).
    • auth.uid() MUST be checked for user-specific data.
    • service_role usage in client is FORBIDDEN.

3. API Design & Security

  • Input Validation (Zod):
    • ALL API routes must parse body/query with Zod.
    • strict() mode recommended to strip unknown fields.
  • Error Handling:
    • Return standardized error structure: { error: string, code: string, details?: any }.
    • NEVER leak Stack Traces to production response.
    • Use 4xx for client errors, 5xx for server errors.
  • Rate Limiting:
    • Ensure sensitive endpoints (auth, email) have rate limiting (Upstash/KV).

4. Code Structure (Vercel Functions)

  • Separation of Concerns:
    • api/xxx.ts -> Controller (Parse Req, Check Auth)
    • src/services/xxx.ts -> Business Logic
    • src/data/xxx.ts -> Database Logic (Supabase calls)
  • Secrets:
    • Check for process.env.XXX. NEVER hardcode strings.

5. Audit Checklist

  • Is RLS enabled on all touched tables?
  • Is Zod validation wrapping the request?
  • Is logging present for state changes?
  • Are we leaking sensitive user data in the response?

スコア

総合スコア

50/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です