Multi-tenant RBAC
Org and team roles become policies through recursion-safe SECURITY DEFINER helpers. No self-promotion paths.
Define tables and access rules in TypeScript. AccessNexus generates correct RLS, RBAC, migrations and a typed SDK for Supabase — in a form your coding agent can't get wrong.
Write the intent. AccessNexus writes the SQL — and gets right the details that break in production.
import { defineSchema, policy, table } from 'accessnexus';
export default defineSchema({
notes: table({
columns: { id: 'uuid', user_id: 'uuid', body: 'text' },
primaryKey: 'id',
policies: {
select: policy.isOwner('user_id'),
insert: policy.isOwner('user_id'),
update: policy.isOwner('user_id'),
},
}),
});ALTER TABLE notes ENABLE ROW LEVEL SECURITY;
ALTER TABLE notes FORCE ROW LEVEL SECURITY;
CREATE POLICY "accessnexus_notes_select"
ON notes FOR SELECT TO authenticated
USING ((SELECT auth.uid()) = user_id);
CREATE POLICY "accessnexus_notes_insert"
ON notes FOR INSERT TO authenticated
WITH CHECK ((SELECT auth.uid()) = user_id);
CREATE POLICY "accessnexus_notes_update"
ON notes FOR UPDATE TO authenticated
USING ((SELECT auth.uid()) = user_id)
WITH CHECK ((SELECT auth.uid()) = user_id);
DROP POLICY IF EXISTS "accessnexus_notes_delete" ON notes;
ENABLE + FORCE RLS everywhere. No rule means deny-all. Removing a rule revokes it.
Org and team roles become policies through recursion-safe SECURITY DEFINER helpers. No self-promotion paths.
llms.txt in the package, an AGENTS.md block, --json output, exit codes 0/1/2 and a fix hint on every error.
Unknown columns, open writes, impersonation and cross-tenant holes are caught before SQL reaches the database.
(SELECT auth.uid()) runs once per query, and policy columns are indexed for you.
Content-hashed migrations under an advisory lock. Edited history is refused.
init writes the contract into your project's AGENTS.md. The agent edits one schema file, validates, and ships SQL that holds.
Why AccessNexus →› Add a projects table: org members read, admins create and update, only the owner deletes.
reading node_modules/accessnexus/llms.txt
editing accessnexus.schema.ts
$ npx accessnexus validate --json
{ "ok": true, "summary": { "errors": 0, "warnings": 0 } }
$ npx accessnexus generate --json
{ "ok": true, "command": "generate", ... }Start with one table. Keep every rule in one file.