Skip to main content
skill CX Codex

better-auth-plugins — Claude Code skill: setup and usage

Guides coding agents when configuring Better Auth plugins in TypeScript projects. Covers two-factor auth, passkeys, JWT, and schema migrations.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add bobmatnyc/claude-mpm-skills --skill better-auth-plugins -a claude-code
Open on GitHub

What better-auth-plugins does

This skill guides coding agents through configuring Better Auth plugins for TypeScript. It pairs server modules from better-auth/plugins with corresponding client plugins from better-auth/client/plugins, preventing API mismatches across the stack.

It also enforces migration steps when plugins add database tables. The assistant is instructed to run npx @better-auth/cli generate and npx @better-auth/cli migrate. In addition, whenever nextCookies is present, it must sit last in the server plugin list.

What it helps with

  • integrate two-factor authentication with server and client plugins
  • run database migrations via Better Auth CLI
  • align client-side authentication methods with server capabilities
  • set up passkey, magic link, JWT, or organizations

Example prompts for the agent

  • Add two-factor authentication to Better Auth and configure the client redirect
  • Set up organization support in Better Auth and run the required migrations
  • Configure the passkey plugin for both server and client auth instances

How to install better-auth-plugins

1Skills CLI (Vercel)

npx skills add bobmatnyc/claude-mpm-skills --skill better-auth-plugins -a claude-code

2Manually: put the files in place

~/.claude/skills/better-auth-plugins/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/better-auth-plugins/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about better-auth-plugins

How to install better-auth-plugins in Claude Code?

Run npx skills add bobmatnyc/claude-mpm-skills --skill better-auth-plugins -a claude-code. This installs the skill directly into your environment.

What does better-auth-plugins do?

It provides implementation patterns for Better Auth in TypeScript, pairing server and client plugins and verifying database migration steps.

What is the ordering requirement for nextCookies?

When using nextCookies, place it as the last item in the server plugins array.

Source text

SKILL.md · MIT
---
name: better-auth-plugins
description: Better Auth plugin system for TypeScript. Use when adding advanced auth features (2FA, magic link, passkey, username, JWT, organizations) via server and client plugins.
user-invocable: false
disable-model-invocation: true
progressive_disclosure:
  entry_point:
    summary: "Better Auth plugin system for TypeScript. Use when adding advanced auth features (2FA, magic link, passkey, username, JWT, organizations) via server and client plugins."
    when_to_use: "When implementing authentication, authorization, or security."
    quick_start: "1. Review the core concepts below. 2. Apply patterns to your use case. 3. Follow best practices for implementation."
  references:
    - plugins-index.md
---
# Better Auth Plugins

## Goals
- Add server plugins to extend auth features.
- Add client plugins for matching client methods.
- Apply schema changes when plugins add tables.

## Quick start
1. Import the plugin from `better-auth/plugins` and add it to `plugins`.
2. Run migrations (`generate` or `migrate`) when required.
3. Add the client plugin from `better-auth/client/plugins`.

### Example: Two-factor authentication
```ts
import { betterAuth } from "better-auth";
import { twoFactor } from "better-auth/plugins";

export const auth = betterAuth({
  plugins: [twoFactor()],
});
```

```ts
import { createAuthClient } from "better-auth/client";
import { twoFactorClient } from "better-auth/client/plugins";

export const authClient = createAuthClient({
  plugins: [twoFactorClient({ twoFactorPage: "/two-factor" })],
});
```

## Migration reminder
Run the CLI when a plugin adds tables:

```bash
npx @better-auth/cli generate
```

```bash
npx @better-auth/cli migrate
```

## Guardrails
- Add server and client plugins together to keep APIs aligned.
- Keep `nextCookies` (if used) last in the server plugin list.
- Review plugin docs for required schema and env variables.

## References
- `toolchains/platforms/auth/better-auth/better-auth-plugins/references/plugins-index.md`

© bobmatnyc · MIT · bobmatnyc/claude-mpm-skills

Similar skills

All skills for Security →

From the same set125

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor