Agent skill

Supabase Enterprise Rbac

by jeremylongshore in jeremylongshore/tons-of-skills-marketplace

Implement custom role-based access control via JWT claims in Supabase: appmetadata.role, RLS policies with auth.jwt() role extraction, organization-scoped access, and API key scoping.

MITAuto-check passedBackend & APIs

Install Supabase Enterprise Rbac

skills CLI
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill supabase-enterprise-rbac -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install jeremylongshore/tons-of-skills-marketplace supabase-enterprise-rbac --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/.curated/supabase-enterprise-rbac .claude/skills/supabase-enterprise-rbac && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
supabase-enterprise-rbac
GitHub stars
2.8k
Token cost
~2.2k tokens
SKILL.md length
690 words
Files
8 (incl. references)
Skills in repo
3,342
Repo updated
First seen
Licence
MIT

At a glance

Implement custom role-based access control via JWT claims in Supabase: appmetadata.role, RLS policies with auth.jwt() role extraction, organization-scoped access, and API key scoping.

  • Works in 3 steps: Define Roles via app_metadata and JWT… → RLS Policies with JWT Role Claims → API Key Scoping and Role Enforcement in…
  • Implementing role-based permissions
  • SKILL.md covers Overview, Prerequisites, Instructions and Output, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Supabase Enterprise Rbac is an agent skill from jeremylongshore/tons-of-skills-marketplace. Implement custom role-based access control via JWT claims in Supabase: appmetadata.role, RLS policies with auth.jwt() role extraction, organization-scoped access, and API key scoping. Use when implementing role-based permissions, configuring organization-level access, building admin/member/viewer hierarchies, or scoping API keys per role. Trigger with "supabase RBAC", "supabase roles", "supabase permissions", "supabase JWT claims", "supabase organization access", "supabase custom roles", "supabase appmetadata".

Its SKILL.md is about 2.2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 8 other files, including reference files (for example `references/api-scoping-and-enforcement.md`, `references/errors.md` and `references/examples.md`). Compatibility notes: Designed for Claude Code

It sits in Backend & APIs, covering Authorization and RBAC and Authentication. It works with Supabase. The repository describes itself as: Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com. The licence is MIT.

When your agent uses it

  • Implementing role-based permissions
  • Configuring organization-level access
  • Building admin/member/viewer hierarchies
  • Scoping API keys per role

Example prompts

  • “supabase RBAC”
  • “supabase roles”
  • “supabase permissions”
  • “/supabase-enterprise-rbac”

Requirements

  • Node.js
  • Compatibility (from SKILL.md): Designed for Claude Code
  • Pre-approved tools (allowed-tools): Read, Write, Edit, Bash(npx supabase:*), Bash(supabase:*), Bash(psql:*)

Workflow steps

3 steps, taken from the step headings in SKILL.md.

  1. Define Roles via app_metadata and JWT Claims
  2. RLS Policies with JWT Role Claims
  3. API Key Scoping and Role Enforcement in Application Code

What it can do on your machine

Read from SKILL.md and the folder at commit cfae287. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit
    • Bash(npx supabase:*)
    • Bash(supabase:*)
    • Bash(psql:*)

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript and sql).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • supabase.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Designed for Claude Code

    From compatibility in the SKILL.md frontmatter.

Context cost

Supabase Enterprise Rbac loads about 2.2k tokens when it runs, and up to ~6.7k if it reads all its reference files. Until then it costs about 136 tokens; SKILL.md has 690 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~136
When it runs · the whole SKILL.md, loaded when a task matches
~2.2k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~6.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from jeremylongshore/tons-of-skills-marketplace at commit cfae287, republished under its MIT licence (© jeremylongshore). 690 words, ~2,155 tokens.

