Concepts
Compiling
Function
Returns
Function
compilePage(doc, pageId, options)
Returns
One page: html, css, the scripts it needs, stats and any problems
Function
compileSubtree(doc, pageId, nodeId, options)
Returns
One node's html and css in editing mode, with class names prefixed by the node id so a replaced part never collides with the page, plus the page-wide pageCss
Function
compileSite(doc, options)
Returns
A file for every page that is switched on, and a manifest of scripts and styles with their sizes
Options: registry (required), data, mode ('live', 'edit' or 'measure'), links (how page slugs and file ids become addresses), lang and fontBase.
Each of these validates first. If the document, the rows or an option has a problem, the result is ok: false with the problems, and nothing is compiled.
What a page contains
All static content is in the HTML. A page with no live node and no island is complete with scripts off; on a page that has them, a live list has no rows, a live form sends nothing and a framed island is blank until its script runs (app/live-data.md).
One <style> element: font faces, base CSS, the look and the page's own rules. Nodes with the same rules share one class.
In live mode, one inline script made of the parts the page needs:
Script
Size
Included when
Script
base
Size
304–688 bytes
Included when
always (includes open/mail when used)
Script
states
Size
1,654 bytes
Included when
a node on the page uses states or triggers
Script
timeline
Size
4,681–7,214 B
Included when
the rendered page needs the motion host
Script
gpuLoader
Size
893 bytes
Included when
the page renders GPU/WASM regions in main
Script
gpuHost
Size
9,513 bytes
Included when
lazy _culm/gpu.js asset (loaded via SRI)
A site can opt into three more scripts, each its own file loaded with an integrity hash, only on a page that uses it: live data and sign-in (_culm/live.js), in-place page changes (_culm/nav.js) and islands (_culm/islands.js, with a sandboxed frame for an island that comes from a package). A site with tools on and a listed plug-in that supplies a tool script also gets _culm/agent.js, loaded the same way on a page that carries a tool table (app/actions.md). Every page still holds all its static content; a live list has no rows, a live form sends nothing and a framed island is blank until its script runs. The site policy is written first in every page. See app/live-data.md, app/islands.md, app/packages.md and app/policy.md.
In editing mode there is no script, and every node's element carries data-id so an editor can map the page back to the document.
A text node still marked as an untouched sample is left out of a live page and kept in editing mode.
Budgets
What
Ceiling
What
All shared scripts on a page
Ceiling
20,000 bytes
What
Base script
Ceiling
10,000 bytes
What
States script
Ceiling
6,193 bytes
What
Timeline script
Ceiling
8,192 bytes
What
GPU host script (_culm/gpu.js)
Ceiling
9,513 bytes
What
Shader source per page
Ceiling
16,384 bytes
What
CSS per page (a site can change it: limits.css in culm.json)
Ceiling
16,000 bytes
What
Elements per page
Ceiling
2,000
What
Nesting depth
Ceiling
12
What
Live, navigation and islands scripts, island modules and frame runtimes, together
Ceiling
12,000 bytes (appScripts)
What
Live script
Ceiling
6,000 bytes
What
Navigation script
Ceiling
2,500 bytes
What
Islands script
Ceiling
3,500 bytes
What
Tool script (toolScript), checked when its plug-in registers
Ceiling
3,000 bytes
Sizes are raw minified bytes. Shader source counts the final text shipped, one trailing newline per definition. The 512-byte raw / 684-byte base64 WASM module ceilings are enforced when an effect is registered, not per page. compilePage reports a page that passes a ceiling as a RESOURCE_LIMIT_EXCEEDED problem and returns its real figures in stats.
The three app scripts are separate files (_culm/live.js, _culm/nav.js, _culm/islands.js, each loaded with an integrity hash), loaded only on a page that opts in, and count against appScripts, not the shared 20,000. At the time of writing they are 5,026, 2,318 and 2,719 bytes, and a frame's runtime is 714 bytes for each frame on a page. See app/live-data.md. The tool script (_culm/agent.js) is also a separate file with an integrity hash; its bytes are reported and are not counted against appScripts, and it is held to 3,000 bytes when its plug-in registers.
CSS-only motion ships no timeline script. The shared 20,000-byte cap applies independently of the individual script ceilings. The stage comparison gives measured byte totals and the desktop and phone frames the owner accepted; the Stage 3c blind recreate rerun and the matched Culm vs. Astro & GSAP comparison are closed.
Measure
The measure layer of the core says what is wrong with a rendered page, in a form an agent can act on, and confirms a repair. It has no browser in it: it takes measurements that a runner made and returns findings.
PROBE_SCRIPT is one function a runner evaluates in the page. It returns, for every element with a node id, its box, whether it paints, its background, clipping, text lines and size, and tap size.
runChecks(input) takes those measurements for every layout of one page, and returns findings. There are 31 checks and one row for a compile problem (invalid). Class 1 is a compile problem, class 2 a defect (off-screen, overflow, h-scroll, overlap, contrast, tap-target, and for shapes shape-covers, shape-complex and raw-colour; and the design findings stretched-button, header-edge, hero-bare, orphan-heading, bleed-gutter, all-stacked, no-accent, chrome-as-inserted, side-stripe, gradient-text, glow and emoji-icon, each with a fix) and class 3 taste (
column, alignment, symmetry, rhythm, empty-band, line-length, heading-order, duplicate-heading, stacked-row, phone-order). The thresholds are in THRESHOLDS. runChecks takes the document (doc), not a root, and unrolls the header, the page and the footer itself.
A finding names the check, the class, the page, the width, the theme, the direction, the nodes, what was observed, what was expected, and a key (findingKey) that is the same on every run for the same defect.
buildReport joins the findings of many cells into one Report, and compareReports(old, new, doc) says, for each earlier finding, whether it is fixed, still present, unobservable (every node of the finding is gone or hidden at the finding's width) or unchecked, and lists the findings that are new.
The measure profile is version 1: widths 1280, 834 and 390, themes light and dark, each direction the site's languages declare, and the default state of each part. MEASURE_PROFILE is that version, and a report says what the profile skipped.
compilePage accepts mode: 'measure' for a runner: the live page with the node ids on its elements. compileSite and culm build never use it.
isRequired(node, form?) is also public: the rule that decides whether a node is required, so a product's guard cannot drift from core's.
Tools
@culmjs/tools depends on @culmjs/core (a peer dependency), @modelcontextprotocol/sdk, jsonc-parser, htmlparser2 and postcss. It adds what needs files, a browser or a port.
What
Does
What
Folder sites
Does
loadFolder reads a folder of JSON files into the document with a source map; fileStore is a SiteStore that writes changes back into the same files and keeps history in .culm/
What
culm command
Does
init, dev, build, check, add, approve, expand, render, schema, agents, mcp
What
Dev server
Does
Serves the pages on 127.0.0.1, reloads on save, and shows an overlay with file, line and message when a save has a problem
What
Measure runner
Does
Opens Chrome over the DevTools protocol on a pipe, with no dependency and no port, and runs the probe and the checks on every page
What
MCP server
Does
createMcpServer: 6 authoring tools by default (culm mcp / jsonOps: true, including render), or 12 full tools (culm mcp --full), over stdio and optionally a local HTTP port with a bearer token
What
JSON Schema
Does
authoringSchema(registry) and culm schema: completion and checks for the folder's files in an editor
Read docs/folder-sites.md for the folder format, .culm/ and the commands, and docs/mcp.md for the MCP tools, what protect refuses and the local port.
A new site
culm init writes a blank site: culm.json with no plug-in, site.json with the default look, named styles, a header (site name and menu) and a footer (note and menu), and one page, pages/home.json, with a heading and one line under it. It registers no block. The data is BLANK_SITE in packages/tools/src/cli/blank.ts, and
packages/tools/__tests__/cli/blank.spec.tsshows that it loads, compiles and passes the schema with no problem.
Tokens: colours ink #1c1917, canvas #fafaf9, brand #b45309, muted #57534e, line #e7e5e4; text styles eyebrow 11, body 17, lead 20, h3 24, h2 32, h1 48. A new site sets textRange to 11–96px for regular text with displayMax: 240 for H1/H2. Phone size, leading and tracking can be set independently. Spacing: xs 4, s 8, m 16, l 24, xl 40, 2xl 64. Fonts are the system stacks only. The home heading is required content.
First run
npx @culmjs/tools init my-site
cd my-site
npm install
npx culm dev # serve the site; reloads on save
npx culm build # write the site to dist/Nothing is on npm yet, so until a release the steps above do not work. From a checkout of this repository, run npm run pack:all (it writes four tarballs to .pack/; init uses the core and tools ones), then
node packages/tools/bin/culm.js init my-site --from .pack, then npm install in my-site. --from <folder> is a folder that holds culmjs-core-*.tgz and culmjs-tools-*.tgz; init then writes file: dependencies on them in place of version numbers. A relative --from is resolved against the folder you run the command in.
culm init <folder> [--from folder] writes the blank site into a new or empty folder. A folder that holds anything, hidden files included, is refused, and the message lists up to five of the names found. It also writes a package.json, a culm.schema.json and a .gitignore (which excludes node_modules, dist and .culm/).
Previous