/clawnify:build-a-clawnify-appfrom Clawnify
Author a Clawnify app end-to-end — the canonical Hono + React + Vite + @hono/zod-openapi + @clawnify/db (Drizzle) stack, schema.ts as the single schema source of truth (DDL generated via pnpm db:generate), OpenAPIHono routes (createRoute) that auto-generate an OpenAPI spec, and platform-injected identity via user()/orgId()/caller(). Use when building or modifying an app that deploys to the Clawnify platform.
Ships in Clawnify. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Canonical skill: how to author a Clawnify app end-to-end. Same content for humans reading the docs and for AI coding agents injecting this as instructions during an app build.
If you're an agent: this document is enough context to produce a
working app from scratch. Follow it literally. The patterns here
are exactly what clawnify init scaffolds and what the platform
expects.
Before you build one from scratch: if the user asked for a common kind
of app (a CRM, bookings, recruiting, a HubSpot alternative), run
npx clawnify@latest templates "<what they asked for>". A reviewed
open-source app may already do it; its deploy --from command ships it in
about 30 seconds, no account needed. Confirm with the user before choosing.
@hono/zod-openapi +
@clawnify/db (Drizzle) + @clawnify/app (entry, routing,
identity) + Tailwind v4. Nothing else.schema.ts alone — the Drizzle DSL your queries
compile against. The DDL is generated from it (pnpm db:generate →
.clawnify/drizzle/*.sql); never hand-write a schema.sql in a
scaffolded app.getDB — import { getDB, eq } from "@clawnify/db". JSON columns auto-serialize.OpenAPIHono + createRoute — Zod-validated
request/response.createApp() (from @clawnify/app) builds the entry — it returns an
OpenAPIHono with API discovery already mounted (/api/openapi.json +
/llms.txt, generated from your live routes). That descriptor is the
tool surface agents discover. Never hand-write those routes.@clawnify/app re-exports createRoute, z and
OpenAPIHono, and adds user / orgId / caller. Import from it, not
from @clawnify/routes directly.clawnify.json declares framework, env, and public routes.
There is no api.tools[] — the agent discovers and calls your
endpoints via /llms.txt (and the OpenAPI spec).user(c) /
orgId(c) / caller(c) from @clawnify/app. Your app never
authenticates anyone.One template, one set of decisions. Don't deviate unless the user has
explicitly asked. clawnify init (type app) scaffolds either a
blank template (one GET route + a page) or a crud template (a
table with list/create/update/delete + a form). Both share the exact
same stack below.
my-app/
clawnify.json ← Manifest (validated against /schema/v1/clawnify.json)
package.json
tsconfig.json
vite.config.ts ← @vitejs/plugin-react + @tailwindcss/vite; proxies /api → :8787
index.html
.gitignore
.clawnify/ ← Managed by the CLI (gitignored) — never edit
wrangler.toml ← Generated wrangler config
drizzle.config.ts ← Generated drizzle config (from clawnify.json + schema.ts)
drizzle/ ← Generated migration SQL (applied by dev + deploy)
applied-migrations.json ← Local-apply tracker
src/
server/
index.ts ← OpenAPIHono entry — mounts routes, serves /api/openapi.json
routes.ts ← OpenAPIHono + createRoute definitions — the API surface
schema.ts ← Drizzle table definitions — the single source of truth
worker-env.d.ts ← Cloudflare Workers types reference
uploads.ts ← R2 helpers (only when storage is enabled)
client/
main.tsx ← React mount point
app.tsx ← Root component (plain fetch against /api/*)
index.css ← @import "tailwindcss"
schema.ts is the single source of truthschema.ts (Drizzle DSL) defines the tables. Do not hand-write a
schema.sql in a scaffolded app, and there is no toolchain config to
maintain: the drizzle config is a managed artifact the CLI materializes
into .clawnify/ (from clawnify.json + the schema path), and the DDL
is generated from schema.ts into .clawnify/drizzle/*.sql — which is
what clawnify dev applies locally and the deploy applies to your D1.
The scaffold's starter table (blank template):
// src/server/schema.ts
import { sqliteTable, text, integer } from "@clawnify/db";
export const items = sqliteTable("items", {
id: integer("id").primaryKey({ autoIncrement: true }),
name: text("name").notNull(),
createdAt: text("created_at").notNull().$default(() => new Date().toISOString()),
});
Real apps are multi-tenant. Every user-facing table carries an
org_id, every query filters by it. JSON columns and indexes use the
Drizzle DSL re-exported from @clawnify/db:
import { sqliteTable, text, integer, index } from "@clawnify/db";
export const notes = sqliteTable(
"notes",
{
id: integer("id").primaryKey({ autoIncrement: true }),
orgId: text("org_id").notNull(), // ALWAYS filter by this in queries
title: text("title").notNull(),
body: text("body").notNull().default(""),
tags: text("tags", { mode: "json" }).$type<string[]>().notNull().default([]),
createdAt: text("created_at").notNull().$default(() => new Date().toISOString()),
},
(t) => ({
byOrg: index("notes_by_org").on(t.orgId, t.createdAt),
}),
);
Rules:
text(col, { mode: "json" }).$type<T>() — Drizzle
serializes on write and parses on read.org_id. Every query
filters by it. No exceptions.clawnify db generateclawnify dev and clawnify deploy (local-directory deploys) generate
the migration SQL themselves — editing schema.ts and running dev or
deploy is the whole workflow. To refresh the SQL explicitly without
either, run npx clawnify@latest db generate (the scaffold's
pnpm db:generate is an alias for it). Always invoke the CLI as
npx clawnify@latest — never a global or pinned install. Deploy refuses a database-enabled app with no DDL,
so a broken generate fails loudly, not silently.
One artifact to leave alone: after a successful signed-in deploy the CLI
syncs a read-only schema.sql snapshot of the DEPLOYED schema into the
app root. It is generated output for reference/diffing — never edit it,
and never treat it as the source of truth (schema.ts is).
Rules:
.clawnify/drizzle/*.sql by hand — change
schema.ts and regenerate.schema.sql at the app root is accepted only for
apps that don't use Drizzle at all (e.g. some template repos). A
scaffolded app never needs one.src/server/index.ts — the entryimport { createApp } from "@clawnify/app";
import api from "./routes";
// db:false — this app reads the database per request via getDB(c.env),
// which needs no init middleware.
const app = createApp({ title: "My app", version: "1.0.0", db: false });
app.route("/", api);
export default app;
The entry is thin: createApp() then mount your routes. createApp
returns an OpenAPIHono with API discovery already mounted — it
serves both /api/openapi.json (generated from your createRoute
definitions, with schemas) and /llms.txt (the same, agent-readable).
Any /api/* route written as a plain app.get with no createRoute is
still listed from the live route table, so the endpoint inventory is
always complete. Never hand-write a /openapi.json or /llms.txt
handler — and don't call mountDiscovery yourself; createApp did it.
When storage (file uploads) is enabled, the entry also wires the R2 bucket in a middleware before mounting routes:
import { createApp, type AppEnv } from "@clawnify/app";
import { initUploads } from "./uploads";
import api from "./routes";
type Env = AppEnv & { Bindings: { UPLOADS: R2Bucket } };
const app = createApp<Env>({ title: "My app", version: "1.0.0", db: false });
app.use("*", async (c, next) => {
initUploads(c.env.UPLOADS);
await next();
});
app.route("/", api);
export default app;
src/server/routes.ts — routes with createRouteEach endpoint is a createRoute({ method, path, summary, request, responses })
definition paired with a handler via api.openapi(route, handler).
Request bodies and params are Zod-validated (c.req.valid("json"),
c.req.valid("param")); response shapes are declared with
.openapi("Name") Zod schemas so they land in the generated spec.
Blank template — one read route:
import { OpenAPIHono, createRoute, z, PageQuery, pageParams, pagedResponse, type AppEnv } from "@clawnify/app";
import { getDB, desc, like } from "@clawnify/db";
import * as schema from "./schema";
const api = new OpenAPIHono<AppEnv>();
const ItemSchema = z.object({
id: z.number(),
name: z.string(),
createdAt: z.string(),
}).openapi("Item");
api.openapi(
createRoute({
method: "get",
path: "/api/items",
summary: "List items",
// Every list endpoint pages: an agent reads this API through one tool,
// and an unbounded list would land in its context whole.
request: { query: PageQuery },
responses: { 200: pagedResponse("items", ItemSchema) },
}),
async (c) => {
const { page, limit, offset, search } = pageParams(c.req.valid("query"));
const db = getDB(c.env, { schema });
const where = search ? like(schema.items.name, "%" + search + "%") : undefined;
const total = await db.$count(schema.items, where);
const items = await db
.select()
.from(schema.items)
.where(where)
.orderBy(desc(schema.items.createdAt))
.limit(limit)
.offset(offset);
return c.json({ items, total, page, limit }, 200);
},
);
export default api;
CRUD template — the full list/create/update/delete surface:
import { OpenAPIHono, createRoute, z, PageQuery, pageParams, pagedResponse, type AppEnv } from "@clawnify/app";
import { getDB, eq, desc, like } from "@clawnify/db";
import * as schema from "./schema";
const api = new OpenAPIHono<AppEnv>();
const ItemSchema = z.object({
id: z.number(),
title: z.string(),
status: z.string(),
createdAt: z.string(),
}).openapi("Item");
const CreateItemSchema = z.object({ title: z.string().min(1) }).openapi("CreateItem");
const UpdateItemSchema = z.object({
title: z.string().min(1).optional(),
status: z.string().optional(),
}).openapi("UpdateItem");
const IdParamSchema = z.object({ id: z.string() });
const OkSchema = z.object({ ok: z.boolean() }).openapi("Ok");
api.openapi(
createRoute({
method: "get",
path: "/api/items",
summary: "List items",
// Every list endpoint pages: an agent reads this API through one tool,
// and an unbounded list would land in its context whole.
request: { query: PageQuery },
responses: { 200: pagedResponse("items", ItemSchema) },
}),
async (c) => {
const { page, limit, offset, search } = pageParams(c.req.valid("query"));
const db = getDB(c.env, { schema });
const where = search ? like(schema.items.title, "%" + search + "%") : undefined;
const total = await db.$count(schema.items, where);
const items = await db
.select()
.from(schema.items)
.where(where)
.orderBy(desc(schema.items.createdAt))
.limit(limit)
.offset(offset);
return c.json({ items, total, page, limit }, 200);
},
);
api.openapi(
createRoute({
method: "post",
path: "/api/items",
summary: "Create item",
request: { body: { content: { "application/json": { schema: CreateItemSchema } } } },
responses: {
201: {
description: "Created item",
content: { "application/json": { schema: ItemSchema } },
},
},
}),
async (c) => {
const { title } = c.req.valid("json");
const db = getDB(c.env, { schema });
const [row] = await db
.insert(schema.items)
.values({ title: title.trim() })
.returning();
return c.json(row, 201);
},
);
api.openapi(
createRoute({
method: "patch",
path: "/api/items/:id",
summary: "Update item",
request: {
params: IdParamSchema,
body: { content: { "application/json": { schema: UpdateItemSchema } } },
},
responses: {
200: { description: "Updated", content: { "application/json": { schema: OkSchema } } },
400: { description: "Nothing to update", content: { "application/json": { schema: OkSchema } } },
},
}),
async (c) => {
const { id } = c.req.valid("param");
const body = c.req.valid("json");
const patch: Partial<typeof schema.items.$inferInsert> = {};
if (body.title !== undefined) patch.title = body.title;
if (body.status !== undefined) patch.status = body.status;
if (Object.keys(patch).length === 0) return c.json({ ok: false }, 400);
const db = getDB(c.env, { schema });
await db.update(schema.items).set(patch).where(eq(schema.items.id, Number(id)));
return c.json({ ok: true });
},
);
api.openapi(
createRoute({
method: "delete",
path: "/api/items/:id",
summary: "Delete item",
request: { params: IdParamSchema },
responses: {
200: { description: "Deleted", content: { "application/json": { schema: OkSchema } } },
},
}),
async (c) => {
const { id } = c.req.valid("param");
const db = getDB(c.env, { schema });
await db.delete(schema.items).where(eq(schema.items.id, Number(id)));
return c.json({ ok: true });
},
);
export default api;
Patterns to follow:
summary/description. The generated
OpenAPI spec is what the agent reads to decide which endpoint to
call — a vague summary makes your endpoint invisible in practice.request.body / request.params
and read it with c.req.valid("json") / c.req.valid("param").
Never parse c.req.raw by hand..openapi("Name") schemas — they
become the documented return type in the spec.src/server — who is callingThe platform authenticates every caller at its perimeter and injects a
verified identity onto the request (it strips any client-supplied
version first, so it can't be spoofed). Your app never authenticates
anyone: no Authorization, no cookies, no JWT, no login screen.
Read it with the helpers from @clawnify/app — don't parse headers
yourself:
import { user, orgId, caller } from "@clawnify/app";
app.get("/api/notes", async (c) => {
const org = orgId(c);
if (!org) return c.json({ error: "unauthorized" }, 401);
const db = getDB(c.env, { schema });
return c.json(
await db.select().from(schema.notes).where(eq(schema.notes.orgId, org)),
);
});
| Helper | Returns |
|---|---|
orgId(c) | Organization UUID — the tenant key. Filter every user-facing query by it. |
user(c) | { id, email, name, avatarUrl, firstName, lastName } — or null when the caller isn't a person. |
caller(c) | user, api, agent, agent-browser, public, bypass, system, or app. |
hasRole(c, min) | Whether the caller may do a task meant for min (member < admin < owner). Use it to gate admin-only tasks. Needs @clawnify/app 0.4.5 or later. |
role(c) | owner, admin or member on Team plans and up; null below that, where every member is treated the same. For display, not for gating. |
Two rules that catch people out:
user(c) is null for five of the eight caller kinds
(agent-browser, public, bypass, system, app). Always handle
the null case — don't assume a person is present just because a
request arrived. For per-user rows, store user(c).id in a user_id
column and filter on it, exactly as you filter on org_id.firstName / lastName are a heuristic split of a single stored
full name (first word / the rest). Fine for a greeting; never persist
them or treat them as someone's legal name — store name.Don't build app-level users, roles, or permissions. Authorization
already happened at the perimeter. For a task meant for admins, use
hasRole(c, "admin"): it checks the role where the plan has role tiers
and lets every person through where it does not, so one check works on
every plan. It fails closed: a caller with no person behind it, or a
request with no identity at all (local pnpm dev), passes no check, so a
gated endpoint answering 403 there is the gate working. Don't loosen a
gate to make a test pass. Never gate on role(c) by hand.
src/client — React + plain fetchThe client mounts React and talks to the API with plain fetch
against the /api/* routes. No data-layer library is scaffolded.
// src/client/main.tsx
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { App } from "./app";
import "./index.css";
createRoot(document.getElementById("app")!).render(
<StrictMode>
<App />
</StrictMode>
);
// src/client/app.tsx (CRUD template shape)
import { useState, useEffect } from "react";
interface Item {
id: number;
title: string;
status: string;
createdAt: string;
}
export function App() {
const [items, setItems] = useState<Item[]>([]);
const [title, setTitle] = useState("");
async function load() {
const res = await fetch("/api/items");
setItems(((await res.json()) as { items: Item[] }).items);
}
useEffect(() => { load(); }, []);
async function addItem(e: React.FormEvent) {
e.preventDefault();
if (!title.trim()) return;
await fetch("/api/items", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ title }),
});
setTitle("");
load();
}
// ...toggleStatus / deleteItem call PATCH/DELETE the same way.
return (
<div className="max-w-xl mx-auto mt-10 px-4">
{/* form + list */}
</div>
);
}
In local dev, Vite proxies /api to the Worker on :8787 (see
vite.config.ts), so the same relative fetch paths work in dev and
in production. The API is the one contract: the UI calls it over
fetch, and the agent calls it over the OpenAPI spec.
If the project contains a DESIGN.md, it is the single source of
truth for visuals — follow its tokens, don't restyle around it. The
scaffold ships Tailwind v4 (via @tailwindcss/vite, imported with
@import "tailwindcss"; in index.css) and nothing else — no
component library. The rules every Clawnify app follows:
clawnify.json — the manifest{
"$schema": "https://app.clawnify.com/schema/v1/clawnify.json",
"version": 1,
"name": "Notes",
"description": "Take and organize notes. Searchable by tag.",
"app": {
"framework": "react+hono",
"database": true,
"storage": false
},
"env": {
"optional": ["OPENROUTER_API_KEY"]
},
"api": {
"public_routes": [
{ "path": "/api/feed", "methods": ["GET"] }
]
}
}
clawnify init writes the minimal form:
{ app: { framework: "react+hono", database: true, storage } }. Add
the rest as needed.
If the app talks to third-party services the user has connected (ads platforms, CRMs, messaging), declare them:
{ "app": { "credentials": ["metaads", "googleads"] } }
Get the ids and names from clawnify connections list — see the
naming rule below.
env supports required (deploy warns if missing), optional
(injected when available), and oneOf (at least one per group).
Rules:
api.tools[]. The manifest's api object only
accepts public_routes and automation_bypass. Your API surface
is discovered from the generated OpenAPI spec, not a hand-authored
tools list (see the next section).api.public_routes. Use only for
webhooks, RSS, embedded feeds.framework: "react+hono" for new apps. Never preact+hono or
vite-preact — those are legacy.database: true if the app uses a DB. schema.ts defines the
tables; run pnpm db:generate after changing it.api.tools[])The old tRPC stack emitted an api.tools[] array from procedure meta.
That mechanism is gone. Today the flow is:
createRoute definitions auto-generate a live OpenAPI 3.0 spec
plus a lean /llms.txt index, both served for you — never hand-write
or route them yourself. These are the agent's discovery channel:
it reads GET /llms.txt (index of every endpoint) or
GET /api/openapi.json (full request/response schemas) on the live
app. Because both are generated from the live route table, they
cannot drift from the code.clawnify_call_app_api; Claude, ChatGPT and other MCP
clients use clawnify_app_api_read (GET), clawnify_app_api_write
(POST, PUT, PATCH) and clawnify_app_api_delete. No per-app MCP
registration and no manifest tools array. Use source reading to
modify code, not to discover endpoints.So you make an endpoint "agent-callable" by defining it with
createRoute() + app.openapi() and giving it a clear
summary/description with Zod-typed request/response. The clearer
those are, the more reliably the agent uses it.
agent.md — lead with the procedure, not the endpoint listagent.md is extracted into agent_instructions on every build. Since
discovery is already covered by the generated surfaces above, agent.md
is not an API reference — re-listing every payload there just creates a
second source of truth that goes stale the first time a route changes.
It is the one place for what generation can't produce: judgment.
Write it in this order:
/llms.txt.Don't ship a per-app skill. A skill's frontmatter stays resident in
agent context, so one skill per app grows the agent's context floor as
the app count grows; agent_instructions and /llms.txt are pulled on
demand instead. Skills are for cross-app procedures — if one earns
reuse across more than one app, promote that single procedure
(parameterized) to the shared skills library rather than copying it into
every app.
@clawnify/connectionsThe naming rule — never invent an identifier. Before declaring
credentials or env names, run clawnify connections list: it shows
the org's canonical integration ids (googleads, never google_ads),
the fixed provider-key names (OPENROUTER_API_KEY, never
OPENROUTER_KEY), and custom env vars already defined — each with
connected/set state. Reuse those exact identifiers; a misspelled one
doesn't fail the build, it silently resolves to nothing at runtime. If
you need a custom secret that isn't listed, pick a clear name and tell
the user to set it in the dashboard.
If the app needs a third-party service or a provider API key, use
the @clawnify/connections SDK. Never read credential bindings
directly, never paste API keys, never hardcode a token or endpoint.
import { connect, secret, describe, searchActions } from "@clawnify/connections";
// A connected integration:
const meta = connect("metaads", env);
const accounts = await meta.adAccounts("name,currency");
// A provider key the user supplied (null if absent):
const key = secret("OPENROUTER_API_KEY", env);
// What's wired vs missing — drive your setup/empty state from this:
const status = await describe(env, undefined, REQUIRES);
How to call a connected service — the mistake that silently breaks integration apps, so get it right:
meta.adAccounts(...), googleads.query(gaql)).const [best] = await searchActions("list google ads campaigns", env);
const data = await connect(best.service, env).run(best.slug, body);
connect("bird", env).get("/path")) — but if .get()/.post()
throws for a service, that service only supports semantic methods
and run(). When unsure, use run().spec_url (the provider's published OpenAPI spec) —
clawnify connections list --json shows it. Save the spec to a file
and query the file, for example jq '.paths | keys' spec.json; never
read a whole spec into context (they run to 10+ MB).fetch against a provider API, and
never invent endpoints or guess tokens.The one exception — a service we don't support at all. If a
provider isn't in the connections registry (nothing to connect()
to, and clawnify connections list doesn't show it), the sanctioned
path is a raw call with a user-supplied key: declare the key(s) it
needs in clawnify.json env (required/optional/oneOf), tell
the user to set them in the dashboard, read them with
secret("THAT_KEY", env), and fetch the provider's documented
endpoints directly. This is the escape hatch for the long tail of
integrations we don't model yet — it does not apply to a service
we do support (use connect() / run() for those, always). Keep
the endpoint and token server-side, never in the client bundle.
Build a describe()-driven setup state instead of assuming
connections exist — show the user what's missing and where to
connect it.
A deployed app cannot bind Cloudflare Queues, Durable Objects, or cron
triggers (the platform builds every app with a fixed binding set: DB +
ASSETS + UPLOADS). To run work later — a scheduled publish, a reminder, a
retry, a "do this in 10 minutes" — use the Clawnify managed queue service
over HTTP. It owns the clock, retries, and at-least-once delivery, then calls an
endpoint on your own app back at the scheduled time.
Use the published @clawnify/queue package — enqueueJob, cancelJob,
verifyDelivery — same shape as @clawnify/db / @clawnify/connections.
Auth is the build-injected env.CLAWNIFY_TOKEN; with no token (local dev)
it degrades to a no-op.
Enqueue a deferred call to your own endpoint:
import { enqueueJob, cancelJob, verifyDelivery } from "@clawnify/queue";
const job = await enqueueJob(env, {
targetUrl: `${origin}/api/internal/publish`, // an endpoint on THIS app
payload: { post_id: id }, // echoed back to you on fire
runAt: new Date(whenMs),
idempotencyKey: `post:${id}:${whenMs}`, // same key dedupes; new time = new job
});
// job.id: store it to cancel or reschedule
Persist job.id on the row (e.g. posts.queue_job_id). Cancel / reschedule:
await cancelJob(env, jobId); reschedule = cancel + a fresh enqueue.
The callback endpoint is a public, signature-verified route. The queue calls
target_url from outside the perimeter, so the endpoint must be declared in
clawnify.json public_routes and verify the delivery signature itself —
the signature is its auth (never trust an unsigned call):
// clawnify.json
"api": { "public_routes": [ { "path": "/api/internal/publish", "methods": ["POST"] } ] }
Deliveries are signed with the platform's ECDSA P-256 (ES256) key,
Stripe-style over ${timestamp}.${rawBody}, verified against
https://services.clawnify.com/.well-known/jwks.json (public key — nothing
breaks on token rotation). Read the raw body, check the signature + a timestamp
tolerance (~5 min) before doing anything:
app.post("/api/internal/publish", async (c) => {
const raw = await c.req.text();
const ok = await verifyDelivery(raw, {
signature: c.req.header("x-queue-signature"),
timestamp: c.req.header("x-queue-timestamp"),
keyId: c.req.header("x-queue-key-id"),
});
if (!ok) return c.json({ error: "bad signature" }, 401);
const { post_id } = JSON.parse(raw);
// …do the deferred work (short: it's one normal Worker invocation)…
return c.json({ ok: true });
});
Each fire is a normal Worker request — size the work to one invocation (publish a post, send a digest). For long compute now (not deferred), hold the request open and return when done; don't fire-and-forget past the response.
When the queue says no. A refused enqueue answers { "error", "detail" }
(enqueueJob throws ClawnifyQueueError with code, status and message).
Past the plan's monthly included jobs each job costs credits, so only an empty
balance (402 insufficient_credits) or no active plan (403 quota_exceeded)
refuses one; show its detail to the owner as it is, since it says where to fix
it. A job that books the next one (a daily sync) must never swallow that
refusal: keep it, show it as a banner on the app's main page, and return it from
the app's status endpoint. Every service error code:
https://docs.clawnify.com/concepts/service-errors
The workflow is:
src/server/schema.ts for the new shape (types + queries).pnpm db:generate — emits the migration SQL under
.clawnify/drizzle/.npx clawnify@latest dev locally, then npx clawnify@latest deploy.On deploy your schema changes are applied to the app's database — new tables and columns are added automatically.
Destructive changes (drop column, rename) are not applied automatically; do them deliberately, and only when the user explicitly asks. Renames are risky on production data — prefer "add new column, backfill, switch queries, drop old column" over a single-step rename.
/openapi.json or /llms.txt handler by hand. createApp()
mounts both, generated from your createRoute definitions.schema.sql, edit anything under .clawnify/, or add a
root drizzle.config.ts. Schema changes happen in schema.ts; the
CLI generates and applies the SQL.api.tools[] array in the manifest. It isn't a valid
field — the OpenAPI spec is the tool surface.JSON.stringify on query params. JSON columns auto-serialize
via Drizzle. The raw SQL API has json() as a helper.org_id filter on a user-facing query. Multi-tenant
leak is the worst-class bug we can ship.PageQuery, pageParams and pagedResponse from @clawnify/app.Authorization / cookies / Bearer tokens, or
hand-parse X-Clawnify-* headers. Use user(c) / orgId(c) /
caller(c) from @clawnify/app.fetch or hardcoded tokens. Go
through @clawnify/connections (connect / secret / run).drizzle-orm as a separate top-level dependency.
@clawnify/db@^0.4.1 pulls it in transitively; only add it if you
need to pin a specific version (rare).@clawnify/db where possible
(getDB, eq, and, desc, sql, sqliteTable, text,
integer, index, etc. are all re-exported there). Drop to
drizzle-orm directly only for things not re-exported.summary/description and Zod-typed
request/response so the agent can discover and call it via the
OpenAPI spec.@clawnify/app exports:
request: { query: PageQuery.extend({ /* filters */ }) },
const { page, limit, offset, search } = pageParams(c.req.valid("query"))
(25 per page by default, capped at 100, bad input falls back), and
responses: { 200: pagedResponse("items", ItemSchema) } for
{ items, total, page, limit }. Count with db.$count(table, where).PATCH, or a PUT that keeps the
fields it is not sent) on the same path, returning the updated
record. Agents then read it in parts and change it with literal
old_text → new_text edits instead of sending all of it back; the
platform provides that, so don't build a find/replace endpoint.DB<typeof schema>
(from @clawnify/db), and a separate routes file's env as AppEnv
(from @clawnify/app). Never name the backend (D1Database,
DrizzleD1Database) or cast getDB's result: the same app code is
served by more than one database backend.npx clawnify@latest dev before deploying; deploys go live at
https://<slug>.apps.clawnify.com (the dashboard's preview pane shows
the draft tier).@clawnify/db
README for the current API + version notes.Apps that let END users define data shapes at runtime (CMS, no-code
table editor) can't model their schema in schema.ts — the table
definitions live in rows. Those apps fall back to the raw SQL API
from @clawnify/db (query, get, run, json). Open-cms is
the canonical example.
If you're building this kind of app, you still use Drizzle's
schema.ts for the registry tables (content types, field
definitions). Only the dynamically-spawned per-collection tables
need raw SQL. See open-cms's src/server/schema-sync.ts for the
runtime DDL pattern.
Every Open* repo under github.com/clawnify
is a complete, open-source app running on this platform. When your
app hits an error you can't resolve from this document, find one that
does the same thing and compare how it does it.
clawnify.json
declares it: app.credentials lists its integrations (metaads,
googleads, ...), app.database and app.storage say whether it
uses D1 and R2. The README says what the app does.https://api.github.com/orgs/clawnify/repos?per_page=100, and fetch
any file at https://raw.githubusercontent.com/clawnify/<repo>/HEAD/<path>
(HEAD resolves the default branch, which is not always main).src/server/schema.sql instead of schema.ts, some use Preact, and
older ones don't page their lists with the @clawnify/app helpers.@clawnify/* package, read what you
installed: node_modules/@clawnify/<pkg>/README.md and
dist/index.d.ts, which match your version exactly.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub clawnify/skills --plugin clawnify6 skills in this plugin
/build-a-clawnify-websiteBuild and ship a Clawnify website (Astro on Cloudflare Workers) with built-in forms, images and assets. Use when creating or editing a website, adding a contact/waitlist/signup form, deploying local edits, or publishing an existing website draft./clawnify-knowledgeRoute a question to the right Clawnify knowledge source before answering or building. Covers how-to-use-Clawnify product docs, your org's company knowledge (brand, pricing, policy, SOPs), a specific client or project's reference, and durable memory. Use whenever a task needs a company fact, a platform how-to, or client-specific context from a connected Clawnify organization./fix-a-clawnify-agentOther plugins' skills for the same job