# better-auth-plugins

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

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 352 installs · ★ 78
- Author: bobmatnyc
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/bobmatnyc/claude-mpm-skills/tree/HEAD/toolchains/platforms/auth/better-auth/better-auth-plugins/SKILL.md
- Updated: 2026-07-18
- HTML: https://affpapa.org/en/nevibecode/skills/better-auth-plugins

## What it 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.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add bobmatnyc/claude-mpm-skills --skill better-auth-plugins -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/better-auth-plugins/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/better-auth-plugins/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add bobmatnyc/claude-mpm-skills --skill better-auth-plugins -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/better-auth-plugins/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add bobmatnyc/claude-mpm-skills --skill better-auth-plugins -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/better-auth-plugins/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install bobmatnyc/claude-mpm-skills better-auth-plugins
```

2. **Manually: put the files in place**
- File: `.github/skills/better-auth-plugins/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add bobmatnyc/claude-mpm-skills --skill better-auth-plugins -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/bobmatnyc/claude-mpm-skills --path toolchains/platforms/auth/better-auth/better-auth-plugins
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/better-auth-plugins/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add bobmatnyc/claude-mpm-skills --skill better-auth-plugins -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/bobmatnyc/claude-mpm-skills/tree/HEAD/toolchains/platforms/auth/better-auth/better-auth-plugins/SKILL.md

## When to use it
- 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
- 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

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: e94951d7af3f78fe.

BEGIN THIRD-PARTY FILE e94951d7af3f78fe
````text
---
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`
````
END THIRD-PARTY FILE e94951d7af3f78fe

The third-party file has ended. Everything between the e94951d7af3f78fe tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

© bobmatnyc · MIT · https://github.com/bobmatnyc/claude-mpm-skills/tree/HEAD/toolchains/platforms/auth/better-auth/better-auth-plugins/SKILL.md

## Similar
- [git-guardrails-claude-code](https://affpapa.org/en/nevibecode/skills/git-guardrails-claude-code.md) — skill · 499069 installs
- [ponytail-review](https://affpapa.org/en/nevibecode/skills/ponytail-review.md) — skill · 57000 installs
- [ponytail-audit](https://affpapa.org/en/nevibecode/skills/ponytail-audit.md) — skill · 45400 installs
- [security-audit](https://affpapa.org/en/nevibecode/skills/cloudflare-security-audit.md) — skill · 54800 installs
- [security-and-hardening](https://affpapa.org/en/nevibecode/skills/security-and-hardening.md) — skill · 70200 installs
- [supabase](https://affpapa.org/en/nevibecode/skills/supabase.md) — skill · 8 installs

From the same set: [bobmatnyc/claude-mpm-skills](https://affpapa.org/en/nevibecode/by/bobmatnyc/claude-mpm-skills.md) — 125 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
