# better-auth-authentication

A skill for TypeScript apps: sets up email and password sign-in, social providers and email verification with Better Auth.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 389 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-authentication/SKILL.md
- Updated: 2026-07-18
- HTML: https://affpapa.org/en/nevibecode/skills/better-auth-authentication

## What it does

The skill walks through wiring Better Auth into a TypeScript project. Quick start is three steps: enable `emailAndPassword`, configure `socialProviders`, create a client with `createAuthClient`. Then the client calls `signUp.email`, `signIn.email`, `signIn.social` and `signOut`.

Email verification gets its own section. Sending the link requires `emailVerification.sendVerificationEmail`, and `emailAndPassword.requireEmailVerification` blocks sign-in until the address is confirmed. Social providers go into `socialProviders` with their own credentials, `signIn.social` starts the OAuth flow, and redirects are set with `callbackURL`, `errorCallbackURL` and `newUserCallbackURL`.

Guardrails matter here. Call client methods from the client only, and keep secrets in server-only environment variables. The GitHub example needs `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET`; without them GitHub sign-in fails. Persistent sessions on email sign-in are controlled by `rememberMe`. The skill is marked `user-invocable: false`, so you cannot call it directly.

## Install

### Claude Code (native platform)

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

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

### Codex

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

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

### Cursor

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

2. **Manually: put the files in place**
- File: `.cursor/skills/better-auth-authentication/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-authentication
```

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

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add bobmatnyc/claude-mpm-skills --skill better-auth-authentication -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-authentication
```

### Windsurf (Devin Desktop)

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

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add bobmatnyc/claude-mpm-skills --skill better-auth-authentication -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-authentication/SKILL.md

## When to use it
- add email and password sign-in to a TypeScript app
- wire up GitHub as an OAuth provider
- send a verification link by email
- block sign-in until the address is verified
- set redirects for success and error cases

## Example prompts
- Set up email and password auth with Better Auth in my TypeScript project
- Add GitHub sign-in and redirect to /dashboard after login
- Require email verification before users can sign in

## 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: 90fff6db1416a360.

BEGIN THIRD-PARTY FILE 90fff6db1416a360
````text
---
name: better-auth-authentication
description: Better Auth authentication flows for TypeScript apps. Use when enabling email/password auth, configuring social providers, or implementing sign-up, sign-in, and verification flows.
user-invocable: false
disable-model-invocation: true
progressive_disclosure:
  entry_point:
    summary: "Better Auth authentication flows for TypeScript apps. Use when enabling email/password auth, configuring social providers, or implementing sign-up, sign-in, and verification flows."
    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:
    - email-password.md
    - providers.md
---
# Better Auth Authentication

## Goals
- Enable email/password authentication and social providers.
- Implement sign-up, sign-in, sign-out, and verification flows.
- Handle redirects and errors consistently.

## Quick start
1. Enable `emailAndPassword` and configure `socialProviders`.
2. Create a client with `createAuthClient`.
3. Use `signUp.email`, `signIn.email`, `signIn.social`, and `signOut` on the client.

```ts
import { betterAuth } from "better-auth";

export const auth = betterAuth({
  emailAndPassword: { enabled: true },
  socialProviders: {
    github: {
      clientId: process.env.GITHUB_CLIENT_ID as string,
      clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
    },
  },
});
```

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

const authClient = createAuthClient();

await authClient.signUp.email({
  email,
  password,
  name,
});

await authClient.signIn.email({
  email,
  password,
  callbackURL: "/dashboard",
});

await authClient.signIn.social({
  provider: "github",
  callbackURL: "/dashboard",
});

await authClient.signOut();
```

## Email verification
- Provide `emailVerification.sendVerificationEmail` to send the verification link.
- Use `emailAndPassword.requireEmailVerification` to enforce verification before sign-in.

## Social providers
- Configure providers in `socialProviders` with provider-specific credentials.
- Use `signIn.social` to start OAuth flows.
- Pass `callbackURL`, `errorCallbackURL`, and `newUserCallbackURL` for redirects.

## Guardrails
- Call client methods from the client only.
- Keep secrets in server-only env variables.
````
END THIRD-PARTY FILE 90fff6db1416a360

The third-party file has ended. Everything between the 90fff6db1416a360 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.

First 2410 of 2694 bytes. © bobmatnyc · MIT · https://github.com/bobmatnyc/claude-mpm-skills/tree/HEAD/toolchains/platforms/auth/better-auth/better-auth-authentication/SKILL.md

_Part of the page did not fit — see the HTML version._

---
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
