packages/better-auth/skills/better-auth-setup/SKILL.md
Set up self-hosted authentication with better-auth using FileMaker as the database backend. Covers FileMakerAdapter, FMServerConnection, betterAuth config, migration via npx @proofkit/better-auth migrate, OData prerequisites, fmodata privilege, Full Access credentials for schema modification, plugin migration workflow, troubleshooting "filemaker is not supported" errors.
npx skillsauth add proofgeist/proofkit better-auth-setupInstall 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.
fmodata privilege enabledpnpm add @proofkit/better-auth @proofkit/fmodata
import { betterAuth } from "better-auth";
import { FMServerConnection } from "@proofkit/fmodata";
import { FileMakerAdapter } from "@proofkit/better-auth";
const connection = new FMServerConnection({
serverUrl: process.env.FM_SERVER_URL!,
auth: {
username: process.env.FM_USERNAME!,
password: process.env.FM_PASSWORD!,
},
});
const db = connection.database(process.env.FM_DATABASE!);
export const auth = betterAuth({
database: FileMakerAdapter({ database: db }),
// add plugins, social providers, etc.
});
FileMakerAdapter accepts a FileMakerAdapterConfig:
database (required) -- an fmodata Database instancedebugLogs (optional) -- enable adapter debug loggingusePlural (optional) -- set true if table names are pluralThe adapter maps Better Auth operations (create, findOne, findMany, update, delete, count) to OData requests via db._makeRequest. It does not support JSON columns, native dates, or native booleans -- all values are stored as strings/numbers.
const connection = new FMServerConnection({
serverUrl: process.env.FM_SERVER_URL!,
auth: {
apiKey: process.env.OTTO_API_KEY!,
},
});
OData must be enabled for the key.
After configuring auth.ts, run the migration CLI to create tables and fields in FileMaker:
npx @proofkit/better-auth migrate
The CLI:
auth.ts config (auto-detected or via --config <path>)getSchema() from better-auth/db to determine required tables/fieldsdb.getMetadata()db.schema.createTable() and db.schema.addFields()Only schema is modified. No layouts or relationships are created.
If your runtime credentials lack Full Access, override for migration only:
npx @proofkit/better-auth migrate --username "admin" --password "admin_pass"
Skip confirmation with -y:
npx @proofkit/better-auth migrate -y
When you add a Better Auth plugin (e.g. twoFactor, organization), it declares additional tables/fields. After updating auth.ts:
import { betterAuth } from "better-auth";
import { twoFactor } from "better-auth/plugins";
import { FMServerConnection } from "@proofkit/fmodata";
import { FileMakerAdapter } from "@proofkit/better-auth";
const connection = new FMServerConnection({
serverUrl: process.env.FM_SERVER_URL!,
auth: {
username: process.env.FM_USERNAME!,
password: process.env.FM_PASSWORD!,
},
});
const db = connection.database(process.env.FM_DATABASE!);
export const auth = betterAuth({
database: FileMakerAdapter({ database: db }),
plugins: [twoFactor()],
});
Re-run migration:
npx @proofkit/better-auth migrate
The planner diffs against existing metadata, so only new tables/fields are added. Existing tables are left untouched.
When migration fails with OData error code 207, the account lacks schema modification privileges. The CLI outputs:
Failed to create table "tableName": Cannot modify schema.
The account used does not have schema modification privileges.
Use --username and --password to provide Full Access credentials.
Fix: provide Full Access credentials via CLI flags. These are only used for migration, not at runtime.
Wrong:
npx better-auth migrate
Correct:
npx @proofkit/better-auth migrate
The standard better-auth CLI does not know about the FileMaker adapter and produces: ERROR [Better Auth]: filemaker is not supported. If it is a custom adapter, please request the maintainer to implement createSchema. The @proofkit/better-auth CLI loads your auth config, extracts the Database instance from the adapter, and handles migration via fmodata's schema API.
Source: apps/docs/content/docs/better-auth/troubleshooting.mdx
Wrong:
# Using runtime credentials that only have fmodata privilege
npx @proofkit/better-auth migrate
# Fails with OData error 207: Cannot modify schema
Correct:
npx @proofkit/better-auth migrate --username "full_access_user" --password "full_access_pass"
Schema modification (db.schema.createTable, db.schema.addFields) requires [Full Access] privileges. Standard API accounts with fmodata privilege can read/write data but cannot alter schema. The CLI accepts --username and --password flags to override credentials for migration only.
Source: packages/better-auth/src/cli/index.ts, packages/better-auth/src/migrate.ts
Wrong:
Manually deleting "unused" fields from better-auth tables in FileMaker
Correct:
Keep all fields created by migration, even if you don't plan to use them
Better Auth expects all schema fields to exist at runtime. The adapter issues OData requests that reference these fields. Removing them causes runtime errors when Better Auth attempts to read or write those columns.
Source: apps/docs/content/docs/better-auth/installation.mdx
Wrong:
// Added twoFactor() plugin to auth.ts but did not re-run migration
export const auth = betterAuth({
database: FileMakerAdapter({ database: db }),
plugins: [twoFactor()],
});
// Runtime errors: tables/fields for twoFactor don't exist
Correct:
# After adding any plugin to auth.ts, always re-run:
npx @proofkit/better-auth migrate
Each plugin declares additional tables and fields via getSchema(). The migration planner diffs the full schema (including plugins) against current OData metadata. Without re-running, the new tables/fields don't exist and Better Auth throws at runtime.
Source: apps/docs/content/docs/better-auth/installation.mdx
Database under the hood for all OData requests. FMServerConnection and database() must be configured before FileMakerAdapter can work. The adapter calls db._makeRequest() for CRUD and db.schema.* for migrations.development
FileMaker WebDirect ProofKit Web Viewer runtime behavior refresh resilience session state localStorage browser resize reload same deployment embedded bundle avoid separate deployment avoid separate web server @proofkit/webviewer fmFetch callFMScript WebViewerAdapter WebDirect page refresh
development
webviewer fmFetch callFMScript WebViewerAdapter globalSettings setWebViewerName SendCallback window.FileMaker browser-only FileMaker Web Viewer script execution fire-and-forget FMScriptOption PerformScript callback fetchId handleFmWVFetchCallback
development
ENTRY POINT for @proofkit/fmodata projects. Generate TypeScript table schemas with entity IDs from FileMaker OData metadata using @proofkit/typegen. Covers proofkit-typegen-config.jsonc for OData mode, npx @proofkit/typegen setup, fmTableOccurrence generation, entity IDs (FMFID/FMTID), generated output structure, field exclusion, type overrides, InferTableSchema, env var configuration, OData prerequisites, fmodata privilege, and why typegen is required for entity ID correctness.
development
OData performance patterns for @proofkit/fmodata. Covers defaultSelect schema vs all, select() for minimal field fetching, select("all") override, pagination with top/skip, default 1000 record limit, batch operations for reducing round trips, entity IDs FMFID FMTID for rename resilience, null field query performance, getQueryString() debugging, relationship query performance testing, FileMaker OData optimization, avoiding OData service overload during testing.