/loxihart-engineering:administering-supabasefrom loxihart-engineering
Manages Supabase database operations for FlashFusion's production stack — schema design, Row Level Security policies, migrations, Edge Functions, and debugging. Active project: flashnframe-app (etctmappdhpjuwptdbeb). Use when the user mentions: Supabase, RLS, row level security, migration, schema, database, table, Edge Function, auth, policies, Postgres, supabase query, database admin, add a column, create a table, why is my query blocked, or any task involving the Supabase project or database structure.
Ships in loxihart-engineering. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Covers the operations that come up on every build: schema changes, RLS policies, migrations, and debugging access errors.
Active project: flashnframe-app (ID: etctmappdhpjuwptdbeb)
Deleted project oorstbwcydxwiojrsoim — do not use.
Should trigger:
Should NOT trigger:
What's the task?
├─ Create or modify a table → Section 2: Schema Design
├─ Write or debug an RLS policy → Section 3: Row Level Security
├─ Add a column or make a schema change safely → Section 4: Migrations
├─ Write or deploy an Edge Function → Section 5: Edge Functions
└─ Query returning unexpected results → Section 6: Debugging
RLS patterns in references/rls-patterns.md.
Before any admin work, confirm you're working on the correct project.
-- Verify in Supabase dashboard or via MCP:
-- Project: flashnframe-app
-- ID: etctmappdhpjuwptdbeb
-- Region: check in dashboard
The deleted project (oorstbwcydxwiojrsoim) should not appear in any
active connection. If it does, that connection needs to be rotated.
client_records, job_queue, agent_runs{table_a}_{table_b} alphabetical orderuser, order, group, schemaid uuid DEFAULT gen_random_uuid() PRIMARY KEY,
created_at timestamptz DEFAULT now() NOT NULL,
updated_at timestamptz DEFAULT now() NOT NULL
Add a trigger for updated_at auto-update:
CREATE OR REPLACE FUNCTION update_updated_at()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = now();
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER set_updated_at
BEFORE UPDATE ON your_table_name
FOR EACH ROW EXECUTE FUNCTION update_updated_at();
When a table should be owned by a user:
user_id uuid REFERENCES auth.users(id) ON DELETE CASCADE NOT NULL
Always reference auth.users, not a custom users table.
ON DELETE CASCADE removes the row when the user is deleted.
The most common source of bugs in every Supabase project.
-- Step 1: Enable RLS on the table (required before any policy works)
ALTER TABLE your_table ENABLE ROW LEVEL SECURITY;
-- Step 2: Create at least one policy (without a policy, ALL access is blocked)
Skipping either step causes silent failure. A table with RLS enabled and no policies returns zero rows for every query — no error, just empty results.
Full patterns and explanations in references/rls-patterns.md.
Quick reference:
-- Public read (anonymous + authenticated)
CREATE POLICY "public_read" ON your_table
FOR SELECT USING (true);
-- Authenticated users only
CREATE POLICY "auth_only" ON your_table
FOR ALL USING (auth.role() = 'authenticated');
-- Owner only (user owns the row)
CREATE POLICY "owner_only" ON your_table
FOR ALL USING (auth.uid() = user_id);
-- Service role bypass: use service_role key in server-side code —
-- it bypasses RLS entirely. Never expose the service_role key client-side.
Index every column used in a RLS policy on tables over ~10,000 rows. Without this, every row requires a sequential scan — a table scan per query.
CREATE INDEX idx_your_table_user_id ON your_table(user_id);
Use Supabase migration files. Never modify schema directly in production without a migration file — you lose the change history and reproducibility.
# Create a new migration
supabase migration new add_status_to_jobs
# Edit the generated file in supabase/migrations/
# Run locally first
supabase db reset
# Push to remote
supabase db push
Adding a column to an existing table with data:
-- Step 1: Add as nullable (no constraint — safe for existing rows)
ALTER TABLE jobs ADD COLUMN status text;
-- Step 2: Backfill existing rows
UPDATE jobs SET status = 'pending' WHERE status IS NULL;
-- Step 3: Add NOT NULL constraint (only after backfill is complete)
ALTER TABLE jobs ALTER COLUMN status SET NOT NULL;
ALTER TABLE jobs ALTER COLUMN status SET DEFAULT 'pending';
Never add a NOT NULL column without a default in a single operation on a table with existing rows. It will fail.
Before dropping a column or table:
Edge Functions are TypeScript functions that run server-side, useful for:
# Create a new function
supabase functions new function-name
# Serve locally for testing
supabase functions serve
# Deploy
supabase functions deploy function-name
Environment variables: never hardcode secrets in Edge Functions.
Use Deno.env.get('SECRET_NAME') and store in Supabase secrets:
supabase secrets set SECRET_NAME=value
-- Check if RLS is enabled
SELECT tablename, rowsecurity
FROM pg_tables
WHERE schemaname = 'public';
-- Check existing policies
SELECT * FROM pg_policies WHERE tablename = 'your_table';
-- Test as authenticated user (in SQL editor, set the role)
SET LOCAL role = authenticated;
SET LOCAL request.jwt.claims = '{"sub": "user-uuid-here"}';
SELECT * FROM your_table;
permission denied for table → RLS policy denying access, or table not
granted to the rolenew row violates row-level security policy → INSERT policy is blockingThis happens in server-side code using the anon key. Switch to:
Before any schema change in production:
What SKILL.md sets; muted values are Claude Code's defaults
22 skills in this plugin
/auditing-logicAudits code for logical errors before they become bugs — control flow gaps, data contract violations, schema/type drift, business logic inconsistencies, and silent failure paths. Produces a severity-rated issue list with a one-line diagnosis and one-line fix per finding. Use this skill whenever code is pasted with a review request, or when the user says "audit this", "check the logic", "does this make sense", "any issues with this", "logic audit", "what's wrong here", "review this function", "is this correct", or hands you any code file and wants a critical eye. Even if the user does not say "logic" — if code is present and they want feedback, use this skill. Also triggers on: "find the bug", "something feels off", "is this right", "sanity check this", "does this hold", "validate my logic", "code review", "PR review", "review this PR".
/code-auditorPerforms comprehensive codebase analysis covering architecture, code quality, security, performance, testing, and maintainability. Use when user wants to audit code quality, identify technical debt, find security issues, assess test coverage, or get a codebase health check./code-transferTransfer code between files with line-based precision. Use when users request copying code from one location to another, moving functions or classes between files, extracting code blocks, or inserting code at specific line numbers.npx claudepluginhub krosebrook/loxihart-skills --plugin loxihart-engineering