mcpField
B
better-auth

better-auth

github.com/blogic-czSecurity368 installsUpdated 3d ago
Repository

About better-auth

A skill for choosing authorization procedures in Better Auth and TRPC template-ts applications. It maps access needs to procedures with the appropriate context, and gives rules for middleware and context reuse.

Key features

  1. 01Procedure selection by access level
  2. 02Organization and project access patterns
  3. 03Middleware chaining guidance
  4. 04Stable context and header handling

Use cases

  1. 01Selecting authorization for a TRPC route
  2. 02Reviewing organization or project access checks
  3. 03Implementing Better Auth calls in procedures

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/blogic-cz/blogic-marketplace --skill better-auth

After installing, type/better-authin Claude Code to confirm it loaded.

Bundled filesreferences/better-auth-examples.md

Details

From the project README

Better Auth Procedure Selection

Select authorization boundaries with Better Auth + TRPC patterns used in template-ts apps.

Procedure Selection Table

ProcedureAccess LevelContext Provided
publicProcedureNo auth{ db, session?, headers }
protectedProcedureAuthenticated{ db, session, userId, headers }
adminProcedureAdmin role{ db, session, headers }
protectedOrganizationMemberProcedureOrg member{ ..., member, organizationId }
protectedOrganizationAdminProcedureOrg admin/owner{ ..., member, organizationId }
protectedProjectMemberProcedureProject access{ ..., project, projectRole, orgRole }
protectedProjectAdminProcedureProject admin{ ..., project, projectRole, orgRole }
protectedProjectEditorProcedureProject editor+{ ..., project, projectRole, orgRole }

Use this table as the primary selector before writing router logic.

Use This Skill When

  • Select the correct protected procedure for organization/project/member/admin access.
  • Implement Better Auth authorization checks inside TRPC procedures.
  • Review auth boundaries in existing routers.

Follow This Workflow

  1. Identify required access level from the Procedure Selection Table.
  2. Start implementation from the matching base procedure.
  3. Chain stricter middleware only when the table does not fully satisfy the access rule.
  4. Load references/better-auth-examples.md for detailed examples and copy-ready snippets.
  5. Keep context shape stable; add only route-specific fields.

Key Rules

  1. Select the narrowest procedure that matches the required permission.
  2. Reuse inherited context (userId, organizationId, project, roles) instead of recomputing it.
  3. Grant organization admins automatic project-admin behavior; avoid duplicate checks.
  4. Pass ctx.headers to auth.api.* server calls.
  5. Validate variable origins in every middleware (opts.ctx, opts.input) before adding business logic.

References

  • references/better-auth-examples.md — auth configuration, context setup, middleware examples, client auth usage, and admin API patterns.

Comments

Markdown supported