generate
Generates the schema required by Better Auth for your database adapter.
- Prisma — appends models to
prisma/schema.prisma - Drizzle — writes a
schema.tsfile in your project root - Kysely — writes a raw
schema.sqlfile in your project root
Options
By default the CLI searches for an auth config file (
auth.ts) in ./, ./utils, ./lib, and the same directories under src/.
migrate
Applies the Better Auth schema directly to your database. Only available
when using the built-in Kysely adapter. For Prisma, Drizzle, or other
ORMs use their own migration tooling after running generate.
Options
PostgreSQL non-default schema: The migrate command automatically detects
your configured
search_path and creates tables in the correct schema. See
the PostgreSQL adapter docs
for configuration details.init
Bootstraps a Better Auth configuration file in an existing project.
Options
secret
Generates a cryptographically random secret suitable for the BETTER_AUTH_SECRET
environment variable.
info
Prints diagnostic information about your Better Auth setup. Useful for
debugging and including in bug reports.
Output includes
- System — OS, CPU, memory, Node.js version
- Package manager — detected manager and version
- Better Auth — installed version and config (sensitive values auto-redacted)
- Frameworks — detected frameworks (Next.js, React, Vue, etc.)
- Databases — detected ORM clients (Prisma, Drizzle, etc.)
Options
[REDACTED] in the output.
mcp
Adds the Better Auth MCP (Model Context Protocol) server to your AI coding assistant. This enables AI tools like Claude Code, Cursor, or Open Code to understand Better Auth APIs and help you implement authentication.
Options
- Claude Code
- Cursor
- Open Code
- Manual
upgrade
Upgrades Better Auth and its related packages to the latest version.
Troubleshooting
Error: Cannot find module X
The CLI cannot resolve imported modules in your config file. Try these steps:
- Remove import aliases and use relative paths instead.
- Run the CLI command.
- Revert to using aliases.