[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6P82WJE1J87VK065SE092WV":3,"skill-same:01M6P82WJE1J87VK065SE092WV":65},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":44,"commitSha":45,"skillDirectory":46,"forksCount":14,"repositoryHtmlUrl":47,"repositoryHomepageUrl":6,"ownerHtmlUrl":48,"ownerBlogUrl":6,"ownerDescription":49,"updatedAt":50,"install":51,"resources":64},"01M6P82WJE1J87VK065SE092WV","organization-best-practices",null,"Guidance and enforcement rules for Better Auth's organization plugin. USE FOR: implement multi-tenant organizations teams and role-based access control with Better Auth, model team membership and roles inside each organization, advise on Better Auth organization-plugin team and role structure without changing code. DO NOT USE FOR: generic roles for an auth provider that does not use Better Auth's organization plugin, unrelated authentication providers.","sarthchawla\u002FSetupMyAI","sarthchawla","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F41484686?v=4","01M6P7D22NFMY9MA11Q2YGPKV2","Sarthak Chawla","01M6P7D26JJ9KW98SD1G8BB83R",0,"MIT","https:\u002F\u002Fgithub.com\u002Fsarthchawla\u002FSetupMyAI\u002Fblob\u002Fmain\u002Fpackages\u002Freact-frontend\u002Fskills\u002Forganization-best-practices\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"best practices","organization best practices","organization","use","tenant","advise","for","organizations","Access Control","do","provider","enforcement","auth","Rules","model","access","team","authentication","code","teams","2026-11-10 10:12:30",false,"---\nname: organization-best-practices\ndescription: >-\n  Guidance and enforcement rules for Better Auth's organization plugin.\n  USE FOR: implement multi-tenant organizations teams and role-based access\n  control with Better Auth, model team membership and roles inside each\n  organization, advise on Better Auth organization-plugin team and role\n  structure without changing code. DO NOT USE FOR: generic roles for an auth\n  provider that does not use Better Auth's organization plugin, unrelated\n  authentication providers.\n---\n\n## Setting Up Organizations\n\nWhen adding organizations to your application, configure the `organization` plugin with appropriate limits and permissions.\n\n```ts\nimport { betterAuth } from \"better-auth\";\nimport { organization } from \"better-auth\u002Fplugins\";\n\nexport const auth = betterAuth({\n  plugins: [\n    organization({\n      allowUserToCreateOrganization: true,\n      organizationLimit: 5, \u002F\u002F Max orgs per user\n      membershipLimit: 100, \u002F\u002F Max members per org\n    }),\n  ],\n});\n```\n\n**Note**: After adding the plugin, run `npx @better-auth\u002Fcli migrate` to add the required database tables.\n\n### Client-Side Setup\n\nAdd the client plugin to access organization methods:\n\n```ts\nimport { createAuthClient } from \"better-auth\u002Fclient\";\nimport { organizationClient } from \"better-auth\u002Fclient\u002Fplugins\";\n\nexport const authClient = createAuthClient({\n  plugins: [organizationClient()],\n});\n```\n\n## Creating Organizations\n\nOrganizations are the top-level entity for grouping users. When created, the creator is automatically assigned the `owner` role.\n\n```ts\nconst createOrg = async () => {\n  const { data, error } = await authClient.organization.create({\n    name: \"My Company\",\n    slug: \"my-company\",\n    logo: \"https:\u002F\u002Fexample.com\u002Flogo.png\",\n    metadata: { plan: \"pro\" },\n  });\n};\n```\n\n### Controlling Organization Creation\n\nRestrict who can create organizations based on user attributes:\n\n```ts\norganization({\n  allowUserToCreateOrganization: async (user) => {\n    return user.emailVerified === true;\n  },\n  organizationLimit: async (user) => {\n    return user.plan === \"premium\" ? 20 : 3;\n  },\n});\n```\n\n## Active Organizations\n\nThe active organization is stored in the session and scopes subsequent API calls. Always set an active organization after the user selects one.\n\n```ts\nconst setActive = async (organizationId: string) => {\n  const { data, error } = await authClient.organization.setActive({\n    organizationId,\n  });\n};\n```\n\n## Members\n\nMembers are users who belong to an organization. Each member has a role that determines their permissions.\n\n### Adding Members (Server-Side)\n\n```ts\nawait auth.api.addMember({\n  body: {\n    userId: \"user-id\",\n    role: \"member\",\n    organizationId: \"org-id\",\n  },\n});\n```\n\n### Removing Members\n\n```ts\nawait authClient.organization.removeMember({\n  memberIdOrEmail: \"user@example.com\",\n});\n```\n\n**Important**: The last owner cannot be removed. Assign the owner role to another member first.\n\n## Invitations\n\nThe invitation system allows admins to invite users via email. Configure email sending to enable invitations.\n\n```ts\norganization({\n  sendInvitationEmail: async (data) => {\n    const { email, organization, inviter, invitation } = data;\n    await sendEmail({\n      to: email,\n      subject: `Join ${organization.name}`,\n      html: `\u003Ca href=\"https:\u002F\u002Fyourapp.com\u002Faccept-invite?id=${invitation.id}\">Accept\u003C\u002Fa>`,\n    });\n  },\n});\n```\n\n## Roles & Permissions\n\nThe plugin provides role-based access control (RBAC) with three default roles:\n\n| Role | Description |\n|------|-------------|\n| `owner` | Full access, can delete organization |\n| `admin` | Can manage members, invitations, settings |\n| `member` | Basic access to organization resources |\n\n### Checking Permissions\n\n```ts\nconst { data } = await authClient.organization.hasPermission({\n  permission: \"member:write\",\n});\n\nif (data?.hasPermission) {\n  \u002F\u002F User can manage members\n}\n```\n\n## Teams\n\nTeams allow grouping members within an organization.\n\n### Enabling Teams\n\n```ts\norganization({\n  teams: {\n    enabled: true,\n  },\n});\n```\n\n### Creating and Managing Teams\n\n```ts\nconst { data } = await authClient.organization.createTeam({\n  name: \"Engineering\",\n});\n\nawait authClient.organization.addTeamMember({\n  teamId: \"team-id\",\n  userId: \"user-id\",\n});\n```\n\n## Dynamic Access Control\n\nFor applications needing custom roles per organization at runtime:\n\n```ts\norganization({\n  dynamicAccessControl: {\n    enabled: true,\n  },\n});\n\nawait authClient.organization.createRole({\n  role: \"moderator\",\n  permission: {\n    member: [\"read\"],\n    invitation: [\"read\"],\n  },\n});\n```\n\n## Lifecycle Hooks\n\nExecute custom logic at various points in the organization lifecycle:\n\n```ts\norganization({\n  hooks: {\n    organization: {\n      afterCreate: async ({ organization, member }) => {\n        await createDefaultResources(organization.id);\n      },\n    },\n    member: {\n      afterCreate: async ({ member, organization }) => {\n        await notifyAdmins(organization.id, `New member joined`);\n      },\n    },\n  },\n});\n```\n\n## Schema Customization\n\nCustomize table names, field names, and add additional fields:\n\n```ts\norganization({\n  schema: {\n    organization: {\n      modelName: \"workspace\",\n      additionalFields: {\n        billingId: { type: \"string\", required: false },\n      },\n    },\n    member: {\n      additionalFields: {\n        department: { type: \"string\", required: false },\n      },\n    },\n  },\n});\n```\n\n## Security Considerations\n\n### Owner Protection\n\n- The last owner cannot be removed from an organization\n- The last owner cannot leave the organization\n- Always ensure ownership transfer before removing the current owner\n\n### Organization Deletion\n\nDeleting an organization removes all associated data. Prevent accidental deletion:\n\n```ts\norganization({\n  disableOrganizationDeletion: true,\n});\n```\n\n### Invitation Security\n\n- Invitations expire after 48 hours by default\n- Only the invited email address can accept an invitation\n- Pending invitations can be cancelled by organization admins\n","## Setting Up Organizations\n\nWhen adding organizations to your application, configure the `organization` plugin with appropriate limits and permissions.\n\n```ts\nimport { betterAuth } from \"better-auth\";\nimport { organization } from \"better-auth\u002Fplugins\";\n\nexport const auth = betterAuth({\n  plugins: [\n    organization({\n      allowUserToCreateOrganization: true,\n      organizationLimit: 5, \u002F\u002F Max orgs per user\n      membershipLimit: 100, \u002F\u002F Max members per org\n    }),\n  ],\n});\n```\n\n**Note**: After adding the plugin, run `npx @better-auth\u002Fcli migrate` to add the required database tables.\n\n### Client-Side Setup\n\nAdd the client plugin to access organization methods:\n\n```ts\nimport { createAuthClient } from \"better-auth\u002Fclient\";\nimport { organizationClient } from \"better-auth\u002Fclient\u002Fplugins\";\n\nexport const authClient = createAuthClient({\n  plugins: [organizationClient()],\n});\n```\n\n## Creating Organizations\n\nOrganizations are the top-level entity for grouping users. When created, the creator is automatically assigned the `owner` role.\n\n```ts\nconst createOrg = async () => {\n  const { data, error } = await authClient.organization.create({\n    name: \"My Company\",\n    slug: \"my-company\",\n    logo: \"https:\u002F\u002Fexample.com\u002Flogo.png\",\n    metadata: { plan: \"pro\" },\n  });\n};\n```\n\n### Controlling Organization Creation\n\nRestrict who can create organizations based on user attributes:\n\n```ts\norganization({\n  allowUserToCreateOrganization: async (user) => {\n    return user.emailVerified === true;\n  },\n  organizationLimit: async (user) => {\n    return user.plan === \"premium\" ? 20 : 3;\n  },\n});\n```\n\n## Active Organizations\n\nThe active organization is stored in the session and scopes subsequent API calls. Always set an active organization after the user selects one.\n\n```ts\nconst setActive = async (organizationId: string) => {\n  const { data, error } = await authClient.organization.setActive({\n    organizationId,\n  });\n};\n```\n\n## Members\n\nMembers are users who belong to an organization. Each member has a role that determines their permissions.\n\n### Adding Members (Server-Side)\n\n```ts\nawait auth.api.addMember({\n  body: {\n    userId: \"user-id\",\n    role: \"member\",\n    organizationId: \"org-id\",\n  },\n});\n```\n\n### Removing Members\n\n```ts\nawait authClient.organization.removeMember({\n  memberIdOrEmail: \"user@example.com\",\n});\n```\n\n**Important**: The last owner cannot be removed. Assign the owner role to another member first.\n\n## Invitations\n\nThe invitation system allows admins to invite users via email. Configure email sending to enable invitations.\n\n```ts\norganization({\n  sendInvitationEmail: async (data) => {\n    const { email, organization, inviter, invitation } = data;\n    await sendEmail({\n      to: email,\n      subject: `Join ${organization.name}`,\n      html: `\u003Ca href=\"https:\u002F\u002Fyourapp.com\u002Faccept-invite?id=${invitation.id}\">Accept\u003C\u002Fa>`,\n    });\n  },\n});\n```\n\n## Roles & Permissions\n\nThe plugin provides role-based access control (RBAC) with three default roles:\n\n| Role | Description |\n|------|-------------|\n| `owner` | Full access, can delete organization |\n| `admin` | Can manage members, invitations, settings |\n| `member` | Basic access to organization resources |\n\n### Checking Permissions\n\n```ts\nconst { data } = await authClient.organization.hasPermission({\n  permission: \"member:write\",\n});\n\nif (data?.hasPermission) {\n  \u002F\u002F User can manage members\n}\n```\n\n## Teams\n\nTeams allow grouping members within an organization.\n\n### Enabling Teams\n\n```ts\norganization({\n  teams: {\n    enabled: true,\n  },\n});\n```\n\n### Creating and Managing Teams\n\n```ts\nconst { data } = await authClient.organization.createTeam({\n  name: \"Engineering\",\n});\n\nawait authClient.organization.addTeamMember({\n  teamId: \"team-id\",\n  userId: \"user-id\",\n});\n```\n\n## Dynamic Access Control\n\nFor applications needing custom roles per organization at runtime:\n\n```ts\norganization({\n  dynamicAccessControl: {\n    enabled: true,\n  },\n});\n\nawait authClient.organization.createRole({\n  role: \"moderator\",\n  permission: {\n    member: [\"read\"],\n    invitation: [\"read\"],\n  },\n});\n```\n\n## Lifecycle Hooks\n\nExecute custom logic at various points in the organization lifecycle:\n\n```ts\norganization({\n  hooks: {\n    organization: {\n      afterCreate: async ({ organization, member }) => {\n        await createDefaultResources(organization.id);\n      },\n    },\n    member: {\n      afterCreate: async ({ member, organization }) => {\n        await notifyAdmins(organization.id, `New member joined`);\n      },\n    },\n  },\n});\n```\n\n## Schema Customization\n\nCustomize table names, field names, and add additional fields:\n\n```ts\norganization({\n  schema: {\n    organization: {\n      modelName: \"workspace\",\n      additionalFields: {\n        billingId: { type: \"string\", required: false },\n      },\n    },\n    member: {\n      additionalFields: {\n        department: { type: \"string\", required: false },\n      },\n    },\n  },\n});\n```\n\n## Security Considerations\n\n### Owner Protection\n\n- The last owner cannot be removed from an organization\n- The last owner cannot leave the organization\n- Always ensure ownership transfer before removing the current owner\n\n### Organization Deletion\n\nDeleting an organization removes all associated data. Prevent accidental deletion:\n\n```ts\norganization({\n  disableOrganizationDeletion: true,\n});\n```\n\n### Invitation Security\n\n- Invitations expire after 48 hours by default\n- Only the invited email address can accept an invitation\n- Pending invitations can be cancelled by organization admins\n",{"name":5,"description":7},"main","3934845b800ff514cb89eb81d43f3dc4cbf51ff2","packages\u002Freact-frontend\u002Fskills\u002Forganization-best-practices","https:\u002F\u002Fgithub.com\u002Fsarthchawla\u002FSetupMyAI","https:\u002F\u002Fgithub.com\u002Fsarthchawla","there ain't no problem i can't solve","2026-10-23 01:26:57",{"source":8,"skillName":5,"commands":52,"prompt":62,"zipAvailable":63},[53,56,59],{"tool":54,"command":55},"npx","npx skills add sarthchawla\u002FSetupMyAI --skill organization-best-practices",{"tool":57,"command":58},"bunx","bunx skills add sarthchawla\u002FSetupMyAI --skill organization-best-practices",{"tool":60,"command":61},"pnpm","pnpm dlx skills add sarthchawla\u002FSetupMyAI --skill organization-best-practices","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fsarthchawla\u002FSetupMyAI\u002Fblob\u002Fmain\u002Fpackages\u002Freact-frontend\u002Fskills\u002Forganization-best-practices\u002FSKILL.md",true,[],[66,79,95,104,114,134],{"skillNo":67,"name":68,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":76,"publishedAt":39},"01M6P8953HNC422WFQSPP2FMQE","sample-skill","https:\u002F\u002Fgithub.com\u002Fsarthchawla\u002FSetupMyAI\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fmock-repo\u002F.claude\u002Fskills\u002Fsample-skill\u002FSKILL.md",[71],{"categoryNo":72,"categoryName":73,"taxonomyType":74,"taxonomyTypeDesc":75},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[77,78],"sample","sample skill",{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":39},"01M6P8924ZSDAZ88Y5Q9P3KAQV","synthetic-review-candidate","Candidate for smoke testing an evaluation runner only.","https:\u002F\u002Fgithub.com\u002Fsarthchawla\u002FSetupMyAI\u002Fblob\u002Fmain\u002Fscripts\u002Fskill-eval\u002Ffixtures\u002Fcandidate\u002FSKILL.md",[],[86,87,88,89,90,91,92,93,94,25],"synthetic review candidate","candidate","synthetic","review","only","testing","Evaluation","smoke","runner",{"skillNo":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":39},"01M6P88FEGGNH8EZY0PDHD9KQA","synthetic-review-baseline","Baseline for smoke testing an evaluation runner only.","https:\u002F\u002Fgithub.com\u002Fsarthchawla\u002FSetupMyAI\u002Fblob\u002Fmain\u002Fscripts\u002Fskill-eval\u002Ffixtures\u002Fbaseline\u002FSKILL.md",[],[102,88,103,89,93,94,25,90,91,92],"synthetic review baseline","baseline",{"skillNo":105,"name":89,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":39},"01M6P87ZXVEHRM860960DB5FEQ","Run the existing user-invoked review bundle and independently adjudicate its findings.","https:\u002F\u002Fgithub.com\u002Fsarthchawla\u002FSetupMyAI\u002Fblob\u002Fmain\u002Fpackages\u002Funiversal\u002Fskills\u002Freview\u002FSKILL.md",[],[89,110,111,112,113],"run","user","bundle","Existing",{"skillNo":115,"name":116,"nameZh":6,"description":117,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":118,"categories":119,"keywords":120,"publishedAt":39},"01M6P87FC73MZTRB6ZBP4GR1VQ","review-adjudication","Verify generated or human review findings before fixing, defending, replying, resolving, or reusing them as learned guidance. Use within a review, review-comment fix, monitor, or readiness workflow.","https:\u002F\u002Fgithub.com\u002Fsarthchawla\u002FSetupMyAI\u002Fblob\u002Fmain\u002Fpackages\u002Funiversal\u002Fskills\u002Freview-adjudication\u002FSKILL.md",[],[121,89,122,123,124,125,126,127,128,129,130,131,22,132,133],"review adjudication","workflow","generated","human review","guidance","human","as","readiness","learned","review findings","fix","verify","monitor",{"skillNo":135,"name":136,"nameZh":6,"description":137,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":138,"categories":139,"keywords":140,"publishedAt":39},"01M6P871Q44KQES293T60JQETA","monitor-mr","Monitor review findings and CI using the shared adjudication procedure.","https:\u002F\u002Fgithub.com\u002Fsarthchawla\u002FSetupMyAI\u002Fblob\u002Fmain\u002Fpackages\u002Funiversal\u002Fskills\u002Fmonitor-mr\u002FSKILL.md",[],[133,141,142,130,143,144,89],"mr","monitor mr","shared","ci"]