Download SKILL.mdSave it as .claude/skills/supabase-enterprise-rbac/SKILL.md (or your agent's skills folder). This skill also uses 7 other files; get the full folder from GitHub.
name
supabase-enterprise-rbac
description
Implement custom role-based access control via JWT claims in Supabase: app_metadata.role, RLS policies with auth.jwt() role extraction, organization-scoped access, and API key scoping. Use when implementing role-based permissions, configuring organization-level access, building admin/member/viewer hierarchies, or scoping API keys per role. Trigger with "supabase RBAC", "supabase roles", "supabase permissions", "supabase JWT claims", "supabase organization access", "supabase custom roles", "supabase app_metadata".
allowed-tools
Read, Write, Edit, Bash(npx supabase:*), Bash(supabase:*), Bash(psql:*)
compatibility
Designed for Claude Code
version
1.54.0
license
MIT
author
Jeremy Longshore <jeremy@intentsolutions.io>
tags
saas, supabase, rbac, security, enterprise, roles, permissions

Supabase Enterprise RBAC

Overview

Supabase supports custom role-based access control (RBAC) by storing role information in app_metadata on the user's JWT, then reading those claims in RLS policies via auth.jwt() ->> 'role'. This skill implements a complete RBAC system: roles in app_metadata, RLS policies that enforce role hierarchies, organization-scoped access, role management through the Admin API, and API endpoints protected with role checks — all using real createClient from @supabase/supabase-js.

When to use: Building multi-role applications (admin/editor/viewer), implementing organization-scoped access, creating custom permission systems beyond Supabase's built-in anon/authenticated roles, or scoping API operations by user role.

Prerequisites

  • @supabase/supabase-js v2+ with service role key for admin operations
  • Understanding of JWT claims and Supabase's auth.jwt() SQL function
  • Database access via SQL Editor or psql for RLS policy creation
  • Supabase project with authentication configured

Instructions

The workflow has three steps: assign roles into the JWT, enforce them in the database with RLS, then enforce them again in application code.

Step 1: Define Roles via app_metadata and JWT Claims

Store custom roles in the user's app_metadata using the Admin API. These claims appear in every JWT the user receives and are readable in RLS policies. Assign roles with the service-role client:

typescript
// Define the role hierarchy
type AppRole = 'admin' | 'editor' | 'viewer' | 'member';

// Assign a role to a user (admin operation, service role key required)
async function setUserRole(userId: string, role: AppRole, orgId: string) {
  const { data, error } = await supabase.auth.admin.updateUserById(userId, {
    app_metadata: { role, org_id: orgId },
  });
  if (error) throw new Error(`Failed to set role: ${error.message}`);
  return data.user;
}

Read the role back in app code with supabase.auth.getUser() and compare it against a numeric hierarchy so hasRole('editor', 'viewer') is true. See role assignment and JWT extraction for the full service-role client setup, granular permissions, bulk assignTeamRoles(), getCurrentUserRole(), getCurrentOrg(), hasRole(), and the requireRole() guard.

Step 2: RLS Policies with JWT Role Claims

Write Row Level Security policies that read auth.jwt() -> 'app_metadata' ->> 'role' and ... ->> 'org_id'. Wrap the JWT extraction in helper functions so every policy stays readable:

sql
CREATE OR REPLACE FUNCTION public.get_user_role()
RETURNS text AS $$
  SELECT coalesce(auth.jwt() -> 'app_metadata' ->> 'role', 'viewer');
$$ LANGUAGE sql STABLE SECURITY DEFINER;

CREATE POLICY "editors_create_projects" ON public.projects
  FOR INSERT WITH CHECK (
    org_id = get_user_org_id()
    AND get_user_role() IN ('admin', 'editor')
  );

Policies pair an org_id = get_user_org_id() tenant check with a get_user_role() role check per operation (SELECT/INSERT/UPDATE/DELETE). See RLS policies and org-scoped schema for both helper functions, the full policy set across projects/documents/team_members, and the organizations/team_members/projects table schema with indexes.

Step 3: API Key Scoping and Role Enforcement in Application Code

Enforce roles a second time at the application layer so API routes never rely on RLS alone. See API key scoping and role enforcement for server-side withRole() middleware, per-request client creation, admin panel operations (list members, invite users, change roles), and organization management patterns.

Output

Completing this skill produces:

  • Role assignment via app_metadata — admin.updateUserById() sets role claims on user JWTs
  • JWT claim extraction — get_user_role() and get_user_org_id() SQL helper functions
  • Role-based RLS policies — SELECT/INSERT/UPDATE/DELETE scoped by role hierarchy (admin > editor > member > viewer)
  • Organization-scoped access — multi-tenant isolation via org_id in JWT claims and RLS policies
  • Application-layer enforcement — withRole() middleware for API routes with proper 401/403 responses
  • Admin panel operations — list members, invite users, change roles with both database and JWT updates
  • Role hierarchy checking — hasRole() function supporting role escalation comparison
Show full SKILL.md (242 more words)Show less

Error Handling

ErrorCauseSolution
app_metadata.role is null in JWTRole not set or user needs to re-loginCall admin.updateUserById() to set role; user must refresh their session
RLS policy returns empty resultsJWT claims don't match policy conditionsCheck auth.jwt() output in SQL Editor; verify app_metadata was set correctly
permission denied for functionHelper function not created or wrong schemaCreate get_user_role() in the public schema with SECURITY DEFINER
User role changes not reflectedJWT cached with old claimsUser must sign out and sign in again, or call supabase.auth.refreshSession()
duplicate key value violates unique constraintUser already in organizationCheck team_members table for existing entry before inserting
foreign key violation on team_membersUser or org doesn't existVerify both user_id and org_id exist before inserting membership
Role hierarchy bypassDirect database access with service roleService role bypasses RLS by design — restrict its use to server-side admin operations only

Examples

Example 1 — Quick role check in a component:

typescript
async function canEditProject(): Promise<boolean> {
  const { data: { user } } = await supabase.auth.getUser();
  const role = user?.app_metadata?.role;
  return role === 'admin' || role === 'editor';
}

Example 2 — Verify RLS policies work correctly:

sql
-- Test as an editor in org-123
SET request.jwt.claims = '{"sub": "user-uuid", "role": "authenticated", "app_metadata": {"role": "editor", "org_id": "org-123"}}';

SELECT * FROM projects;                                                    -- returns only org-123 rows
INSERT INTO projects (org_id, name, created_by) VALUES ('org-123', 'Test', 'user-uuid');  -- succeeds
DELETE FROM projects WHERE id = 'some-project-id';                          -- fails (editors cannot delete)

RESET request.jwt.claims;

For the full onboarding example (onboardOrganization() — create org, assign creator as admin, seed team_members), see role assignment reference and API scoping reference.

Resources

Next Steps

  • For database migration patterns, see supabase-migration-deep-dive
  • For security hardening and API key scoping, see supabase-security-basics
  • For data handling and GDPR compliance, see supabase-data-handling

© jeremylongshore, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 7 other files (references) in skills/.curated/supabase-enterprise-rbac of jeremylongshore/tons-of-skills-marketplace.

  • SKILL.md
  • references/api-scoping-and-enforcement.md
  • references/errors.md
  • references/examples.md
  • references/rls-policies.md
  • references/role-assignment.md
  • references/role-implementation.md
  • references/sso-integration.md

Open the folder on GitHubat commit cfae287

Compare with similar skills

Supabase Enterprise Rbac next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Supabase Enterprise Rbac compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Supabase Enterprise Rbac this skilljeremylongshore/tons-of-skills-marketplace2.8k—~2.2kAutomated safety check: PassMIT
Workosusenotra/notra260—~6.2kAutomated safety check: PassAGPL-3.0
Authaiskillstore/marketplace433—~1.6kAutomated safety check: PassNone
Supabase Development and Debuggingsupabase/agent-skills2.7k3 repos~3.6kAutomated safety check: PassMIT
Supabasecurvenote/curvenote1705 repos~2.2kAutomated safety check: PassCustom licence
Cognitoitsmostafa/aws-agent-skills1.2k1 repos~2.3kAutomated safety check: PassMIT

Similar skills

  • Workos

    usenotra/notra

    A skill your agent uses when the user asks for a WorkOS docs URL, term, or dashboard field (Sign-in endpoint, initiateloginuri, Redirect URI, WORKOS env vars), or is implementing, debugging, or…

    260 GitHub stars~6.2k tokensUpdated today
    Backend & APIsAuto-check passed
  • Auth

    aiskillstore/marketplace

    Authentication and access control skill for Next.js 15 + Supabase applications.

    433 GitHub stars~1.6k tokensUpdated yesterday
    Backend & APIsAuto-check passed
  • Official

    General Supabase skill for database, auth, Edge Functions, Realtime and storage work, plus client libraries, migrations, security audits, debugging and reading logs.

    2.7k GitHub starsUsed in 3 repos~3.6k tokens
    Backend & APIsAuto-check passed
  • Supabase

    curvenote/curvenote

    A skill your agent uses when doing ANY task involving Supabase.

    170 GitHub starsUsed in 5 repos~2.2k tokens
    Backend & APIsAuto-check passed
  • Cognito

    itsmostafa/aws-agent-skills

    AWS Cognito user authentication and authorization service. An agent skill from itsmostafa/aws-agent-skills.

    1.2k GitHub starsUsed in 1 repo~2.3k tokens
    Backend & APIsAuto-check passed
  • Auth Implementation Patterns

    ynulihao/AgentSkillOS

    Master authentication and authorization patterns including JWT, OAuth2, session management, and RBAC to build secure, scalable access control systems.

    618 GitHub starsUsed in 10 repos~4.4k tokens
    Backend & APIsAuto-check passed

More from jeremylongshore/tons-of-skills-marketplace

All 3,342 skills in this repo
  • Performing Security Code Review

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to conduct a security-focused code review using the security-agent plugin.

    2.8k GitHub starsUsed in 2 repos~1.3k tokens
    Auto-check: notes
  • Adapting Transfer Learning Models

    jeremylongshore/tons-of-skills-marketplace

    Build this skill automates the adaptation of pre-trained machine learning models using transfer learning techniques.

    2.8k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Agent Context Loader

    jeremylongshore/tons-of-skills-marketplace

    Execute proactive auto-loading: automatically detects and loads agents.md files.

    2.8k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Aggregating Performance Metrics

    jeremylongshore/tons-of-skills-marketplace

    Aggregate and centralize performance metrics from applications, systems, databases, caches, and services.

    2.8k GitHub stars~1.2k tokensUpdated today
    Auto-check passed
  • Analyzing Capacity Planning

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to analyze capacity requirements and plan for future growth.

    2.8k GitHub stars~947 tokensUpdated today
    Auto-check passed
  • Analyzing Database Indexes

    jeremylongshore/tons-of-skills-marketplace

    Process use when you need to work with database indexing. An agent skill from jeremylongshore/tons-of-skills-marketplace.

    2.8k GitHub stars~2k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about Supabase Enterprise Rbac

What does Supabase Enterprise Rbac do?

Implement custom role-based access control via JWT claims in Supabase: appmetadata.role, RLS policies with auth.jwt() role extraction, organization-scoped access, and API key scoping. Supabase Enterprise Rbac is an agent skill from jeremylongshore/tons-of-skills-marketplace.jwt() role extraction, organization-scoped access, and API key scoping.

When should I use Supabase Enterprise Rbac?

Supabase Enterprise Rbac fits situations like: implementing role-based permissions; configuring organization-level access; building admin/member/viewer hierarchies; scoping API keys per role.

How do I install Supabase Enterprise Rbac in Claude Code?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill supabase-enterprise-rbac -a claude-code`. Or copy the skill folder (skills/.curated/supabase-enterprise-rbac in jeremylongshore/tons-of-skills-marketplace) into .claude/skills/supabase-enterprise-rbac in your project. Claude Code loads it when a task matches its description.

How do I install Supabase Enterprise Rbac in Codex?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill supabase-enterprise-rbac -a codex`. Or copy the skill folder (skills/.curated/supabase-enterprise-rbac in jeremylongshore/tons-of-skills-marketplace) into .agents/skills/supabase-enterprise-rbac in your project. Codex loads it when a task matches its description.

Can I use Supabase Enterprise Rbac in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill supabase-enterprise-rbac -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/supabase-enterprise-rbac, .gemini/skills/supabase-enterprise-rbac, .github/skills/supabase-enterprise-rbac and .opencode/skills/supabase-enterprise-rbac in your project.

What does Supabase Enterprise Rbac need to run?

SKILL.md names no scripts, command-line tools or credentials: Supabase Enterprise Rbac is instructions for the agent only. Our summary lists: Node.js. Its frontmatter pre-approves these tools: Read, Write, Edit, Bash(npx supabase:*), Bash(supabase:*), Bash(psql:*). Compatibility (from SKILL.md): Designed for Claude Code.

Does Supabase Enterprise Rbac access the network?

SKILL.md names 1 domain. As links in the text: supabase.com. This is read from the text; nothing was executed.

Is Supabase Enterprise Rbac safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Supabase Enterprise Rbac use?

Supabase Enterprise Rbac is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Supabase Enterprise Rbac use?

About 2.2k tokens (SKILL.md is roughly 8.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 4.5k tokens, read only when the agent opens those files.

What are the alternatives to Supabase Enterprise Rbac?

Skills that share tags, products or a category with Supabase Enterprise Rbac: Workos (usenotra/notra, 260 stars), Auth (aiskillstore/marketplace, 433 stars), Supabase Development and Debugging (supabase/agent-skills, 2.7k stars) and Supabase (curvenote/curvenote, 170 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Supabase Enterprise Rbac?

jeremylongshore (a GitHub user) maintains it in jeremylongshore/tons-of-skills-marketplace, which has 2,827 GitHub stars. The repository holds 3,342 skills in this directory. The repository was last updated on October 10, 2026.

Source: jeremylongshore/tons-of-skills-marketplace on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.