Stack: typescript server, react client.
Generated by MetaObjects (refresh:
meta init --refresh-docs). Put project notes in your rootAGENTS.mdorCLAUDE.md, not here: this file is regenerated.
The metadata (metaobjects/ unless .metaobjects/config.json says otherwise) is the source of
truth. Code, schema and migrations are generated from it and are regenerated output.
-
Config. In
metaobjects.config.tssetdialect("postgres" | "sqlite" | "mysql"; D1 is"sqlite") and list the generators. Nothing is generated until it is listed. The usual data layer:import { entityFile, namesFile, barrel } from "@metaobjectsdev/codegen-ts/generators"; // generators: [entityFile(), namesFile(), barrel()]
Per entity:
<Entity>.ts(Drizzle table, row types, Zod schemas, enum types) and<Entity>.names.ts(physical names), plus anindex.tsbarrel. Install what they import:npm i drizzle-orm zodand your database driver. Every other generator (CRUDqueriesFile()/routesFile(), docs,requirementTests()) is one line too;npx meta gen --listis the catalog.npx meta eject <name>copies one intocodegen/generators/to change it;npx meta generator new <name>writes a new one. -
Generate.
npx meta gen. See a file's exports withgrep -n "^export" <file>. WhenagentDocsFile()/apiDocsFile()are wired, read theagent/*.mdorapi/AGENT-API.mdpage for the tier you touch.
The client tiers are generators in metaobjects.config.ts, whatever the backend: formFile()
from @metaobjectsdev/codegen-ts-react, tanstackQuery() and tanstackGrid() from
@metaobjectsdev/codegen-ts-tanstack, with the runtime packages @metaobjectsdev/react and
@metaobjectsdev/tanstack. Wrap the app in <EntityFetcherProvider fetcher={...} baseUrl="/api">:
baseUrl is where the server mounts its routes, and leaving it out drops that prefix from every
hook without an error. The metaobjects-runtime-ui skill has the detail.
A commit that changes behaviour updates them in the same commit: @status: live once a claim
is built (never before), a new node for new behaviour.
npx meta verify --codegen(the generated code and docs pages; the requirement gate runs on everymeta verify).
Commit the metadata, the generated code and .metaobjects/.gen-state/.hashes/.
When the project serves the generated routes (any port):
- Filter as
?filter[<field>][<op>]=<value>:?filter[status][eq]=active, never?status=active(TypeScript refuses that with 400; the other ports ignore it). Operators:eq,ne,isNull(true/false),in(comma list, at most 100),like(case-sensitive,%and_),gt,gte,lt,lte. Filters AND; only@filterablefields filter. ?sort=<field>:asc|desc,?limit=N&offset=N;withCount=1returns{"rows", "total"}. Always sendlimit: without it the project'sapi.pagination.defaultLimitapplies, or with none set C# returns every row, the other ports 50; abovemaxLimitis 400.PUTis the same partial update asPATCH. Send only declared fields: an undeclared key is 400unknown_fields(unlessapi.unknownFieldsisdrop).- Errors are
{"error": "<code>"}: 400 for validation (issueslists each problem) and for a bad filter or sort (invalid_filter_field,_op,_value,invalid_sort, each namingfield), 404not_found, 409 for a unique or foreign-key conflict.
- What the metadata describes is generated, never hand-written (tables, types, validators, foreign keys, schema, migrations). Hand-write only what it cannot describe, on top.
- Never hand-edit generated output: change the metadata and regenerate. Output wrong for you, or broken? Fix the generator: eject it and it is yours, no permission needed, nothing to wait on.
- Never spell a table or column name as a string; use the generated table or names constants.
- Wire a generator only for output you will import.
- An LLM prompt in a project that declares
template.promptis a declared template (metaobjects-prompts); a grouped total or report view is anobject.report(metaobjects-authoring). Open the skill before writing either by hand. - Never invent metadata vocabulary. Search it:
npx meta types <term>, andnpx meta types <type>.<subType> --detailfor one construct's valid attributes. Vocabulary of your own says what a thing is and relates to, never a product, a version or a step. - Metadata nodes are fused-key maps,
{"field.string": {"name": "email"}}. Attribute names are unique within a node, and package paths use::.
The loop above needs no skill. For less common work load a metaobjects-* skill by name, or open
.claude/skills/<skill>/SKILL.md if your assistant does not load skills: metaobjects-authoring
(unusual shapes, your own vocabulary, reports, adopting existing code), metaobjects-codegen
(owning or writing a generator), metaobjects-runtime-ui (REST routes, the web client), metaobjects-prompts (LLM
prompts), metaobjects-verify (migration edge cases, drift, upgrades), metaobjects-audit (an
adoption review). Each names the one reference page to open.
meta init --refresh-docs regenerates this file and the skills, so keep project guidance in
the root AGENTS.md or CLAUDE.md (or copy a skill to a new name). A refresh never overwrites a
file you edited; it writes <path>.new beside it, which you merge into <path> and delete.
Never --force a refresh over local edits.