Stopping AI from Generating USING (true): Bulletproof PostgreSQL RLS Shield
The Catastrophic "USING (true)" Hallucination
When asking AI to "fix permissions on my Supabase table", models routinely hallucinate the most dangerous SQL statement in web development:
-- ❌ CATASTROPHIC SECURITY VULNERABILITY GENERATED BY DEFAULT AI:
CREATE POLICY "Enable read access for all users"
ON user_billing_profiles FOR SELECT
USING (true); -- ❌ THIS EXPOSES ALL USERS' PRIVATE BILLING PROFILES PUBLICLY!Strict Zero-Slop Postgres Constraints
Our `.windsurfrules` and `.cursorrules` database guards mandate: 1. Every table must execute `ALTER TABLE table_name ENABLE ROW LEVEL SECURITY;`. 2. Policies MUST check `auth.uid() = user_id` or organization tenant IDs. 3. Every foreign key constraint MUST have a corresponding btree index to prevent cascade lock contention during concurrent updates.
-- ✔ BULLETPROOF RLS PATTERN ENFORCED BY FCKAISLOP:
ALTER TABLE user_billing_profiles ENABLE ROW LEVEL SECURITY;CREATE POLICY "Users can only access own billing data" ON user_billing_profiles FOR ALL TO authenticated USING (auth.uid() = user_id) WITH CHECK (auth.uid() = user_id);
CREATE INDEX idx_billing_user_id ON user_billing_profiles(user_id); ```
Get The Full Production Vault
All 8 production suites (.cursorrules, CLAUDE.md, .windsurfrules) for $19.