backend_safeguard
π―Skillfrom cityfish91159/maihouses
Validates and sanitizes backend API inputs, preventing injection attacks and ensuring robust data integrity across server-side endpoints
Installation
npx skills add https://github.com/cityfish91159/maihouses --skill backend_safeguardSkill Details
Supabase schema validation, RLS enforcement, and API security best practices.
Overview
# 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
Zodvalidation wrapping the request? - [ ] Is logging present for state changes?
- [ ] Are we leaking sensitive user data in the response?
More from this repository10
Enforces architectural best practices by guiding developers to think systematically about data flow, component boundaries, and scalability before writing code.
Enforces comprehensive testing by mandating tests for every code change, bug fix, and new feature implementation.
read-before-edit skill from cityfish91159/maihouses
Enforces strict Row Level Security (RLS) policies in Supabase, mandating default-deny access and comprehensive security checks.
Validates TypeScript/React code quality for maihouses projects, ensuring adherence to CLAUDE.md standards through comprehensive automated checks.
Checks and fixes TypeScript type errors by identifying, analyzing, and resolving type mismatches across project files.
Enforces strict React performance guidelines by policing re-renders, optimizing bundle size, and preventing performance bottlenecks.
Maintains a persistent memory file to track project context, architecture, issues, and operational rules across AI agent sessions.
pre-commit-validator skill from cityfish91159/maihouses
skill-marketplace skill from cityfish91159/maihouses