organization-best-practices

Implements multi-tenant organizations, teams, and role-based access control using Better Auth's organization plugin.

Updated Jul 21, 2026
One-click install
npx skills add https://github.com/masakinihirota/2026src-ni --skill organization-best-practices-masakinihirota
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: organization-best-practices
Source: https://github.com/masakinihirota/2026src-ni/tree/main/.agents/skills/organization-best-practices
Command: npx skills add https://github.com/masakinihirota/2026src-ni --skill organization-best-practices-masakinihirota

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires better-auth, @better-auth/cli, @better-auth/organization.

What problem does it solve? Building multi-tenant applications requires complex logic for organizations, memberships, invitations, teams, and role-based permissions. This Skill provides guidance and enforcement rules for implementing all of these features correctly with Better Auth's organization plugin, avoiding common security pitfalls like removing the last owner. ## Core Features & Use Cases - Organization & Member Management: Create organizations, set active organizations, add or remove members, and assign multiple roles with configurable limits. - Invitations & Teams: Send invitation emails, generate shareable invitation URLs, and group members into teams with per-team limits. - RBAC & Dynamic Access Control: Use built-in owner/admin/member roles, check permissions client- or server-side, and create custom roles at runtime. - Use Case: You are building a SaaS dashboard where companies sign up, invite employees, and organize them into teams with different permission levels. This Skill guides the full Better Auth organization plugin setup, including hooks, schema customization, and security rules. ## Quick Start Set up Better Auth's organization plugin with teams, invitations, and role-based access control for my multi-tenant app.

Frequently Asked Questions about organization-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up organizations with Better Auth?▼

Add the organization plugin to your betterAuth config with options like allowUserToCreateOrganization, organizationLimit, and membershipLimit, then run npx @better-auth/cli migrate to create the required database tables. Add organizationClient to your client for frontend access.

How do I send organization invitation emails in Better Auth?▼

Configure the sendInvitationEmail callback in the organization plugin options, which receives the email, organization, inviter, and invitation data. Call authClient.organization.inviteMember with the email and role to trigger it.

Does Better Auth support custom roles and dynamic access control?▼

Yes, enable dynamicAccessControl in the organization plugin to create custom roles at runtime with createRole, updateRole, and deleteRole. Pre-defined roles like owner, admin, and member cannot be deleted.

Why can't I remove a member from an organization?▼

The last owner cannot be removed from an organization in Better Auth. You must first transfer ownership by assigning the owner role to another member with updateMemberRole, then remove or demote the previous owner.

How do I check user permissions on the client side?▼

Use authClient.organization.checkRolePermission for static role checks in UI rendering. For dynamic access control, use the hasPermission endpoint instead, since client-side checks do not work with runtime-defined roles.