Claude-skill-registry backend_safeguard
Supabase schema validation, RLS enforcement, and API security best practices.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/backend-safeguard-cityfish91159-maihouses" ~/.claude/skills/majiayu000-claude-skill-registry-backend-safeguard && rm -rf "$T"
manifest:
skills/data/backend-safeguard-cityfish91159-maihouses/SKILL.mdsource content
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
(if available) orpg_jsonschema
constraints for complex JSON data.CHECK - Indexes: Ensure Foreign Keys have indices if used in JOINs frequentyl.
- Use
2. RLS (Row Level Security) "Ironclad" Rules
- Enablement:
is MANDATORY.ALTER TABLE "table_name" ENABLE ROW LEVEL SECURITY; - Policies:
- Must have separate policies for SELECT, INSERT, UPDATE, DELETE (unless absolutely identical).
MUST be checked for user-specific data.auth.uid()
usage in client is FORBIDDEN.service_role
3. API Design & Security
- Input Validation (Zod):
- ALL API routes must parse body/query with
.Zod
mode recommended to strip unknown fields.strict()
- ALL API routes must parse body/query with
- 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.
- Return standardized error structure:
- Rate Limiting:
- Ensure sensitive endpoints (auth, email) have rate limiting (Upstash/KV).
4. Code Structure (Vercel Functions)
- Separation of Concerns:
-> Controller (Parse Req, Check Auth)api/xxx.ts
-> Business Logicsrc/services/xxx.ts
-> Database Logic (Supabase calls)src/data/xxx.ts
- Secrets:
- Check for
. NEVER hardcode strings.process.env.XXX
- Check for
5. Audit Checklist
- Is RLS enabled on all touched tables?
- Is
validation wrapping the request?Zod - Is logging present for state changes?
- Are we leaking sensitive user data in the response?