/clerk:organization-managementfrom clerk
Implements Clerk multi-tenant organization features with RBAC, organization switching, member management, and tenant isolation. Provides scripts and templates for setup, role configuration, and data isolation.
Ships in clerk. 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; scripts run unread.
Purpose: Autonomously implement and configure Clerk organization features for multi-tenant applications with RBAC.
Activation Triggers:
Key Resources:
scripts/setup-organizations.sh - Enable and configure organizationsscripts/configure-roles.sh - Setup RBAC with custom rolesscripts/test-org-isolation.sh - Test tenant data isolationtemplates/organization-schema.md - Multi-tenant database schema patternstemplates/rbac-policies.ts - Role and permission definitionstemplates/organization-switcher.tsx - Organization switcher componentexamples/multi-tenant-app.tsx - Complete multi-tenant applicationexamples/org-admin-dashboard.tsx - Organization admin interfaceBefore implementing organization features, enable them in your Clerk Dashboard:
# Run setup script to guide through Clerk Dashboard configuration
./scripts/setup-organizations.sh
Manual steps (documented in script):
# Setup custom roles and permissions
./scripts/configure-roles.sh [basic|advanced|custom]
# Examples:
./scripts/configure-roles.sh basic # Admin + Member only
./scripts/configure-roles.sh advanced # Admin + Manager + Member + Viewer
./scripts/configure-roles.sh custom # Interactive custom role creation
Outputs:
Use templates to create organization UI:
Organization Switcher (for multi-org users):
# Copy and customize organization switcher
cp templates/organization-switcher.tsx src/components/OrganizationSwitcher.tsx
Organization Schema (for database integration):
# View multi-tenant database schema patterns
cat templates/organization-schema.md
RBAC Policies:
# Copy RBAC policy definitions
cp templates/rbac-policies.ts src/lib/rbac.ts
# Test tenant data isolation (requires project running)
./scripts/test-org-isolation.sh
# Validates:
# - Data scoped to organization_id
# - Cross-tenant data leakage prevention
# - Role-based access enforcement
# - Organization switching works correctly
Row-Level Security (RLS) Pattern:
-- Every table includes organization_id
CREATE TABLE projects (
id UUID PRIMARY KEY,
organization_id TEXT NOT NULL,
name TEXT NOT NULL,
created_at TIMESTAMP DEFAULT NOW()
);
-- RLS Policy (Supabase/Postgres)
CREATE POLICY "Users can only access their org's projects"
ON projects FOR ALL
USING (organization_id = current_setting('app.current_organization_id'));
Application-Level Scoping:
// Always filter by organization_id in queries
const projects = await db.projects.findMany({
where: {
organizationId: user.organizationId
}
});
Level 1: Basic (Admin/Member)
Level 2: Advanced (4+ roles)
Level 3: Custom (Granular permissions)
project:create, billing:manage, members:inviteSee templates/organization-switcher.tsx for complete component with:
See examples/org-admin-dashboard.tsx for:
See examples/multi-tenant-app.tsx for:
# Enable organizations + advanced RBAC
./scripts/setup-organizations.sh
./scripts/configure-roles.sh advanced
# Implement organization switcher
cp templates/organization-switcher.tsx src/components/
# Enable organizations + custom RBAC with granular permissions
./scripts/setup-organizations.sh
./scripts/configure-roles.sh custom
# Setup database isolation
# Follow templates/organization-schema.md for RLS setup
# Test isolation after implementing schema
./scripts/test-org-isolation.sh
# Validates:
# - No cross-tenant data access
# - RLS policies working correctly
# - Organization switching updates context
Middleware Protection:
// Check role in middleware
import { auth } from '@clerk/nextjs/server';
export default async function middleware(req: Request) {
const { orgRole } = await auth();
if (orgRole !== 'org:admin') {
return new Response('Forbidden', { status: 403 });
}
}
Component-Level Checks:
// Hide UI based on role
import { useOrganization } from '@clerk/nextjs';
function AdminOnlyButton() {
const { membership } = useOrganization();
if (membership?.role !== 'org:admin') return null;
return <button>Admin Action</button>;
}
Custom Permission Checks:
// Check specific permission
import { checkPermission } from '@/lib/rbac';
if (await checkPermission(user, 'billing:manage')) {
// Allow billing access
}
See templates/organization-schema.md for complete schema patterns.
// Organization-scoped queries
const projects = await prisma.project.findMany({
where: {
organizationId: user.organizationId
}
});
// Middleware to auto-inject organization_id
prisma.$use(async (params, next) => {
if (params.action === 'create') {
params.args.data.organizationId = getCurrentOrgId();
}
return next(params);
});
# .env.example (no real keys!)
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_your_clerk_key_here
CLERK_SECRET_KEY=sk_test_your_clerk_secret_here
# Organization feature flags (optional)
NEXT_PUBLIC_ENABLE_ORG_CREATION=true
NEXT_PUBLIC_MAX_ORGS_PER_USER=5
Organizations not appearing:
RBAC not working:
Data isolation failing:
Scripts: All scripts in scripts/ directory are executable and include detailed usage instructions
Templates: templates/ contains production-ready components and schema patterns
Examples: examples/ contains complete application examples with organization features
Clerk Dashboard Configuration Required: Organizations must be enabled in your Clerk Dashboard before using this skill
Framework Support: Next.js (App Router & Pages Router), React, Remix, Gatsby
Version: 1.0.0 Clerk SDK Compatibility: @clerk/nextjs 5+, @clerk/clerk-react 5+
README.md (opens in a new tab)examples/multi-tenant-app.tsx (opens in a new tab)examples/org-admin-dashboard.tsx (opens in a new tab)scripts/configure-roles.sh (opens in a new tab)scripts/setup-organizations.sh (opens in a new tab)scripts/test-org-isolation.sh (opens in a new tab)templates/organization-schema.md (opens in a new tab)templates/organization-switcher.tsx (opens in a new tab)templates/rbac-policies.ts (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
10 skills in this plugin
/api-authenticationBackend API authentication patterns with Clerk JWT middleware and route protection. Use when building REST APIs, GraphQL APIs, protecting backend routes, implementing JWT validation, setting up Express middleware, or when user mentions API authentication, backend security, JWT tokens, or protected endpoints./auth-componentsPre-built and custom Clerk authentication component templates with theming and customization patterns. Use when building authentication UI, creating sign-in/sign-up pages, customizing Clerk components, implementing user buttons, theming auth flows, or when user mentions Clerk components, SignIn, SignUp, UserButton, auth UI, appearance customization, or authentication theming./npx claudepluginhub vanman2024/ai-dev-marketplace --plugin clerkOther plugins' skills for the same job