skills/better-auth-drizzle-init/SKILL.md
## better-auth-drizzle-init ### Goal Set up Better Auth with Drizzle ORM and drizzle-kit using a migration-safe, team-friendly workflow. ### Rules 1. Use the Drizzle adapter in Better Auth and set `provider` to one of `"pg"`, `"mysql"`, or `"sqlite"`. 2. Keep the Better Auth config in a CLI-discoverable path (`./auth.ts`, `./lib/auth.ts`, `./utils/auth.ts`, or equivalents under `src/`) or always pass `--config` to Better Auth CLI. 3. For Drizzle projects, do not use `@better-auth/cli migrate`;
npx skillsauth add theprimeagen/skills skills/better-auth-drizzle-initInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Set up Better Auth with Drizzle ORM and drizzle-kit using a migration-safe, team-friendly workflow.
provider to one of "pg", "mysql", or "sqlite"../auth.ts, ./lib/auth.ts, ./utils/auth.ts, or equivalents under src/) or always pass --config to Better Auth CLI.@better-auth/cli migrate; use @better-auth/cli generate for schema generation, then drizzle-kit generate and drizzle-kit migrate for SQL migrations.--output to Better Auth CLI generate so auth schema lands in a dedicated file (avoid root-level schema.ts collisions).drizzle.config.ts as source of truth for migrations. Include both your app schema files and Better Auth generated schema in schema paths.auth schema file, app schema files, and drizzle/* migration files/snapshots).schema, modelName, fields) so Better Auth and Drizzle stay aligned.@better-auth/cli init for Drizzle bootstrapping; it is limited to specific scaffolding paths and does not replace the Drizzle migration flow.project/
src/
db/
schema.ts
auth-schema.ts
lib/
auth.ts
drizzle/
drizzle.config.ts
package.json
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { db, schema } from "../db";
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
schema,
}),
emailAndPassword: {
enabled: true,
},
});
import { defineConfig } from "drizzle-kit";
export default defineConfig({
dialect: "postgresql",
schema: ["./src/db/schema.ts", "./src/db/auth-schema.ts"],
out: "./drizzle",
dbCredentials: {
url: process.env.DATABASE_URL!,
},
});
{
"scripts": {
"auth:schema": "npx @better-auth/cli@latest generate --config ./src/lib/auth.ts --output ./src/db/auth-schema.ts --yes",
"db:generate": "drizzle-kit generate",
"db:migrate": "drizzle-kit migrate",
"db:check": "drizzle-kit check",
"db:sync": "npm run auth:schema && npm run db:generate",
"db:sync:migrate": "npm run db:sync && npm run db:migrate"
}
}
auth:schema.db:generate.drizzle/*/migration.sql.db:migrate.@better-auth/cli migrate with Drizzle.
drizzle-kit generate + drizzle-kit migrate).--output on Better Auth CLI generate.
src/db/auth-schema.ts.--config explicitly.import { env } from "cloudflare:workers" in auth config (newer Workers setup), ornodejs_compat_populate_process_env compatibility flag and process.env access.tools
# Neovim Lua API Reference This document contains type stubs and API references for Neovim's Lua API. Use this as a reference when writing Neovim plugins or configurations in Lua. --- ## api The following are type stubs for all the functions available on `vim.api.*`. Prefer these functions where possible. ```lua vim.api = {} vim.api.nvim__buf_debug_extmarks(buffer, keys, dot) vim.api.nvim__buf_stats(buffer) vim.api.nvim__complete_set(index, opts) vim.api.nvim__get_lib_dir() vim.api.nvim
development
# Neovim Treesitter API Reference This document contains type stubs and API references for Neovim's treesitter Lua API. Use this as a reference when working with treesitter in Neovim Lua. --- ## tsnode TSNode methods - represents a specific element in a parsed syntax tree. Use these methods to navigate and inspect nodes. ```lua function TSNode:parent() end function TSNode:next_sibling() end function TSNode:prev_sibling() end function TSNode:next_named_sibling() end function TSNode:prev_name
tools
# Neovim LSP API Reference This document contains function definitions from Neovim's LSP help docs. Use this as a reference when working with LSP in Neovim Lua. --- ## lsp Functions extracted from `lsp.txt`. ```lua vim.lsp.buf_attach_client({bufnr}, {client_id}) vim.lsp.buf_detach_client({bufnr}, {client_id}) vim.lsp.buf_is_attached({bufnr}, {client_id}) vim.lsp.buf_notify({bufnr}, {method}, {params}) vim.lsp.buf_request_all({bufnr}, {method}, {params}, {handler}) vim.lsp.buf_request_sync({
tools
# Neovim Diagnostics API Reference This document contains function definitions for Neovim's diagnostics Lua API. Use this as a reference when working with diagnostics in Neovim Lua. --- ## diagnostic vim.diagnostic APIs, types, and helpers. ```lua function get_qf_id_for_title(title) function __newindex(t, name, handler) function __index(t, bufnr) function callback() function to_severity(severity) function severity_predicate(severity) function filter_by_severity(severity, diagnostics) functi