03

Cantrip

AI / Platform

RoleFounder / Full-Stack Engineer
TimelineMar 2026 – Ongoing
ClientPersonal Product
StatusPreview
Cantrip screenshot

Outcomes

1 rules SDK, 2 surfaces

cantrip-sdk validates rulesets at authoring time and executes them at play time. No schema drift between editor and runtime.

AI bound to typed grammar

DM tools defined per-ruleset via Vercel AI SDK structured tools, so the AI stays in-system instead of hallucinating mechanics.

Overview

Cantrip is a multi-tenant TTRPG platform where game publishers ship rulesets and players run sessions with an AI Dungeon Master. The same architectural backbone as Chicknz (multi-tenant, oRPC, Prisma, Better Auth) but applied to a creative-tools domain: the AI is the host, not a chatbot.

Flagship ruleset: Zairoo, an Afrocentric original system that doubles as the platform's reference content while the editor and session experience are stress-tested.

Challenge

Existing virtual-tabletop tools force publishers into a fixed rules engine, and AI DM tools tend to be single-system. Cantrip splits the layer cleanly: an extractable rules engine SDK + a tenant-isolated session runtime + an AI orchestrator that knows the active ruleset's grammar. Publishers get authoring tools; players get a host that doesn't break character.

Tech Stack

Next.jsTypeScriptPrismaoRPCBetter AuthAI SDKAnthropic

Architecture

AUTHORINGENGINERUNTIMEPublisher editorvalidate at write timecantrip-sdktyped rulesSession runtimetenantId-scopedAI Dungeon Mastertyped tools, in-grammar
One engine, the cantrip-sdk, validates rulesets at authoring time and executes them at play time, so a ruleset that saves is one that runs. The AI DM is bound to the ruleset's typed tools, so it improvises story without inventing mechanics.

Key Features

01

AI Dungeon Master

Anthropic Claude orchestrates session flow, generates encounters, and arbitrates rules. Bound to the active ruleset's grammar so it stays in-system instead of hallucinating mechanics.

02

Ruleset Authoring

Publisher dashboard for shipping rulesets: character sheets, moves, tables, narrative tone. Same authoring layer that powers Zairoo also opens to third-party publishers.

03

Tenant-Isolated Sessions

Each session runs in a tenant-isolated context with its own ruleset, party state, and AI memory. Built on the same multi-tenant primitives as Chicknz, with every query scoped and every AI call sandboxed.

Cantrip screenshot 1
Cantrip screenshot 2
Cantrip screenshot 3
Cantrip screenshot 4

Lessons & tradeoffs

An AI Dungeon Master is only fun if it stays inside the rules. Free-form prompting drifts and starts inventing mechanics that don't exist. I bound the AI to a typed tool surface generated from each ruleset's grammar, so it improvises the story but never breaks the system.

Challenge

An AI DM that free-associates will happily invent spells and stats that aren't in the ruleset, which quietly ruins the game.

Decision

I bound the AI to a strict, typed tool surface derived from the active ruleset's grammar instead of prompting it in prose.

Lesson

AI agents stay in character only when their tools are typed. Constrain the surface and creativity becomes safe instead of chaotic.

Challenge

Publishers author rulesets in one place and players run them in another. Any drift between authoring and runtime and a ruleset that 'saved fine' breaks mid-session.

Decision

I shipped one engine, the cantrip-sdk, that validates rulesets at authoring time and executes them at play time.

Lesson

An SDK shipped alongside the platform is worth the dual-target tax. A ruleset that validates is one that runs, by construction.

Challenge

I needed tenant isolation again, this time on a creative-tools product that looks nothing like a family chore app.

Decision

I reused the same tenantId query-scoping pattern from Chicknz rather than reinventing isolation for a new domain.

Lesson

I didn't reuse a single line of Chicknz's code in Cantrip, I reused its tenant-scoping pattern. The pattern travels between products; the code doesn't.

Next ProjectLHBK Web