Command Palette

Search for a command to run...

UnylyUnyly
Back to skills

typegen-fmdapi

FreeNo executable scriptsNot checked

ENTRY POINT for @proofkit/fmdapi projects. Generate TypeScript types and Zod validators from FileMaker layouts using @proofkit/typegen. Covers…

proofshby proofsh★ 21 GitHub stars

About this skill

ALWAYS use @proofkit/typegen to set up an @proofkit/fmdapi project. Typegen generates type-safe, schema-validated clients directly from your FileMaker layouts. It is the preferred and recommended path — manual client setup is only a fallback. Before writing any DataApi code, run typegen first.

Prerequisites

  • FileMaker Server 19.6+ accessible via port 443
  • OttoFMS 4.7+ installed on the FM server (for API key auth)
  • FileMaker account with the fmrest extended privilege enabled
  • Data API enabled on the FileMaker server

Setup

1. Install the runtime package

pnpm add @proofkit/fmdapi

2. Set environment variables

# .env
FM_SERVER=https://your-server.com     # must start with https://
FM_DATABASE=MyFile.fmp12              # must end with .fmp12

# OttoFMS Data API key (recommended)
OTTO_API_KEY=dk_123456...789
# OR username/password (requires token store in production)
FM_USERNAME=admin
FM_PASSWORD=password

3. Initialize and run typegen

npx @proofkit/typegen@beta init

This creates proofkit-typegen-config.jsonc at your project root. Configure your layouts:

{
  "$schema": "https://proofkit.proof.sh/typegen-config-schema.json",
  "config": {
    "type": "fmdapi",
    "path": "schema",
    "validator": "zod/v4",
    "clientSuffix": "Layout",
    "clearOldFiles": true,
    "generateClient": true,
    "layouts": [
      { "layoutName": "api_Customers", "schemaName": "Customers" },
      {
        "layoutName": "api_Invoices",
        "schemaName": "Invoices",
        "valueLists": "strict",
        "strictNumbers": true
      }
    ]
  }
}

Run typegen to generate clients:

npx @proofkit/typegen@beta

Add a convenience script to package.json:

{
  "scripts": {
    "typegen": "npx @proofkit/typegen@beta"
    "typegen:ui": "npm run typegen ui"
  }
}

4. First query

import { CustomersLayout } from "./schema/client";

const { data } = await CustomersLayout.findOne({
  query: { id: "==123" },
});

console.log(data.fieldData);

The generated client includes full type safety and runtime schema validation — no manual type definitions needed.

Core Patterns

Generated output structure

schema/
  generated/      # Auto-generated. NEVER edit.
    Customers.ts
    Invoices.ts
  client/         # Auto-generated. NEVER edit.
    Customers.ts
    Invoices.ts
    index.ts
  Customers.ts    # Override file. Safe to edit.
  Invoices.ts     # Override file. Safe to edit.

Override files for customization

Override files live at schema/<schemaName>.ts. They re-export from generated/ and are never overwritten by typegen. Customize by modifying the Zod schema:

// schema/Customers.ts (override file)
import { z } from "zod/v4";
import {
  ZCustomers as ZCustomers_generated,
} from "./generated/Customers";

export const ZCustomers = ZCustomers_generated
  .omit({ active: true })
  .extend({
    active: z.coerce.boolean(),
  });

export type TCustomers = z.infer<typeof ZCustomers>;

The generated client automatically imports from the override file, so transformations apply at runtime.

Type inference helpers

For portals, use InferZodPortals from @proofkit/fmdapi:

import type { InferZodPortals } from "@proofkit/fmdapi";

export const ZInvoicesPortals = {
  lineItems: ZLineItems,
};

export type TInvoicesPortals = InferZodPortals<typeof ZInvoicesPortals>;

Custom env variable names

{
  "config": {
    "type": "fmdapi",
    "envNames": {
      "server": "MY_FM_SERVER",
      "db": "MY_FM_DATABASE",
      "auth": {
        "apiKey": "MY_OTTO_KEY"
      }
    },
    "layouts": [
      { "layoutName": "api_Users", "schemaName": "Users" }
    ]
  }
}

Default env variable names when envNames is omitted: FM_SERVER, FM_DATABASE, OTTO_API_KEY (or FM_USERNAME/FM_PASSWORD for Fetch adapter).

Multiple configs

The config key can be an array mixing fmdapi and fmodata entries, each with its own path and envNames.

FM MCP mode (local Web Viewer development — no credentials)

FM MCP mode lets typegen fetch layout metadata from a locally running FileMaker file via the FM MCP proxy, without needing OttoFMS, a hosted server, or any credentials. Generated clients use WebViewerAdapter — FM MCP is only used during typegen.

{
  "$schema": "https://proofkit.proof.sh/typegen-config-schema.json",
  "config": {
    "type": "fmdapi",
    "fmMcp": { "enabled": true },
    "layouts": [
      { "layoutName": "api_Contacts", "schemaName": "Contacts" }
    ]
  }
}

fmMcp accepts an object with optional overrides:

  • enabled — true to enable (default when object is present)
  • scriptName — FM script the proxy calls for Data API operations. Resolution: fmMcp.scriptName > webviewerScriptName > "PK_execute_data_api"
  • baseUrl — FM MCP server URL (default: http://127.0.0.1:1365). Can also be set vi
Full SKILL.md on GitHub

Install typegen-fmdapi in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

FAQ

What does the typegen-fmdapi skill do?

ENTRY POINT for @proofkit/fmdapi projects. Generate TypeScript types and Zod validators from FileMaker layouts using @proofkit/typegen. Covers proofkit-typegen-config.jsonc for Data API mode, npx @proofkit/typegen setup, OttoAdapter and FetchAdapter env vars, FM MCP mode for local Web Viewer development, generated vs override file structure, schema/generated/client directory layout, Standard Schema validation, InferZodPortals, fmMcp mode prerequisites, and choosing between OttoAdapter and FetchAdapter auth.

How do I install the typegen-fmdapi skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the typegen-fmdapi skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare typegen-fmdapi with