backend_safeguard

Backend Safeguard Protocol (Supabase + Vercel API)

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "backend_safeguard" with this command: npx skills add cityfish91159/maihouses/cityfish91159-maihouses-backend-safeguard

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.

  1. 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.

  1. 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).

  1. 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.

  1. 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?

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

read-before-edit

No summary provided by upstream source.

Repository SourceNeeds Review
General

rigorous_testing

No summary provided by upstream source.

Repository SourceNeeds Review
General

type-checker

No summary provided by upstream source.

Repository SourceNeeds Review
General

frontend_mastery

No summary provided by upstream source.

Repository SourceNeeds Review