Skip to content
v0.4.4-next · Built for AI coding agents→

Row-level securityyou can trust.

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.

Get started

One rule in TypeScript. Correct SQL in Postgres.

Write the intent. AccessNexus writes the SQL — and gets right the details that break in production.

  • ✓ENABLE + FORCE RLS: not even the table owner skips it
  • ✓(SELECT auth.uid()) is evaluated once per query, not per row
  • ✓inserts and updates are pinned with WITH CHECK
  • ✓no delete rule? The policy is dropped: deny-all
accessnexus.schema.tsTypeScript
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'),
    },
  }),
});
generated/policies/notes_rls.sqlgenerated SQL
$ npx accessnexus generate ✓
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;

Secure by default

ENABLE + FORCE RLS everywhere. No rule means deny-all. Removing a rule revokes it.

Multi-tenant RBAC

Org and team roles become policies through recursion-safe SECURITY DEFINER helpers. No self-promotion paths.

Agent-native CLI

llms.txt in the package, an AGENTS.md block, --json output, exit codes 0/1/2 and a fix hint on every error.

Validate before push

Unknown columns, open writes, impersonation and cross-tenant holes are caught before SQL reaches the database.

Fast policies

(SELECT auth.uid()) runs once per query, and policy columns are indexed for you.

Drift-checked pushes

Content-hashed migrations under an advisory lock. Edited history is refused.

Your agent already knows the rules.

init writes the contract into your project's AGENTS.md. The agent edits one schema file, validates, and ships SQL that holds.

Why AccessNexus →
agent
› 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", ... }

Stop hand-writing policies.

Start with one table. Keep every rule in one file.

Released under the MIT License.