# Build a module for Creative Chief

**Kit version 4** (2026-11-10). Claude writes this number into each module as `"kit": 4` (section 3). When the kit changes, its number goes up, and Creative Chief tells a module's author when one of theirs was built with an older kit.

**Contract 2.0 (a module in a sandbox, section 1a) · kit for Creative Chief v0.4.0-alpha.104 and later · 2026-11-10** (kit 3's modules, for alpha.47 and later, still work; an older Creative Chief ignores `icon`, `summary`, `chat` and `page.side`) (older modules say contract 1.1; for them: sections in the right panel and reading websites need alpha.7; limit codes in the Shop's report and Request a capability need alpha.8; category tabs and Add to group shop need alpha.9, and an older Creative Chief ignores `category`)

This file is for two readers.

**You (the person making the module):** start a new chat with Claude and attach this file, or paste all of it in. Then say what your module should do, in plain words. Claude writes its files (with an icon, `icon.svg`). You drop them in **Your modules** in Creative Chief (in **You**, with **Creator mode** on), and it checks them. If it finds a problem, copy its report back into the same chat. The last part of this file has the steps.

**Claude:** everything you need is in this file. You don't need Creative Chief's source code, and you don't need to run anything. Follow "What to give back" exactly, and use only the parts of `core` described here. If something the person wants isn't possible with what's here, follow section 14, "When something can't be done": say so plainly, build the closest thing that works, and write a capability request.

**What changed in each kit version** (for a module built with an older kit, add what's new since its `kit`):

<!-- kit:start (made from Creative Chief's own list; don't edit by hand) -->
**Kit 4** (2026-11-10):
- An icon: icon.svg, a square SVG picture beside manifest.json, and "icon": "icon.svg" in manifest.json; the Apps grid and the Shop show it in place of the module's first letter (section 3, "Your module's icon").
- A summary: "summary" in manifest.json, one line of up to 80 characters that the Shop shows under the name; the description stays for more (section 3).
- Tools beside a page: a "page.side" place, { "hook": "page.side", "id", "page", "title" }, shown beside that page on a wide screen and from a button at the top on a phone (section 5, "Tools beside your page").
- A chat: "chat": { "log", "title" } in manifest.json makes one of its shared logs a chat that Creative Chief draws in Chat; don't draw a message box of your own (section 5, "A chat for your module").
- core.ui.tell(data) hands plain data (8 KB at most) to the module's other open frames, which hear it as core.events.on("told", fn) (section 5).
- "kit": 4 in manifest.json.

**Kit 3** (2026-11-04):
- The module runs in a sandbox: "contract": "^2.0" and "sandbox": 1, with the places it draws ("places"), its actions ("actions") and its undo types ("undo") listed in manifest.json (section 1a).
- Calls to another module's capability give promises (await them); ready(), relay() and domains() still answer at once (section 1a).
- Each place it draws is its own copy of the module: keep what two places share in core.settings() or core.storage.json (section 1a).
- Links open after the person says Open; forms, alert and confirm work as usual; there is no network but web.fetch (section 1a).
- "kit": 3 in manifest.json.

**Kit 2** (2026-11-03):
- A module that provides a capability describes it in "offers": what it does, how to call it and an example, so the Shop's What modules offer list shows it to friends and their Claude (section 3).
- To work with a friend's module, use the block the person pastes from the Shop (What modules offer, Copy for Claude): put the capability in enhancedBy, check core.capability(...) for null, and keep the module working without it (section 5, "Working with other modules").
- Adding to the person's own Google Calendar: w.run("create_event", …) inside core.write, keeping the event's id to change or remove it later (section 6, "Adding to the person's calendar").
- "kit": 2 in manifest.json.

**Kit 1** (2026-11-03):
- Every thing a person can add or change has a write action that calls the same function as its button, and that function does its own core.write (rule 8, section 6).
- A "category" from the Shop's list (section 3).
- Phrases people can type in Main Chat with no AI, for its actions ("phrases" in manifest.json), and a "said" sentence in each action's result (section 6, "Phrases people can type").
- "kit": 1 in manifest.json.
<!-- kit:end -->

**New in kit 4** (Creative Chief v0.4.0-alpha.104): a module has **an icon** (`icon.svg`) and **a summary** (one line for the Shop), section 3; it can have **tools beside its page** (`page.side`), **a chat** that Creative Chief draws in Chat (`"chat"`), and **`core.ui.tell`** between its open frames, section 5. A kit-3 module still works; its author sees "Built with an older kit" with what changed.

**Added to kit 4 on 2026-11-26** (Creative Chief v0.4.0-alpha.222; the number stays 4, nothing older breaks): **inviting your group**. `core.chat.invite` puts an invitation to a game in the group chat, drawn by Creative Chief as a card with **Join**, which opens your page there; `core.chat.mark` says when it's full or over (section 5, "Inviting your group"). Check it's there first: an older Creative Chief doesn't have it.

**Added to kit 4 on 2026-11-25, again** (Creative Chief v0.4.0-alpha.220; the number stays 4, nothing older breaks): **news on Today**. `core.hooks["today.line"]` gives Today's "In <group>" card a line from your module, like "Ann pinned a picture", with how long ago and a › to your page (section 5). Check it's there first: an older Creative Chief doesn't have it.

**Added to kit 4 on 2026-11-25** (Creative Chief v0.4.0-alpha.218; the number stays 4, nothing older breaks): **who's on**. `core.people()` says who is in Creative Chief now: `online`, `status` (`"active"` or `"away"`) and `statusText`, the words they wrote (section 5). A game can offer a table to the people who are around.

**Added to kit 4 on 2026-11-23** (Creative Chief v0.4.0-alpha.207; the number stays 4, nothing older breaks): when you drop a module in Your modules, its check warns about the phone budget's heavy patterns (section 8a, "Checking it"), and **Preview** shows it in light and dark before you share it (section 8, "Check it in dark before you share it").

**Added to kit 4 on 2026-11-14, again** (Creative Chief v0.4.0-alpha.133; the number stays 4, nothing older breaks): section 8a, **Talking without bursts**: save only what changed, one hello at a time, each frame has its own memory, a picture in one piece, ask for many things a few at a time, and an add-on starts again each time its parent does. Rule 7 says what the guard does now: calls over the limit are held back and go through a moment later; only a module that keeps going over for five seconds is switched off.

**Added to kit 4 on 2026-11-14** (Creative Chief v0.4.0-alpha.132; the number stays 4, nothing older breaks): section 8a, **the phone budget**, for every kind of module: what a phone can hold (Today's section still and light, a module's own page rich, one scene at a time), what's costly and what's cheap on an iPhone, worked examples that keep a module beautiful within it (a rare pull with foil, a game, ambient motion, a gallery, shared things, charts), and how to bring an existing module up to it, keeping its look. It's advice: nothing is refused for it.

**Added to kit 4 on 2026-11-13** (Creative Chief v0.4.0-alpha.126; the number stays 4, nothing older breaks): the sizes of a shared log's `append` are written down (section 7: 50 lines in one call, 4000 characters a line), and Creative Chief's refusal now names the one that was broken. Section 8 has a part on **dark mode**: how to design for it, how your module knows which mode is on, and to check it in dark before you share it.

**Added to kit 3 on 2026-11-07** (Creative Chief v0.4.0-alpha.81; the number stays 3, nothing older breaks): shared data shows without a refresh. `log.watch(fn)` on a shared log (section 7) is called each time anyone adds to it, your own line at once; Creative Chief watches the commons for every module (since alpha.82, the logs of the module you have open are checked one by one, about every 1.5 seconds while someone else is in it), so **never poll a shared log with a timer of your own**. "Here now" beats only while your module is on screen (alpha.82). A module without `log.watch` has its right-panel section's and page's `refresh()` run instead. `agenda.items` now works for a module in a sandbox (register it in `setup`; section 5). `sync.slice` is gone from this kit (nothing read it; use `core.storage.json`).

---

## 1. What a module is

Creative Chief is a web app that friends use as a small shared intranet. It keeps everything in each person's own Google Drive and has no server. Almost everything in it is a module, and the person can switch any module on or off: Calendar, Tasks, Projects, the Journal, the Looks and the AI.

A module is **a folder with two files**, its icon and its changelog:

| File | What it is |
|---|---|
| `manifest.json` | What the module is: its name, its version, what it needs and what it writes. Data only. |
| `module.js` | The code: **one file** with `export default function setup(core) { … }` and **no `import` lines**. |
| `icon.svg` | Its icon (kit 4): a square SVG picture the Apps grid and the Shop show (section 3, "Your module's icon"). Optional for the check, but always make one. |
| `CHANGELOG.md` | Optional, but needed for sharing: one `## x.y.z` section per version, saying what changed. |

The module runs inside Creative Chief in the person's browser. It can't do anything on its own. It asks the core (the `core` object handed to `setup`) for everything: storage, saving changes, showing things on screen, timers.

## 1a. In a sandbox (kit 3)

**Every module you make now runs in a sandbox** (Creative Chief v0.4.0-alpha.47 and later; from 1 January 2027, a module that isn't in one stays off and can't be installed): each place it draws is a frame of its own that can't reach the person's sign-in, their other files, the rest of the page or the internet. It asks Creative Chief for everything, by message, and Creative Chief checks each ask. Friends can install it without trusting it with their whole Google account. What that means for the module:

- **manifest.json** says `"contract": "^2.0"` and `"sandbox": 1`, and lists, so Creative Chief knows them without running any code:
  - `"places"`: where it draws. `{ "hook": "page", "id": "main", "title": "My module" }` with `{ "hook": "nav.item", "id": "main", "label": "My module", "page": "main" }` for a tile in Apps and its page; `{ "hook": "today.section", "id": "now", "title": "…", "places": ["today"] }`; `{ "hook": "settings.page", "id": "<id>" }`; `{ "hook": "project.section", "id": "…", "title": "…" }`. A module with no screen lists `[]`.
  - `"actions"`: each action it registers, as `{ "name", "description", "params", "write", "undo" }` (the same as in `core.actions.register`, without `run`).
  - `"undo"`: the undo types it registers, like `["my-module.note"]`.
- **The code is the same shape** (`setup(core)`, the same hooks, `core.write`, `core.storage.json`, `core.settings()`, `core.changes.record`, `core.ui.done`, `core.timer`, `core.presence`, the commons' logs). Draw only inside the element a hook hands you: it is the frame's own page.
- **Each place is its own copy of the module.** A page, a right-panel section and the module's actions don't share variables. Keep what two places both need in `core.settings()` (this browser) or `core.storage.json` (the person's Drive).
- **Shared data shows without a refresh** (alpha.81): `log.watch(fn)` on a shared log (section 7) runs when anyone adds to it. Creative Chief looks for every module: often while someone else is in your module, rarely otherwise, never while hidden. Don't poll a shared log with `core.timer`.
- **Capabilities answer later:** `await core.capability("x").method(…)`. `ready()`, `relay()` and `domains()` still answer at once, so `if (ai && ai.ready())` works as before. Only plain data goes both ways (no functions, no elements).
- **No network** but `core.capability("web.fetch")` (and `web.lookup`). Links to websites open after the person says **Open** (a plain `<a href>` does that, or `core.ui.openLink(url)`). Forms, `alert`, `confirm`, Copy buttons and downloading a file the module made work as usual.
- **Full screen, one button** (Creative Chief v0.4.0-alpha.214): `core.ui.fullScreen(true)` from a tap on a button of yours, `core.ui.fullScreen(false)` to leave. It uses the browser's full screen where there is one (it answers `"screen"`), and where there isn't (an iPhone, or Creative Chief installed on an iPad's or iPhone's Home Screen) Creative Chief lays your page over its whole window, with its own **Done** in the top right corner (it answers `"window"`). Escape and Done leave too, so label your button from `core.events.on("fullScreen", (how) => …)`, which you hear each time it changes: `"screen"`, `"window"` or `""`. Call it inside the tap's handler (the browser's full screen needs the tap), and keep the top right corner clear for Done. From a Today card where the browser has no full screen, your page opens and fills the window. In the drop's preview nothing happens (it answers `""`). Check `if (core.ui.fullScreen)` first (an older Creative Chief has none), and use the browser's own then, below.
- **Full screen** (Creative Chief v0.4.0-alpha.213), the browser's own: `el.requestFullscreen()` from a tap (the element holding your board, or `document.documentElement`); `document.exitFullscreen()` or Escape leaves. If you use it instead of `core.ui.fullScreen`, draw that button only when `document.fullscreenEnabled` is true: an iPhone has no full screen for a page, nor has Creative Chief installed on an iPad's Home Screen (Safari on an iPad, Android and computers do), and the drop's preview never has it. Nothing to add to manifest.json. What goes full screen is painted on the Look's paper unless you give it a background; lay it out for any screen size, and leave room at the edges.
- **The microphone** (alpha.213): only with `"devices": ["microphone"]` in manifest.json (section 3). A frame can't record by itself, so ask the core: `await core.microphone.start()` from a tap starts it (Creative Chief shows a bar that says it's recording, with Stop), and `const clip = await core.microphone.stop()` gives `{ audio, type, ms }`, `audio` being a `data:` address you can play (`new Audio(clip.audio)`) or decode for Web Audio, or `null`. A clip is a minute at most, one recording at a time; when Creative Chief ends it (its Stop, the minute, the person leaving), you hear `core.events.on("recorded", (clip) => …)` instead. `start()` can fail (the person or the browser said no, no microphone, another module recording): catch it, show its message in a line, and keep working without recording. Check `if (core.microphone)` first (an older Creative Chief has none). To keep a clip for the group or the person, pass it to `core.storage.files` (section 5, "Audio clips your group keeps"); otherwise it lasts while your module is open.
- **Not in the sandbox:** `core.storage.docs`, `core.storage.system`, `core.google.request`, the commons' `folder`/`list`/`find`, and `core.ui.card`, `ask`, `chat`, `viewer`, `tag` and `openPage`. If the person needs one of these, say so (section 14).

## 2. The rules (contract 1.1, in plain words)

1. **Ask the core for everything.** Never call `fetch`, `XMLHttpRequest`, `WebSocket`, `gapi` or `google.accounts`. To read a website, use `core.capability("web.fetch")` and list the site in your manifest (section 6). Never read or write `localStorage` yourself: use `core.settings()`.
2. **Every write goes through `core.write`.** That includes saving JSON, adding to a shared log and any Google change. Record a Changed line with `core.changes.record`, and give an Undo where one makes sense: register an undo type with `core.undo.register`. Outside `core.write`, the core refuses writes.
3. **Depend on capabilities, not on other modules.** Check `core.capability(name)` before you use one. If you use AI (`ai.complete`), **also give a manual path** that works with AI off (see section 6).
4. **Touch only your own things:** the element a hook hands you, your own settings and your own data folder. **Use theme tokens for color** (`var(--ink)`, `var(--accent)` and the others in section 8). Never write a raw color such as `#336699`, `rgb()` or `white`: the Shop's check refuses it, because it would be unreadable in some Looks.
5. **Shared data:** it starts with a format line, logs are only ever added to, and you never write over a newer format (section 7).
6. **Your manifest says what you write** (`writes`) and which Google access you need (`googleScopes`, almost always `[]`).
7. **Keep working offline or signed out.** Show a line such as "Sign in to see this". Don't throw. If your code throws, Creative Chief switches your module off for the session and says so. **Never save or fetch from a draw** (a draw that saves can draw again, in a loop): save when the person does something. A module that saves more than 25 times a second, or reads or fetches more than 250 times in ten seconds, waits: Creative Chief holds back its calls over the limit, in order, and they go through a moment later. Only a module that keeps going over for five seconds in a row (a loop), or has more than 250 calls waiting at once, is switched off the same way (Creative Chief v0.4.0-alpha.133; from alpha.131 the first call over the limit switched it off). How to talk to other modules without bursts: section 8a, "Talking without bursts".
8. **If your module adds or changes things, let people ask for it in words.** For each thing a person does with a button (add a movie, log a watering, tick a score), register an action with `core.actions.register`, so with AI on they can type "ai: add Dexter to screening room" in Main Chat instead of opening your page. The action runs the same function as the button. See section 6, "Let people ask for it".

`setup(core)` **only registers things** (hooks, actions, undo types, capabilities, timers). It must not read Drive. Read Drive in `start()`, or when the person opens your page.

## 3. manifest.json

Every field must be there, even when it's empty.

```json
{
  "id": "plant-log",
  "name": "Plant log",
  "version": "1.0.0",
  "author": "sam@example.com",
  "basedOn": null,
  "description": "One plain sentence: what it does for you.",
  "summary": "Water your plants on time",
  "icon": "icon.svg",
  "contract": "^2.0",
  "kind": "code",
  "scope": "mine",
  "writes": "personal",
  "provides": { "plant-log.plants": "1.0" },
  "requires": { "storage": "^1.0" },
  "enhancedBy": { "ai.complete": "^1.0" },
  "googleScopes": [],
  "dataFormat": { "plant-log.plants": 1 },
  "settings": [ { "key": "showWatered", "label": "Show when each plant was watered", "type": "boolean", "default": true } ],
  "category": "Tracking",
  "kit": 4,
  "sandbox": 1,
  "places": [ { "hook": "page", "id": "plants", "title": "Plants" }, { "hook": "nav.item", "id": "plants", "label": "Plants", "page": "plants" } ],
  "actions": [ { "name": "plant_log_water", "description": "Log that a plant was watered.", "params": { "type": "object", "properties": { "plant": { "type": "string" } }, "required": ["plant"] }, "write": true, "undo": "plant-log.water" } ],
  "undo": ["plant-log.water"],
  "entry": "module.js",
  "assets": []
}
```

A module that reads other websites adds one more field, `"webDomains"` (see the table and section 6). **Every module also gets `"category"`, `"kit"`, `"summary"` and `"icon"`** (optional for the check, but always set them, and make `icon.svg`: see the table and "Your module's icon" below). **A module that provides something also gets `"offers"`** (kit 2): what each capability does and how to call it. **A module with actions also gets `"phrases"`** (optional; Creative Chief v0.4.0-alpha.34 or later): what people can type in Main Chat to reach it, with no AI (section 6, "Phrases people can type").

| Field | Rule |
|---|---|
| `id` | Lowercase letters, digits and `-`. It never changes. It can't be a built-in's id (`core`, `looks`, `calendar`, `tasks`, `inbox`, `projects`, `journal`, `rhythm`, `ai`). |
| `name`, `description` | Plain words, shown in the Shop and in Settings. |
| `summary` | **Always set it** (kit 4): one line, 80 characters at most, that the Shop shows under the name, like `"Water your plants on time"`. The description is for more. |
| `icon` | **Always** (kit 4): `"icon.svg"`, the name of the icon file beside `manifest.json` (see "Your module's icon" below). |
| `version` | Like `1.0.0`. Raise it for every new copy you share: `1.0.1` for a fix, `1.1.0` for something new, `2.0.0` when your data format changes. The same version twice is refused. |
| `author` | The Google account email of whoever looks after the module. **Always a real Google email** (alpha.16: the Shop won't share a module of yours whose author is a name, empty or `you@example.com`; replacing, Bring across and Take out all go by it). Ask the person for theirs if you don't know it. |
| `basedOn` | `null`, or `{ "id", "author", "version" }` of the module this one was copied from (a fork). |
| `contract` | `"^2.0"` (kit 3: it runs in a sandbox, with `sandbox`, `places`, `actions` and `undo`; section 1a). A module made with kit 2 or before says `"^1.1"`: Use `"^1.0"` only if you use nothing from 1.1: no `nav.item` or `page` entries of your own, no `today.section`, no `project.section`, no commons, no presence, no websites, no `core.ui.done` and no `core.me`. |
| `kind` | `"code"`. |
| `scope` | `"mine"` (just you) or `"group"` (shared in your group's folder). Either works for testing. |
| `writes` | `"none"`, `"local"` (this browser only), `"personal"` (your own Drive) or `"shared"` (the group's commons). |
| `provides` | Capabilities your module offers others, named `<your id>.<thing>`, with a version `"1.0"`. Every one you `core.provide` must be listed here. |
| `requires` | Capabilities it can't work without. Without one, the module stays off and Settings says what it needs. The built-in ones: `storage`, `profile`, `calendar`, `tasks`, `inbox`, `projects`, `deadlines`, `log` (the Journal), `rhythm`, `look`, `ai.complete`. Don't put `ai.complete` here: see section 6. |
| `enhancedBy` | Capabilities it uses when they're there, **and only ones it really uses and is better with** (section 6). The Shop's badges come from this: "Works without AI" or "Better with AI". |
| `googleScopes` | `[]`. (Calendar, Tasks and Drive are reached through the built-in modules' capabilities.) |
| `dataFormat` | Every file format you write, with its version: `{ "<id>.<name>": 1 }`. `{}` if you write nothing. |
| `settings` | Simple fields that Creative Chief draws for you on your module's Settings page (Settings on its page, Settings beside it in Your modules, or its gear in Edit layout). `type` is `"boolean"`, `"text"`, `"number"` or `"select"` (a select has `"options": ["a", "b"]`). They follow the person to their other devices, unless you add `"local": true`. Never name one `key`. |
| `entry` | `"module.js"`. |
| `assets` | `[]`. Bundled files aren't copied at install yet, so draw pictures in code, for example as SVG. |
| `webDomains` | **Only for a module that reads websites** (optional otherwise): the sites it reads, like `["api.open-meteo.com"]`. Lowercase names, no `https://`, no path. `metv.com` also covers `www.metv.com`. People see them in the Shop, and Install asks them first. Any other site is refused. |
| `imageDomains` | **Only for a module that shows pictures from other websites** (optional otherwise), such as card art or map tiles: the sites the pictures come from, like `["cards.scryfall.io"]` (at most 10; a name covers its subdomains, so `tile.openstreetmap.org` covers `a.tile.openstreetmap.org`). Lowercase names, no `https://`, no path. Then `<img src="https://cards.scryfall.io/…">` (or a CSS background picture) just works in your module, over https; pictures from any other site are blocked. The person agrees to the list before installing. It only shows pictures: your code still can't fetch anything. |
| `media` | **Only for a module that keeps pictures** (optional otherwise): where, `["shared"]` (the group), `["mine"]` (just this person) or both. To stop others saving its pictures (a "view once" game): `{ "scopes": ["shared"], "save": false }`. The Shop shows it and asks before installing. See "Pictures that expire" (section 5). |
| `devices` | **Only for a module that records with the microphone** (optional otherwise): `["microphone"]`. The Shop shows it and asks before installing; then `core.microphone` works (section 1a). Not `media`: that one is for pictures. |
| `files` | **Only for a module that keeps audio clips or books** (optional otherwise; Creative Chief v0.4.0-alpha.233 and later, books from v0.4.0-alpha.234): where and what, `{ "scopes": ["shared"], "kinds": ["audio"] }`: scopes `"shared"` (the group; needs `"writes": "shared"`) and `"mine"` (just this person), one or both; kinds `"audio"` and `"book"`, one or both. The Shop shows it and asks before installing, and again when an update adds a scope or a kind. See "Audio clips your group keeps" and "Books your group keeps" (section 5). Not `media`: that one is for pictures. |
| `palette` | **Only for a module whose colors mean something the Look's can't** (optional otherwise; Creative Chief v0.4.0-alpha.230): up to 8 named colors, like `{ "red": "#c0392b", "sky": { "light": "#2a6fb0", "dark": "#8cc0ef" } }`. A name is lowercase letters, digits and `-` (up to 20, starting with a letter); a value is `"#rrggbb"` or `{ "light", "dark" }`. Each needs 3:1 against every Look's paper and card; one given once gets its dark version made. Then `var(--mod-red)` in your styles and `core.ui.palette()` for a canvas. See section 8, "Colors of your own". |
| `kit` | **Always set it** to the kit version at the top of this file (`4`). A whole number; Creative Chief v0.4.0-alpha.35 and later use it to tell the author when the module was built with an older kit. Raise it when you update a module with a newer kit. |
| `sandbox` | **Always `1`** (kit 3): the module runs in frames of its own (section 1a). |
| `places` | **Always** (kit 3): where it draws, each `{ "hook", "id", … }` (section 1a); `[]` for a module with no screen. |
| `actions` | **When it registers actions** (kit 3): each one's `name`, `description`, `params`, `write` and `undo`, as in `core.actions.register`. |
| `undo` | **When it registers undo types** (kit 3): their names, like `["plant-log.water"]`. |
| `offers` | **Only for a module that provides something** (optional otherwise): for each capability in `provides`, what it does, how to call it and an example: `{ "plant-log.plants": { "does": "The person's plants, and when each was last watered.", "how": "core.capability(\"plant-log.plants\").list() → [{ name, watered }] (a promise)", "example": "A right-panel line: plants not watered for a week." } }`. `does` 300 characters at most, `how` and `example` 500. The Shop gathers these into **What modules offer**, so friends and their Claude can build on yours. |
| `phrases` | **Only for a module with actions** (optional otherwise): `[{ "say": "add {title} to screening room", "action": "screening_room_add" }]`, at most 20, each 80 characters at most. Each names one of your own actions; a `{slot}` (at most 3) is one of its parameters, and every required parameter needs one. See section 6. |
| `category` | **Claude chooses it; the person doesn't have to.** The Shop shows one tab per category. Pick one from this list: `"Games"`, `"Creative tools"`, `"Social"`, `"Tracking"`, `"Utilities"`, `"Other"`. Only when none fits, make a new one: a short plain name (30 characters at most) that a friend would look for. Tell the person which you chose. If they say it's wrong, change it to what they want (from the list if one fits). A module without one is shown under Other. (Apps groups its apps by it too.) |
| `chat` | **Only for a module with a chat** (kit 4; optional otherwise): `{ "log": "talk", "title": "Table talk" }`. See "A chat for your module" (section 5). |
| `parent` | **Only for an add-on** (optional otherwise): the `id` of the module it adds to, like `"pocket-chief"` for a game that plays inside Pocket Chief. Leave it out for an ordinary module. See "An add-on to another module" (section 11). |

### Your module's icon (kit 4)

`icon.svg` is a small square picture of what the module is, drawn as SVG: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">…</svg>`. The Apps grid shows it 56 px square and the Shop 36 px, in place of the module's first letter, so keep it simple and bold: one or two shapes on a filled background, no words, no fine lines. It's a picture, not code, so its own colors are fine (rule 4 is for module.js), and it should read on a light page and a dark one. **The check refuses** an icon over 20 KB, or one with `<script>`, `<foreignObject>`, event attributes (`onload` and the like), `javascript:`, or links to anything outside the file (`href` and `url(…)` may only point inside it, `#…`). A module without one shows its first letter on a color, as before.

```svg
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="14" fill="#2f6f4f"/><path d="M32 50V26M32 34c-8 0-14-6-14-14 8 0 14 6 14 14zm0 0c8 0 14-6 14-14-8 0-14 6-14 14z" fill="none" stroke="#e9f5ec" stroke-width="5" stroke-linecap="round"/></svg>
```

## 4. module.js: the shape

```js
export default function setup(core) {
  // Register things here. No Drive reads.
  core.hooks["nav.item"].add({ id: "main", label: "Plant log", page: "main" });
  core.hooks.page.add({ id: "main", title: "Plant log", render(el) { /* draw inside el */ } });
  return {
    start() { /* after sign-in: reads are allowed */ },
    stop()  { /* when switched off: undo what you started yourself */ }
  };
}
```

- Code outside `setup` (constants, helper functions) is fine. It runs once, when the file loads. Only `export default` may be exported.
- Everything runs in strict mode. Use plain modern JavaScript and the browser's DOM (`document.createElement` and the like). No libraries, no build step and no TypeScript.
- When the module is switched off, the core removes its hooks, actions, undo types, capabilities and timers. `stop()` only cleans up what you made yourself.

## 5. What `core` gives you

### Places to draw (hooks): `core.hooks.<name>.add(spec)`

| Hook | spec | What appears |
|---|---|---|
| `nav.item` | `{ id, label, page }` | An app in **Apps**: its tile opens your page `page`. (Or `{ id, label, open() }` to do something else.) |
| `page` | `{ id, title, render(el), refresh(), leave() }` | A page in the main area, like the Journal. `render(el)` draws inside `el` each time it opens. `refresh()` (optional, alpha.81) runs when something in the group's commons changed and your module has no `log.watch` on it (section 7). `leave()` (optional) runs when the person goes elsewhere. |
| `today.section` | `{ id, title, render(el), refresh(), leave(), places }` | **A section of the right panel**, drawn with the same title and spacing as Deadlines and Tasks: you draw only the inside, in `el`. `places` is `["today"]` (`["today", "sidebar"]` is still accepted, and shows on Today too: the old left panel's place is retired since v0.4.0-alpha.116). People choose its order, or hide it (You, Looks, Edit Today, or Edit layout); a new one starts at the end, marked New. `render(el)` runs when it appears, again when your settings change, and when the web relay comes or goes. `refresh()` (optional) runs when they press Refresh, and (alpha.81) when something in the group's commons changed and your module has no `log.watch` on it. `leave()` (optional) when it's taken off the page. Keep it short: the panel is about 230 px wide. Keep it still and light too: it's on screen beside every other module's (section 8a). |
| `project.section` | `{ id, title, render(el, project) }` | A section at the bottom of every project page, in the order people choose. `project` is `{ id, name, title, domain, shared }`, where `id` is the project Doc's id (use it as a key). |
| `settings.page` | `{ id, render(el) }` | Extra things on your module's Settings page, under its own settings, while it's on. |
| `agenda.items` | `{ read(span) }` | Dated items for "what's on today", "this week" and the right panel's This week. Register it in `setup` (it isn't a place: your module's main copy answers it, alpha.81). `span` is `{ purpose, start, end, today, now }` (dates as `"YYYY-MM-DD"`; `now` an ISO date-time). Return `[{ kind: "event" or "task", date, time, text }]` within 5 seconds, 50 at most; `time` is text like `"7:00 PM"`, or `"All day"`. A game night, a shared deadline: this is how it reaches Today. |
| `today.line` | `{ id, read() }` | **A line of news on Today** (alpha.220): Today's "In <group>" card shows a row per module, newest first, three at most: your words, then your module's name and how long ago, and a › that opens your page. Register it in `setup` (it isn't a place: your module's main copy answers it, so your module needn't be open). `read()` returns `null` when there's nothing new, or `{ text, at, page }`: `text` plain words of 120 characters at most, written for the person ("Ann pinned a picture": the name from `core.people()`; leave out what they did themselves); `at` when it happened, an ISO date-time like `"2026-11-25T14:05:00Z"` (a line over a week old isn't shown); `page` (optional) which of your `page` places the › opens, else the page your Apps tile opens. Answer within 5 seconds from what you already keep (one read, never a loop). An older Creative Chief doesn't have this hook, so add it only when it's there: `if (core.hooks["today.line"]) core.hooks["today.line"].add({ … })`. It's read when Today is (and on a group switch), not live. Once the person has opened your page in that group (by the row or any other way), the row goes until a newer line comes, so give `at`: a line with no time comes back only when its words change. |
| `page.side` | `{ id, render(el), refresh(), leave() }` | **Tools beside one of your pages** (kit 4): list it in `places` as `{ "hook": "page.side", "id": "tools", "page": "table", "title": "Turn" }`. See "Tools beside your page" below. |

Other hook names exist (`reader.rules`, `rhythm.*` and more) but **aren't drawn for installed modules yet**. Don't use them.

### Tools beside your page (kit 4)

`{ "hook": "page.side", "id": "tools", "page": "table", "title": "Turn" }` in `places`, with `core.hooks["page.side"].add({ id: "tools", render(el) { … } })` in `setup`. On a wide screen Creative Chief shows it beside your page `table`, where Today usually sits; on a phone it opens from a **Turn** button at the top of the page. Put what people use now and then there (buttons, options, a move list) and keep the page for the main thing. One side per page; `page` is one of your pages; `title` is 24 characters at most. Your page and its side are two copies of your module: share what both need through your log (both can `watch` it), and use `core.ui.tell(data)` for what's only on screen (which seat is picked):

```js
// In the side: a seat was picked.
core.ui.tell({ seat: 2 });
// In the page: hear it.
core.events.on("told", (data) => { if (data && data.seat) highlightSeat(data.seat); });
```

### A chat for your module (kit 4)

`"chat": { "log": "talk", "title": "Table talk" }` in manifest.json makes one of your shared logs a chat that Creative Chief draws in Chat, with the same box and look as every chat: while someone is in your module, Chat offers it beside Creative Chief and the group chat, and a dot shows on your module's menu entry and Apps tile when someone else writes in it. **Don't draw a message box of your own.** It needs `"writes": "shared"` and works in a group (its log is in the group's commons). Lines are `{ at, by, name, text }`; read them with `log.read()`, or `watch` the log to react (a game that answers a word typed in the chat). `title` is 24 characters at most. If your log has its own format, add it: `"chat": { "log": "talk", "title": "Table talk", "format": "my-game.talk", "version": 1 }` (by default `"<id>.<log>"` and `1`, the same as `log("talk", { format: "<id>.talk", version: 1 })`).

### Inviting your group (kit 4)

A game (or anything people do together) can ask the whole open group to join: `core.chat.invite({ key, text, page, join })` puts an invitation in the group chat, which Creative Chief draws as a card with your module's icon and name, your words, who sent it and **Join**. Join opens your page `page` (else your first) for whoever presses it, or your module's Shop entry if they don't have it; your page then hears `core.events.on("join", ({ key, join, from }) => …)` with the `join` you sent (which game) and who sent it (`from.name`). When the game fills up or ends, say so: `core.chat.mark(key, "full")`, `"over"`, or `"open"` again; any copy of your module may mark it, so whoever ends the game can. It needs `"writes": "shared"`, a group open, and goes inside `core.write` like every write:

```js
if (core.chat) { // an older Creative Chief has no core.chat
  await core.write({ kind: "write", title: "invitation", run: async () => {
    await core.chat.invite({ key: gameId, text: "Starting a 4-player game, 2 seats left", page: "table", join: { game: gameId } });
    core.changes.record({ subject: "My game", kind: "daily", text: "invited the group" });
    return { ok: true };
  } });
}
core.events.on("join", (d) => openGame(d.join.game)); // in your page
```

- `key` is lowercase letters, digits and `-` (40 at most), one per game: the same key twice is refused (whoever sent it: one card per game, and the others join with its Join), and so is a second invitation from the same person within 5 minutes, or while their last one from your module is still open: mark it `"over"` when the game ends, then a new one can go (Creative Chief v0.4.0-alpha.223). Show the refusal's words to the person; hide your Invite button while their invitation is open. `text` is 140 characters at most; Creative Chief adds the name and the time, so write what the game is ("2 seats left"), not who's asking. `join` is plain data of 1 KB at most.
- It goes to the **whole group**. An invitation for one or two people stays in your own page. Nothing shows in Main Chat; with no mark, Join closes after a day.
- Keep the `key` (your own JSON, or your shared log) so you can mark it later.

### Services

| Call | What it does |
|---|---|
| `core.settings().get()` / `.set(obj)` | Your settings in this browser. `get()` returns only what's been set, so fall back to your manifest's defaults: `core.settings().get().greeting \|\| "Hello"`. |
| `core.storage.json.read(name)` → data or `null` | Your own small JSON file, `Creative Chief/module-data/<id>/<name>.json`. `name` is lowercase letters, digits and `-`. |
| `core.storage.json.write(name, data)` | Save it (**inside `core.write`**). The core adds the format header `"<id>.<name> v1"` around your data. |
| `core.storage.moduleData()` | Your own folder: `{ folder(), list(), find(name) }`, all async. |
| `core.storage.moduleData("shared")` | **The commons** (needs `"writes": "shared"`): your folder inside the group's shared folder. `{ folder(), list(), find(name), log(name, { format, version, readNewer }) }`. See section 7. |
| `core.storage.media(scope)` | **Pictures** (alpha.65; needs `media` in manifest.json): `"shared"` for the group, `"mine"` for this person. `put`, `get`, `list`, `keep`, `save`, `remove`, all async. See "Pictures that expire" below. |
| `core.storage.files(scope)` | **Audio clips and books** (Creative Chief v0.4.0-alpha.233, books from v0.4.0-alpha.234; needs `files` in manifest.json): `"shared"` for the group, `"mine"` for this person. `put`, `get`, `list`, `remove`, all async. See "Audio clips your group keeps" and "Books your group keeps" below. |
| `core.microphone` | **Recording** (alpha.213; needs `devices` in manifest.json): `start()` and `stop()` → `{ audio, type, ms }` or `null`, both async; `core.events.on("recorded", fn)` when Creative Chief ends it. See section 1a. |
| `core.ui.palette()` | **Your own colors** (Creative Chief v0.4.0-alpha.230; needs `palette` in manifest.json): `{ red: "#c0392b", … }` for the mode showing now (light, or the dark ones), for a canvas or a chart; ask again when the mode changes. Elsewhere use `var(--mod-red)`. See section 8. |
| `core.ui.fullScreen(on)` | **Full screen, one button** (alpha.214): from a tap, `true` → `"screen"` (the browser's) or `"window"` (Creative Chief's page over its whole window, with Done), `false` → `""`; heard as `core.events.on("fullScreen", fn)`. See section 1a. |
| `core.chat.invite({ key, text, page, join })` / `core.chat.mark(key, state)` | **An invitation in the group chat** (Creative Chief v0.4.0-alpha.222), inside `core.write`: a card with Join that opens your page, which hears `core.events.on("join", fn)`; `state` is `"full"`, `"over"` or `"open"`. See "Inviting your group" above. |
| `core.ui.openModule(id, page)` | Opens another module (alpha.66): its page when the person has it on (the page you name, or its first), else its entry in the Shop. For a "Play it" or "Open the game" button. |
| `core.caller()` | Inside a capability you provide: the id of the module calling it (alpha.66). Read it first thing, before any `await`. Use it to keep each caller to its own data (the Leaderboard keeps each game's scores under the game that posted them). |
| `core.write({ kind: "write", title, run: async () => result })` | **Every write.** Shows the "working" line, records Changed lines and makes Undo. `run` returns `{ ok: true }`, or `{ ok: true, undo: { type, title, …your data } }` for an Undo, or `{ error: "plain words" }`. `core.write` returns that result. |
| `core.changes.record({ subject, kind: "daily", text })` | One Changed line, such as "Plant log · Fern: watered". Call it inside `run`. |
| `core.undo.register(type, async (u) => ({}))` | Your undo handler: `u` is the `undo` object you returned. Put things back, record a Changed line, and return `{}` (or `{ said: "Your note is back as it was" }` for what Undo says, or `{ error }`). It runs as a write, so it may save. `type` must be your own, for example `"plant-log.water"`. |
| `core.ui.done(el, result, text)` | After a `core.write`, shows `text`, its Changed lines and an **Undo** button inside `el` (typing "undo" in the chat works too). |
| `core.ui.openPage(pageId)` | Opens one of your pages. |
| `core.ui.announce(text)` | Says something to a screen reader. |
| `core.ui.tell(data)` | Hands plain data (8 KB at most) to your module's other open frames (its page, its side, its sections), which hear it as `core.events.on("told", fn)`; never to another module (kit 4). |
| `core.me()` | `{ email, name, pronouns, picture }` of whoever is signed in, or `null`. `pronouns` and `picture` (a small image's data URL) are what their profile shows their groups, `""` when they left it out. |
| `await core.people()` | The people in the open group, as its Group page shows them: `[{ email, name, pronouns, picture, you, online, status, statusText }]`. Pronouns and a picture only from what each person's profile shows their groups (`""` when they left it out); nothing else of theirs. On Home (no group) it's `[]`. **Who's on** (Creative Chief v0.4.0-alpha.218): `online` is `true` while someone is Active or Away in Creative Chief (any page, not only yours), `status` is `"active"`, `"away"` or `""`, and `statusText` is the few words they wrote ("up for a game"; `""` when none). Someone who chose Hidden reads exactly like someone offline, and so do you while you're Hidden. Ask again for a fresh answer (a game's "who's around" every half minute with `core.timer` is fine: it comes from what Creative Chief already read, with no Drive call); an older Creative Chief has no `online`, so treat a missing one as unknown, not as offline. With `core.presence.here()` (who has your module open), a "who's here" list with faces. **When `pronouns` or `picture` is `""`, show nothing for it** (no "none", no "no pronouns shown", no empty box): show the name, and the email under it. |
| `core.time(x)` | A time the person's way: `"9:30 PM"`, or `"21:30"` if they chose 24-hour in Settings. `x` is a `Date`, a time in milliseconds, `"21:30"`, or an ISO date-time (`ev.start`). **Show every time through it**, never your own format. `""` when it can't read `x`. |
| `core.timer.every(ms, fn)` | A repeating timer that **doesn't run while the page is hidden**, and stops when the module does. It returns a function that stops it. Use this, never `setInterval`. Not for shared data: a shared log is watched for you (`log.watch`, section 7). |
| `core.presence` | "Here now", for modules that write to the commons. `start()` beats every 30 seconds while the page is visible and your module is on screen (a page or section of it; alpha.82), `stop()` ends it, and `await here()` returns `[{ email, name, at }]` for the last 100 seconds. |
| `core.events.on(name, fn)` | `signedIn`, `signedOut`, `accountChanged`, `dayChanged`, `changed` (after any write), `opened`, `told` (kit 4: what another of your frames handed over with `core.ui.tell`), and `join` (your page, opened from a group chat invitation's Join). |
| `core.capability(name)` | Another module's offer, or `null` when it's off. **Always check for `null`.** |
| `core.provide(name, api)` | Offer something of your own (listed in `provides`). |
| `core.actions.register({ name, description, params, write, run })` | Something the AI may call as a tool, so people can ask for it in Main Chat (rule 8). `name` is `snake_case` and unique (begin it with your id: `plant_log_list`). `description` is what the AI reads to choose it: say what it does in your module's words. `params` is a JSON schema (`{ type: "object", properties: {} }`). One for each thing a person can add or change (`write: true`), whose `run` calls your own `core.write` (section 6); read-only ones (`write: false`) for what someone might ask about. |
| `core.say(key)`, `core.dates`, `core.text` | Shared helpers. Not needed for most modules. `core.text.clean(html)` (Creative Chief v0.4.0-alpha.234) makes a book's markup safe to show: see "Books your group keeps". |

**`web.fetch` (when your group has a web relay):** `const web = core.capability("web.fetch")`. It is `null` without the relay, so always have a manual path. `await web.get(url)` reads one page of a site in your `webDomains` and returns `{ ok, status, url, text, json(), html() }`: `json()` for an API, `html()` for a web page (an inert copy you can search with `querySelector`; its scripts never run). `{ fresh: true }` skips the one-minute copy. It throws with a plain line ("Not read: …") when it can't read the page: catch it and show the line. See section 6.

**`web.lookup` (when the AI module is on):** `const look = core.capability("web.lookup")`. When `look && look.ready()`, `await look.ask({ question, url })` has the AI read the page (or search the web) and returns `{ text, sources, sourceList, queries }`. Only after a tap: it costs the person money (tokens, plus Google's charge for each search: 5,000 a month free, then $14 per 1,000). Show the answer with its `sourceList` (`[{ uri, title }]`) as links, so the person can check it. Without a `url` it searches the web, and `queries` says what was searched for. Those words go to Google, so send only what the person asked about, never their files. A key on Google's free tier can't search, and `ask` then throws one plain line: catch it and show it.

**`ai.complete` (when the AI module is on):** `const ai = core.capability("ai.complete")`. Then `ai && ai.ready()` is true only when the person has saved their key. `await ai.complete({ prompt, system })` returns `{ text }`. It costs the person money, so call it only when they tap something.

### Pictures that expire (alpha.65)

`core.storage.media("shared")` keeps pictures for the group, and `core.storage.media("mine")` for this person only. Creative Chief shrinks each one (1600 px on its longest side, a JPEG of 1 MB at most), keeps it as a file of its own in the sender's Drive, and shows it to your frame. **Don't keep pictures any other way** (not as text in JSON or a log).

```js
const media = core.storage.media("shared");
// Inside core.write, like every change (Changed and Undo come with it: Undo really takes the picture away).
await core.write({ kind: "write", title: "Send a snap", run: async () => { await media.put(file, { expires: "24h" }); return { said: "Sent." }; } });
const items = await media.list();       // [{ id, by, at, expires, kept, savedFrom, savedBy, mine }], oldest first, expired ones left out
img.src = await media.get(items[0].id); // a picture address for <img>
```

- `put(picture, { expires })`: a `File` (from `<input type="file">`), a `Blob` or a `data:` address. `expires` is `"1h"` to `"7d"` (like `"90m"`, `"24h"`, `"3d"`), or `null` to keep it. At most 200 new pictures a day per person in each module.
- `keep(id)`: the sender keeps their own for good. `save(id)`: anyone else saves it: a copy with no expiry, theirs, that `list()` gives **in the original's place for everyone**, with `savedBy`. Show the sender who saved theirs ("Kevin saved your snap").
- `remove(id)`: the sender takes theirs back (or a saver takes their saved copy away); it goes to their Drive's trash. **Once someone saves a picture, it stays, and its sender can't take it back** (`list()` gives the saved copy in its place, which isn't theirs). Say so in your page: "Kevin saved it, so it stays".
- When a picture expires, every Creative Chief stops showing it at once, and it goes to the sender's Drive trash the next time the sender opens Creative Chief. Until then someone who opens the group's folder in Drive could still find it: don't promise more than "gone from Creative Chief after a day".
- `keep`, `save` and `remove` go inside `core.write` too. `get` and `list` don't.

### Audio clips your group keeps (Creative Chief v0.4.0-alpha.233)

`core.storage.files("shared")` keeps audio clips for the group, and `core.storage.files("mine")` for this person only. Each clip is a file of its own in the Drive of whoever added it, named from the name you give it, and it stays until **that person** takes it out (to their Drive's trash): there's no expiry, and nobody else can remove it. A remix is a new clip, the remixer's own. **Don't keep audio any other way** (not as text in JSON or a log). Check `if (core.storage.files)` first: an older Creative Chief has none.

```js
const clips = core.storage.files("shared");
// Inside core.write, like every change (Changed and Undo come with it: Undo really takes the clip away).
const rec = await core.microphone.stop(); // { audio, type, ms }, section 1a; a File from <input type="file" accept="audio/*"> works too
await core.write({ kind: "write", title: "Keep a clip", run: async () => { await clips.put(rec.audio, { name: "Bass loop" }); return { said: "Kept." }; } });
const items = await clips.list();          // [{ id, name, kind, type, size, by, at, mine }], oldest first
const clip = await clips.get(items[0].id); // { blob, audio, type, name, size }
playButton.addEventListener("click", () => new Audio(clip.audio).play()); // play only from a tap (an iPhone needs one)
```

- `put(file, { name })`: a `File`, a `Blob` or a `data:` address (a recording's `audio`). Creative Chief looks at the file's first bytes, not its type: WebM, MP4, MP3, WAV or Ogg is a clip, anything else is refused. A clip is **2 MB at most** (a minute from the microphone is about half that); at most 100 new clips a day per person in each module, and 500 files in a module's group (or the person's own) at once. The name is cleaned and cut to 120 characters, with the extension the bytes say; without one it's "clip". It gives back `{ id, name, kind, type, size, at }`.
- `get(id)`: `audio` is a `data:` address for `new Audio(…)`; `blob` is the same clip as a `Blob`, for Web Audio (`await ctx.decodeAudioData(await clip.blob.arrayBuffer())`). Start playing only from a tap: phones won't play sound without one. A clip recorded in one browser may not play in another (an iPhone may not play WebM): catch `play()`'s failure and say so in a line.
- `list()`: every clip in that place, oldest first; `mine` is true for the person's own, `by` is who added it (an email: show the name from `core.people()`).
- `remove(id)`: only the person who added a clip can take it out (others get a refusal: draw the button only when `mine`). It goes to their Drive's trash.
- `put` and `remove` go inside `core.write`. `get` and `list` don't. A refusal (too big, not audio, the day's count, outside `core.write`, not yours) is thrown with words for the person: catch it and show its message.
- The clips stay when your module is removed, and when someone leaves the group (they're still that person's files). Say so if your module offers a "clear all".

### Books your group keeps (Creative Chief v0.4.0-alpha.234)

The same `core.storage.files` keeps books, with `"kinds": ["book"]` in manifest.json: a PDF, an EPUB or a text file, each a file of its own in the Drive of whoever added it, until **that person** takes it out. A group's library is everyone's books in `"shared"`. Check `if (core.storage.files)` first; a Creative Chief older than v0.4.0-alpha.234 refuses a book at `put` with a line for the person, so catch it and show it.

```js
const library = core.storage.files("shared");
// A File from <input type="file" accept=".pdf,.epub,.txt">, inside core.write; progress says how far it has gone.
await core.write({ kind: "write", title: "Add a book", run: async () => {
  await library.put(file, { name: "Dune", progress: (done, total) => { bar.value = done / total; } });
  return { said: "Added." };
} });
const books = await library.list();             // [{ id, name, kind, type, size, by, at, mine, link }], oldest first
const book = await library.get(books[0].id, { progress: (done, total) => { bar.value = done / total; } }); // { blob, type, name, size }
if (book.type === "text/plain") page.textContent = await book.blob.text();
// An EPUB is a zip of XHTML pages: read a page out of book.blob yourself, then show it only through core.text.clean.
chapterEl.innerHTML = core.text.clean(chapterMarkup);
openInDrive.addEventListener("click", () => core.ui.openLink(books[0].link)); // a PDF opens in Google Drive for now
```

- `put(file, { name, progress })`: a `File` or a `Blob`. Creative Chief looks at the first bytes, not the type: `%PDF-` is a PDF; a zip whose first entry is `mimetype` holding `application/epub+zip` is an EPUB; valid UTF-8 text with no NUL is a text file. Anything else is refused. A book is **50 MB at most**, a text file 5 MB; at most 20 new books a day per person in each module. Over 5 MB it goes up in pieces, and a piece that fails is sent again, so a big book on a slow connection still gets there; `progress(done, total)` hears how far (numbers only). The name is cleaned, with the extension the bytes say (`.pdf`, `.epub`, `.txt`); without one it's "book". It gives back `{ id, name, kind, type, size, at, link }`.
- `get(id, { progress })`: `{ blob, type, name, size }`, the book as a `Blob`. A book opened once stays on that device (up to 200 MB, the oldest out first), so it opens again without downloading; the person clears it in Connections, and it goes when they sign out.
- `link`: the book's page in Google Drive. Open it with `core.ui.openLink(link)` (Creative Chief asks first). It's how a PDF is read until Creative Chief reads PDFs itself.
- **A book's markup never goes into the page except through `core.text.clean`.** An EPUB's pages are a stranger's HTML: set with `innerHTML` as they are, their scripts and handlers would run as your module, for everyone who opens the book. `core.text.clean(html)` gives back an inert copy with only plain reading elements (paragraphs, headings, emphasis, lists, tables, quotes, links within the book), and no scripts, handlers, styles, frames, pictures or outside addresses. Its ids start `cc-book-`, and a link within the book is changed to match.
- `list()`, `remove(id)`, `core.write` and what stays when a module is removed or someone leaves: as for clips above.

### Scores and leaderboards (alpha.66)

**Don't draw your own leaderboard.** The **Leaderboard**, built into Creative Chief (alpha.110), draws every game's board, one tab per game, in one design, and links back to your game. Your game only posts scores. Draw your own board only when the person asks for one.

```js
const lb = core.capability("leaderboard.scores"); // in "enhancedBy": { "leaderboard.scores": "^1.0" }
if (lb) {
  const r = await lb.post(score, { title: "BONE CATCH" });   // when a round ends; r.best: a new best for this player
  const top = await lb.read({ n: 3 });                        // { title, lower, rows: [{ rank, name, score, me }] }
}
```

- `post(score, { title, game, lower })`: once per round, at its end. The player's name comes from Creative Chief, and the board is your module's (`game` makes a board of your own inside it, like one per level; `lower: true` when the lowest score wins, like a time). It's the Leaderboard's own write, with a Changed line and Undo.
- **A small top list on your own page** (optional): draw `read`'s rows in the shared look, so every board matches: `<ol class="cc-board">`, each row `<li>` (with `class="cc-board-me"` on the player's own) holding `<span class="cc-board-rank">`, `<span class="cc-board-name">` and `<span class="cc-board-score">`; when there are no rows, `<p class="cc-board-empty">No scores yet.</p>`.
- `lb.open()` opens the Leaderboard on the game this player last scored in.
- **A game that had its own board:** the first time it runs with the Leaderboard, send this player's old bests across once with `await lb.importBest([{ score, title, game }])` (only boards where they have no score yet), then post there from now on.
- The Leaderboard is built in but off until a game wants it: when someone installs your game (with `leaderboard.scores` in `enhancedBy`), Creative Chief asks them once to turn it on. While it's off, `core.capability` gives `null`: keep the game working (show this player's own best, or nothing). Don't ask the person to install a Leaderboard from the Shop: there isn't one to install.

### Working with other modules (kit 2)

Your module can use what a friend's module offers (Snaps' `snaps.compose`, say), without having that module's files:

- **The person pastes what's there.** In Creative Chief, **Your modules** (in You, with Creator mode on) **→ More for makers → What modules offer → Copy for Claude** gives a block listing each capability their modules offer: what it does, how to call it and an example. If they want your module to work with another, ask them to paste it (once is enough). Use only what's in it; never guess at another module's calls.
- **Always optional,** with one exception. Put the capability in `enhancedBy`, never `requires`. The exception: an add-on of that module (`"parent"`) that can't work without it puts its capability in `requires` (section 11). Draw the button or section that uses it only when `core.capability("<capability>")` isn't `null`, and keep the module working without it.
- **Offer yours, but only when it's wanted.** Provide a capability only when the person asks for one, or another module needs it (a friend's module that will call it, say). Don't add one just because you can: it shows in everyone's What modules offer list, and nobody will use it. **If you think one could be useful that nobody asked for, ask the person first:** say what it would offer and what another module could use it for ("This could offer the scores to other games, so a shared leaderboard could show them. Add it?"), and add it only if they say yes. When you do, describe it in `"offers"` (section 3), so it shows in that list. Keep `how` exact: the call, its arguments and what comes back.

## 6. The easy AI path plus a manual path

Many people won't switch AI on. So a module **works fully without AI**, and offers AI as an extra:

- Put `"ai.complete": "^1.0"` in `enhancedBy`, never in `requires`. The Shop then shows "Better with AI".
- **Only when it's better.** Claim AI (`ai.complete` or `web.lookup`) only when the AI path gives a better result than the module does without it. When a website or the person's own typing gives the better answer, leave the AI out, and the Shop says "Works without AI": that's the honest label. Weather 1.2 is the example: the weather service's numbers beat the AI's guess, so it has no AI.
- Draw the AI button only when `core.capability("ai.complete")` is there and `.ready()` is true.
- Never send anything to the AI without a tap. If the AI fails, show a line and leave the manual path working.

Example: an Overwatch stats module would offer "Ask AI to read my profile" and also a form to type the stats in.

### Let people ask for it (actions)

With AI on, a person can type in Main Chat instead of opening your page: "ai: add Dexter to screening room", or tap **Ask AI** on a card Creative Chief wasn't sure about. The AI can only do what the modules that are on have registered as actions. Without one, it doesn't know your module can add anything, and it goes looking in their Drive instead. So:

- **One action for each thing a person can add or change** on your page, and a read-only one for what they might ask ("what's on my watch list?").
- **The action and the button call the same function.** That function does its own `core.write`, so the save is allowed, Changed lists it and Undo works, whether a tap or the AI started it. (The AI's call runs inside the AI's write: your own `core.write` joins it, so Changed and Undo come with it.)
- **The description is what the AI reads** to choose your action. Use the words a person would type and your module's name: "Add a show or movie to the Screening Room watch list." Name each parameter and describe it in a few words.
- **Return plain results:** `{ ok: true, … }` with what was done, or `{ error: "plain words" }`. The AI turns them into its answer. Add `said`, one plain sentence of what happened: typed phrases show it on their card (below).

```js
// The one function the button and the action both use.
const addTitle = (title) => core.write({ kind: "write", title: "Add " + title, run: async () => {
  title = String(title || "").trim();
  if (!title) return { error: "Say what to add." };
  const list = (await core.storage.json.read("watch-list")) || { items: [] };
  if (list.items.some((x) => x.title.toLowerCase() === title.toLowerCase())) return { ok: true, already: true, title };
  list.items.push({ title, added: new Date().toISOString() });
  await core.storage.json.write("watch-list", list);
  core.changes.record({ subject: "Screening Room", kind: "daily", text: "added \"" + title + "\"" });
  return { ok: true, title, said: "Added \"" + title + "\" to the Screening Room list.", undo: { type: "screening-room.add", title: "\"" + title + "\"", item: title } };
} });

// In setup(core):
core.actions.register({
  name: "screening_room_add",
  description: "Add a show or movie to the Screening Room watch list. Skips one already on it.",
  params: { type: "object", required: ["title"], properties: { title: { type: "string", description: "The show or movie, as the person said it" } } },
  write: true,
  run: (args) => addTitle(args.title)
});
core.actions.register({
  name: "screening_room_list",
  description: "What is on the Screening Room watch list. Reads only.",
  params: { type: "object", properties: {} },
  write: false,
  run: async () => {
    const items = ((await core.storage.json.read("watch-list")) || { items: [] }).items.map((x) => x.title);
    return { items, said: items.length ? "On the Screening Room list: " + items.join(", ") + "." : "The Screening Room list is empty." };
  }
});
core.undo.register("screening-room.add", async (u) => {
  const list = (await core.storage.json.read("watch-list")) || { items: [] };
  list.items = list.items.filter((x) => x.title !== u.item);
  await core.storage.json.write("watch-list", list);
  core.changes.record({ subject: "Screening Room", kind: "daily", text: "took off \"" + u.item + "\"" });
  return {};
});
// The page's Add button: core.ui.done(el, await addTitle(input.value), "Added.");
```

### Phrases people can type (no AI)

Since Creative Chief v0.4.0-alpha.34, a module can also be reached by typing **without AI**: "add Dexter to screening room" in the box at the bottom, from anywhere. **Give every module with actions phrases** in `manifest.json`, each mapped to one of its actions:

```json
"phrases": [
  { "say": "add {title} to screening room", "action": "screening_room_add" },
  { "say": "what's on screening room", "action": "screening_room_list" }
]
```

- **A `{slot}` is where the person's own words go** (one or more words). Its name is one of the action's parameters, and it fills that parameter: "add Dexter to screening room" runs `screening_room_add` with `{ title: "Dexter" }`. Every required parameter needs a slot. At most 3 slots, never two in a row.
- **A slot gets its parameter's type.** For a `"number"` (or `"integer"`) parameter it takes digits or a number word up to twenty: "roll two dice" and "roll 2 dice" both run `{ dice: 2 }`. Words that aren't a number don't match, and a slot never holds only "the", "a", "an" or "my", so "roll the dice" reaches its own phrase rather than "roll {dice} dice". Any other type gets the words as typed.
- **The other words must be typed**, but capitals, "the", "a", "an", "my" and a full stop at the end don't matter ("Add Dexter to the Screening Room." works too), nor does your module's name at the end after "on", "in", "at", "from", "with", "using" or "via" ("roll two dice on the Dice table"). A phrase with a slot needs at least two words of its own besides it, so it doesn't catch everything people type.
- **Creative Chief's own phrases always win.** Yours are tried only when it isn't sure what a message means, so "remind me to …" or "todo: …" can never reach your module. The check warns when one of your phrases is taken first: choose other words, ideally with your module's name in them ("… to screening room").
- **Two modules with the same phrase:** the person picks one ("Which one did you mean?", a chip with each module's name). A message that is close to your phrase (most of its words) gets a chip with your module's name on the "not sure" card; each slot is filled from the words where it stands, and the person checks them. A question close to your phrase, with a word of your module's name in it, runs that phrase ("what's the weather like?" for Weather's "what's the weather now"), and the card offers to remember the wording.
- **Typed in Chat beside your module's page**, a phrase answers there and your page stays open.
- **What the card says:** return `said` in your action's result, in plain words ("Added Dexter to the Screening Room list."). Without it the card says "Done (Screening Room)." A write action runs at once when it has an undo type (the card offers Undo), and asks "Go ahead?" first when it hasn't.
- **The What can I say? page** (at the top of Chat, or typing "what can I say?") lists each module's phrases with its action's description, so write descriptions a person can read.
- The same actions are still what the AI calls when it is on: one set of actions serves both.

### Adding to the person's calendar (kit 2)

A module can put events on the signed-in person's own Google Calendar (never anyone else's), through Creative Chief's calendar actions, inside your own `core.write`:

```js
const addGame = (game) => core.write({ kind: "write", title: "Add " + game.title + " to your calendar", run: async (w) => {
  const off = core.dates.localOffsetForDate(game.day); // "-08:00": the person's own time on that day
  const ev = await w.run("create_event", { summary: game.title, start: game.day + "T19:00:00" + off, end: game.day + "T22:00:00" + off, description: "Upkeep: " + game.table });
  if (!ev || ev.error || !ev.id) return { error: (ev && ev.error) || "The calendar didn't take it." };
  core.changes.record({ subject: "Upkeep", kind: "daily", text: "added \"" + game.title + "\" to your calendar" });
  return { ok: true, eventId: ev.id, said: "Added " + game.title + " to your calendar.", undo: { type: "event", eventId: ev.id, title: game.title } };
} });
```

- **Showing a time:** `core.time(ev.start)` gives "7:00 PM" (or "19:00" for someone who chose 24-hour).
- **Times:** a timed event needs its offset: `day + "T19:00:00" + core.dates.localOffsetForDate(day)` (`day` is `"YYYY-MM-DD"`), or Google refuses it. An all-day event is just `start: "YYYY-MM-DD"` (the end is filled in).
- **Keep the event's id** (`ev.id`) in your own data. To move it later: `w.run("update_event", { eventId, start, end, summary })`; to take it off: `w.run("delete_event", { eventId })`, each inside `core.write`.
- **Undo:** return `undo: { type: "event", eventId, title }` and Creative Chief's own Undo takes the event off again. Don't register an undo type of your own for it.
- Put `"calendar": "^1.0"` in `enhancedBy` and check `core.capability("calendar")` for `null`: without the Calendar module the button isn't there, and the module still works.

### Reading a website: three paths

A module that needs something from a website offers every path that's there, and always the last one:

1. **The core reads it, and your module picks out what it needs** (`web.fetch`, with the group's relay): `const r = await web.get("https://api.open-meteo.com/v1/forecast?...")`, then `r.json()`; or for a web page `const doc = r.html()` and `doc.querySelector("h2")`. Free and quick.
2. **The AI reads it** (`web.lookup`, with the AI module on): `await look.ask({ url, question: "Which movie is on this Saturday? The title only." })`. Good for pages whose layout changes. Costs a little, only after a tap.
3. **The person types it.** A small form. Always there.

```js
const web = core.capability("web.fetch");
if (web) {
  try {
    const r = await web.get("https://api.open-meteo.com/v1/forecast?latitude=43.5&longitude=-80.2&current=temperature_2m");
    if (r.ok) show(Math.round(r.json().current.temperature_2m) + "°");
    else say("The weather service answered " + r.status + ".");
  } catch (e) { say(String(e.message || e)); }  // "Not read: …": show it, don't throw
} else {
  // no relay: show the form to type it (and an Ask AI button when web.lookup is ready)
}
```

What can't be read, even with the relay: pages built by JavaScript after they load (the relay sees the empty shell; the page's JSON address often works instead), pages behind a sign-in or a paywall, sites that block robots (a "checking your browser" page), forms and searches (it only reads), pictures and PDFs, anything over 2 MB, and things on someone's own network. Check a site's terms before reading it often.

## 7. Data formats and versions

- **Your own JSON** (`core.storage.json`): put a version inside your data, for example `{ v: 1, plants: [...] }`. If you find `v` bigger than yours, show the data but don't change it: "Update Plant log to keep using this." Name the format in `dataFormat`.
- **Shared data** (the commons, `"writes": "shared"`): use a **log**, which is only ever added to.
  ```js
  const room = core.storage.moduleData("shared").log("messages", { format: "<id>.messages", version: 1, readNewer: true });
  const got = await room.read();   // { exists, lines: [...], canWrite, newer, problem }
  const stop = room.watch((log) => draw(log.lines)); // alpha.81: each time anyone adds to it (your own line at once); stop() ends it
  await core.write({ kind: "write", title: "message", run: async () => { await room.append(["one line"]); return { ok: true }; } });
  ```
  **Read once when your page opens, then `watch`** (never a timer of your own): Creative Chief finds new things with one Drive call for the group's whole commons, and checks the logs of the module you have open one by one: about every 1.5 seconds while someone else is in that module (their "here now" or a line of theirs in the last 100 seconds) and every 45 seconds otherwise, never while the page is hidden. It reads a changed log once for all your frames. `log` is what `read()` gives (`exists`, `lines`, `canWrite`, `newer`, `problem`) plus `by` (`"you"` or `"someone"`) and `at`. A change by someone else shows a second or two after it was saved. **Start each line with its time**, an ISO date-time (`new Date().toISOString() + " · " + …`, as Chatroom does): the makers' timing line then says how fast lines arrive (alpha.83). `room.changed()` (Drive's last-change time, cheap) is still there, but it can lag behind a line by minutes: for a live table, use `watch`.
  **Sizes (alpha.126):** one `append` takes **1 to 50 lines**, and each line is a string of **4000 characters at most**. A longer call is refused whole, with words that name the limit and the line ("… each 4000 characters at most; line 1 is 5012 characters"), so nothing reaches the log. Keep a line to one small thing (a message, a move, one card). Something bigger, such as a whole set of cards with their words, goes as **several lines** (one per card, with a shared id so a reader can put them back together), or as JSON in your own folder (`core.storage.json`, 200,000 characters) with a short line in the log that points to it. Never retry a refused line as it is: it will be refused again.
  The core makes the Doc the first time, with the line `cc-format: <format> v<version>` first. `append` adds lines at the end in one go, so two people writing at the same moment both get through. **Never** read, edit and write back a shared file. If the log was written in a newer version, `canWrite` is `false` and `problem` says "Update … to keep using this". Show that line and turn off your send button. `readNewer: true` means your module can still show newer lines.
- **Versions** follow `major.minor.patch`. A change to a data format is a new **major** (`2.0.0`), with a new format version and a CHANGELOG line saying so.
- **The changelog**: `## 1.1.0 (2026-11-02)` followed by `- what changed`, newest first.

## 8. Looks: the classes and colors to use

Creative Chief has 7 Looks, each in light and dark, and your module must suit all 14 (and the themes people make from them). So use only these:

- **Classes:** `btn-primary` (one main button), `btn-secondary`, `hint` (small, muted text), `row-buttons` (a row of buttons with gaps). Headings `h2` are styled on pages. In a right-panel section, the core draws the title: don't add another.
- **Color tokens:** `var(--ink)` (text), `var(--ink-soft)`, `var(--muted)`, `var(--paper)` (the page), `var(--card)`, `var(--line)` (borders), `var(--accent)`, `var(--accent-soft)`, `var(--accent-text)` (accent-colored text). Set them through `el.style` (for example `el.style.borderTop = "1px solid var(--line)"`), or in SVG through `el.style.fill`.
- **Also in every frame:** `var(--danger)` (a red for warnings and a red team), `var(--ok)` and `var(--ok-text)` (a green, and green text), and `var(--on-accent)` (text on a button filled with the accent). Each one changes with the Look and the mode, like the nine above. Use these, not a hex, when a color has to mean something.
- **Accessible:** every input has a `<label for=…>`. Buttons are `<button type="button">` with words on them. Pictures have `role="img"` and an `aria-label`. Status text has `role="status"`. Nothing scrolls sideways on a phone 390 px wide.
- **Ids:** start every `id` with your module's id (`plant-log-…`), so it can't clash.
- **Habits for your own CSS and styles:** colors only from the tokens (never a hex, `rgb()` or a color's name, not even inside `color-mix()`); no `!important`; to change how something looks, change the rule that says it, don't add a later rule to cancel an earlier one.
- **That's all a frame has (alpha.132):** your module's frame is given the color tokens, the styles of plain elements (buttons, fields, headings, lists) and the classes above, not the rest of Creative Chief's own page. Style anything else with your own CSS.

### Dark mode: design for it, don't flip (alpha.126)

Half of the 16 are dark. The color tokens above already swap, so a module built only from them works in dark; what's left is to **design** for dark rather than turn light upside down.

- **Depth by lighter surfaces, not shadows.** In dark, a raised thing is a slightly lighter surface: `var(--card)` on `var(--paper)`, with a `var(--line)` border. A shadow barely shows on a dark page, so don't rely on one to separate things.
- **No pure white on pure black:** `var(--ink)` on `var(--card)` is already the right softness in each Look. If a color has to carry a meaning (a red team, a warning, a chart's series), take it from the tokens (`var(--danger)`, `var(--ok)`, `var(--accent)`), keep such colors few, and give each a softer version for dark, mixed with the page, for example `color-mix(in srgb, var(--danger) 70%, var(--paper))`; everything else stays on the plain tokens. A color written in module.js (`#d33`, `rgb(…)`, `red`) is refused by the Shop's check even inside `color-mix()`, because it can be unreadable in some Looks. If a color has to mean something the tokens can't say, give it a name in manifest.json's `palette` (below).
- **Pictures don't flip.** A photo, a drawing or pixel art looks the same in both modes. Put it on `var(--card)` with a `var(--line)` border, or on a fixed background you choose for it, so it doesn't sit on a black page with no edge. An SVG icon drawn in `currentColor` or the tokens follows the mode by itself.
- **Which mode is on:** your frame's `<html>` carries the Look and the mode, as Creative Chief's page does: `document.documentElement.getAttribute("data-mode")` is `"light"` or `"dark"`, and `data-look` is the Look's name (`"modern"`, `"editorial"` …). They change while your module is open when the person changes the Look, so draw from the tokens, and if something must be drawn differently in dark (a canvas, a chart), redraw when they change:
  ```js
  const isDark = () => document.documentElement.getAttribute("data-mode") === "dark";
  new MutationObserver(draw).observe(document.documentElement, { attributes: true, attributeFilter: ["data-mode", "data-look"] });
  ```
- **Check it in dark before you share it.** In Creative Chief, You → Looks, set Mode to Dark, then open your module: the text readable, the buttons clear, nothing lost against the page. Quicker: drop it in Your modules, and once it passes the check press **Preview**, which draws its Today section (or its page) in the current Look, with a Light | Dark switch (Creative Chief v0.4.0-alpha.207). The preview shows it as it would the first time: its reads come back empty, and nothing it does there is saved or sent.

### Colors of your own (Creative Chief v0.4.0-alpha.230)

Use the Look's tokens wherever they make sense: they are what keeps your module at home in every Look. Some colors carry a meaning of their own, though, and a Look can't give them: the teams or characters in a game ("the blue one" has to be blue for everyone), the rarities of cards, a clear day's blue sky in a weather module. For those, name them in manifest.json:

```json
"palette": { "red": "#c0392b", "blue": "#1f5fa8", "sky": { "light": "#2a6fb0", "dark": "#8cc0ef" } }
```

- **Up to 8**, each named with lowercase letters, digits and `-` (up to 20 characters, starting with a letter). A value is `"#rrggbb"`, or `{ "light": "#rrggbb", "dark": "#rrggbb" }` to choose both.
- **Readable in every Look:** each must reach **3:1** against the paper and the card of every Look in its mode. The Shop's check refuses one that doesn't, names the Look where it falls short and offers the nearest shade that passes ("try #917609"). 3:1 is enough for marks, fills, borders and pieces, not for words: write words in `var(--ink)` beside the color (a team's name next to its color), not in it.
- **Dark mode is made for you:** a color given once gets a dark version, lightened until it reads on every dark Look, the same for everyone. Give `{ "light", "dark" }` when you want to choose it; then both are checked.
- **Using them:** `var(--mod-red)` (your color's name after `--mod-`) in your CSS and `el.style`, which follows the mode like the tokens do. Give a token after it, `var(--mod-red, var(--danger))`, so an older Creative Chief, which doesn't know `palette`, still draws something. For a canvas or a chart, `core.ui.palette()` gives `{ red: "#c0392b", … }` for the mode showing now: draw again when the mode changes (the observer above).
- **Never color alone:** some people can't tell red from green. Give each color a name, a letter, a shape or a pattern too.
- module.js still writes no color of its own: the colors live in manifest.json, where the check can read them.

## 8a. What a phone can hold (the phone budget)

**Every module, of every kind, shares one page with every other module the person has on.** On a computer or an iPad there's plenty of room. On a phone, an iPhone most of all, there isn't: when the page and all its modules together hold more than the phone will give it, iOS ends the page. It goes blank and reloads by itself, or the browser says it can't open the page. That isn't an error your code can catch, and the module that tipped it over may not be the one that looks heavy. It has happened with modules that looked great on a computer.

This section is how to keep a module beautiful **and** light enough to share a phone: where it can be rich, what's costly and what's cheap, worked examples for several kinds of module, and how to bring an older module up to it. It's advice (the kit stays 4; nothing is refused for it), and it's for every module: games, cards, pets, weather, galleries, charts, shared things. A good module costs little where it's always on screen and saves its magic for the moment someone opens it.

**What it can and can't promise.** Following it lowers the risk a lot. It can't make it zero: no browser lets a page measure or cap how much memory it uses, the limit isn't published, and it changes with the phone, the browser and what else is open. A module's own page that holds too much on its own can still be ended while it's open. Creative Chief's side of the bargain is the rest of the page; your module's side is below. And if a phone ends the page twice in a row while it opens, Creative Chief opens the next time in safe mode by itself (Creative Chief v0.4.0-alpha.131), so the person can switch modules off.

### What costs memory

One idea covers almost all of it: **the browser keeps some things as a picture of their own, at the phone's real pixels, and every such picture stays in memory.** An iPhone has 3 real pixels for every CSS `px`, each way: 9 times the area, at 4 bytes a pixel.

- **An element that's animated, or under a filter** (`blur`, `drop-shadow`, `hue-rotate`, `saturate`…), **a blend mode** (`mix-blend-mode`), `backdrop-filter`, or `will-change`: each becomes a picture of its own. A card 100 × 140 px is about 0.5 MB on an iPhone. Thirty such cards on a shelf is about 15 MB, and each filter chained after another can add another picture. An animated filter is drawn again on every frame, forever.
- **A picture (`<img>`, a CSS background) is kept at its own size, not the size it's shown at.** An 800 × 800 picture is about 2.5 MB once shown, even at 48 px wide; thirty of them is about 75 MB.
- **A `<canvas>` costs its own width × height × 4 bytes, however many things you draw in it.** One canvas 390 × 600 px at twice the pixels is about 3.7 MB, whether it holds one spark or a thousand raindrops.
- **Each place your module draws is a page of its own** (a frame: its Today section, its page, its side), each with its own copy of your code (section 1a).
- **Animation that never stops** keeps all of that alive and busy, even when nobody is looking at it.

So a whole first-person game drawn in one canvas can run well on an iPhone, while a shelf of small pieces, each under four shadows and a moving color filter, can end the page. The number of things the browser has to keep as separate pictures matters far more than how much is going on.

### Where the richness goes

| Place | Its budget |
|---|---|
| **Today's section** (`today.section`) | **Still and light.** It's drawn on every open and every sign-in, beside every other module's section, and it can be drawn again, or taken away and drawn later, at any time. No animation that repeats; no filters, blurs or blend modes; no canvas that keeps drawing; pictures small in fact, not just shown small; a few dozen elements at most. A one-time change after a tap (under half a second, on `transform` or `opacity`) is fine. Show where things stand and invite: "A box to open ›" that opens your page. |
| **Your module's page** (`page`) | **Rich, one scene at a time.** It costs memory only while the person has it open, so this is where your module plays, reveals and moves. One big moving thing at a time (a pull, a game, a sky), and everything it held let go in `leave()`. |
| **Tools beside a page** (`page.side`), **a project's section, Settings** | Like Today: still and light. They sit beside something else. |
| **Actions and capabilities** (no place) | Nothing drawn. |

### Cheap and costly

| Cheap: use it | Costly: what to use instead |
|---|---|
| Animating `transform` (move, scale, rotate) and `opacity` | Animating `top`, `left`, `width`, `height`, `margin`, `box-shadow` or `background-position`: move it with `transform` instead (a column of rain moved with `translateY`, not `top`). |
| A gradient (`radial-gradient`, `linear-gradient`) for a glow, a shine, fog or a sky | `filter: blur()` or `backdrop-filter` for a glow: a `radial-gradient` that fades to `transparent` looks the same. **Never animate a blur.** |
| One `box-shadow`, a border, or in dark a lighter surface (section 8) | `filter: drop-shadow()` chained, on many pieces: one `box-shadow`, an outline drawn into the picture, or a `var(--card)` frame with a `var(--line)` border. |
| Colors drawn into the picture: an SVG `fill`, a sprite drawn once in each color | `filter: hue-rotate()` or `saturate()` on every piece for its color, and above all animated: draw each color once (below, "Bringing an existing module up to the budget") and show that. |
| A light gradient laid over a picture, with `opacity` | `mix-blend-mode` (overlay, screen…): a plain gradient looks nearly the same. A blend mode only on one still thing on your page, if at all. |
| Pictures about **twice the size they're shown at** (a trinket shown at 64 px: a picture 128 pixels across); pixel art at its own tiny size with `image-rendering: pixelated` | A big picture shown small. Shrink it before you keep it (below, "A gallery"). |
| **One `<canvas>`** for many moving pieces (rain, sparks, confetti, a game), its pixels at most twice its CSS size | Dozens of elements, each animated on its own. |
| Animation that ends: a reveal of one to three seconds, then still | `infinite` on Today, ever. On your page, endless only for a few small pieces on `transform` or `opacity`, and stopped when off screen. |
| `will-change: transform` on the one thing about to move, taken off after | `will-change` on everything "to be safe". |
| Stopping what's off screen, hidden, or left (`leave()`) | A `requestAnimationFrame` loop that never stops. |

### The habits

1. **Today's section is still.** No loops, no filters, no blend modes, small pictures. The magic is one tap away, on your page.
2. **Animate only `transform` and `opacity`.**
3. **Never animate a filter, a blur or a blend mode.** On Today use none; on your page, few, and still.
4. **No chained shadows on many pieces.** One shadow, or a lighter surface.
5. **Pictures about twice their shown size**, pixel art at its own size. Lazy-load what's below the fold (`loading="lazy"`).
6. **Many moving pieces go in one canvas**, sized to its box (not the whole screen), its pixel ratio at most 2. Smooth motion runs on `requestAnimationFrame`; `core.timer.every` is for slow things (in a frame it runs once a second at most).
7. **Stop what can't be seen:** off screen, the page hidden, or the person gone elsewhere (`leave()`).
8. **Honor Reduce Motion** (the person's setting: `prefers-reduced-motion`). The moment still happens (the rare card is still shown as rare), but as a fade or at once, with nothing looping. Put CSS animations under `@media (prefers-reduced-motion: no-preference)`, and check it in code for a canvas, `requestAnimationFrame` or `element.animate()`, which no style sheet stops.
9. **One scene at a time on your page.** Opening something large (a card, a picture, a level) lets go of the last one; `leave()` lets go of everything: cancel the loop, remove the canvas, clear pictures (`img.src = ""`), revoke object URLs (`URL.revokeObjectURL`), disconnect observers.
10. **A draw is cheap and can run again.** `render(el)` may run several times: clear `el` and draw fresh, don't add on top. Never save or fetch from a draw (rule 7).
11. **Keep counts sane.** A shelf of 200 shows the first 24 and a "More" button; a log shows its latest lines, not all of them.

A loop that runs only while it can be seen, and never under Reduce Motion (draw one still frame first, so there's always something there):

```js
// For a canvas or anything driven by requestAnimationFrame. Returns a stop function: call it in leave().
function runWhileSeen(el, frame) {
  const still = matchMedia("(prefers-reduced-motion: reduce)");
  let raf = 0, inView = true;
  const tick = (t) => { frame(t); raf = requestAnimationFrame(tick); };
  const sync = () => {
    const run = inView && document.visibilityState === "visible" && !still.matches;
    if (run && !raf) raf = requestAnimationFrame(tick);
    if (!run && raf) { cancelAnimationFrame(raf); raf = 0; }
  };
  const io = new IntersectionObserver((e) => { inView = e[e.length - 1].isIntersecting; sync(); });
  io.observe(el);                                   // it notices Creative Chief's scrolling too, from inside your frame
  document.addEventListener("visibilitychange", sync);
  still.addEventListener("change", sync);
  sync();
  return () => { io.disconnect(); document.removeEventListener("visibilitychange", sync); still.removeEventListener("change", sync); if (raf) cancelAnimationFrame(raf); raf = 0; };
}

// A canvas sized to its box, at most twice the pixels.
function sizeCanvas(cv) {
  const r = Math.min(2, window.devicePixelRatio || 1);
  cv.width = Math.round(cv.clientWidth * r); cv.height = Math.round(cv.clientHeight * r);
  const g = cv.getContext("2d"); g.setTransform(r, 0, 0, r, 0, 0); return g;
}
```

### Talking without bursts (kit 4, Creative Chief v0.4.0-alpha.133)

A burst of saves or calls all at once (when someone signs in, or when an add-on says hello) is what a phone notices first,
and it's what Creative Chief holds back (rule 7). Most bursts come from how modules and frames talk, so:

1. **Save only what changed.** Never save on every hello, every start or every answer. A setting saved as it already is costs
   nothing (Creative Chief answers it and tells no frame), but a time that changes on every call ("last hello at …") is a new
   save each time: save it once in ten minutes at most.
2. **One hello at a time.** An add-on saying hello to its parent waits for the answer before it tries again, never starts a
   second hello while one is waiting, and stops once it's answered. Count the tries **before** you wait, so the stop can't
   be skipped.
3. **Each frame has its own memory.** Your Today section, your page, the tools beside it and a hidden frame (which answers
   your actions and capabilities) each run `setup` and `start()`, and none sees what another keeps. Don't hand data to the
   hidden frame expecting your page to have it: a frame that needs something reads it, or asks for it, itself (or another
   frame sends it with `core.ui.tell`).
4. **A picture goes in one piece.** A message between modules (a capability's arguments or its answer) carries up to 200,000
   characters, so send a picture whole, not in parts.
5. **Ask for many things a few at a time** (four, say), and don't ask again every few seconds while some are missing: ask
   again when something changed.
6. **An add-on starts again each time its parent does.** One that requires its parent (`"parent"`, with its capability in
   `requires`) stops when the parent stops and starts again when it's back: switched on, updated, or started again after a
   stop. So its hello runs again, and answering a hello must be cheap and safe to repeat (no saves when nothing changed).

What Creative Chief does: a module that saves more than 25 times a second, or reads or fetches more than 250 times in ten
seconds, has its calls over the limit held back, in order, and they go through a moment later; your module carries on. Only
one that keeps going over for five seconds in a row, or has more than 250 calls waiting at once, is switched off, as a throw
would be (rule 7).

### Keeping it beautiful: worked examples

Each example says what goes on Today, what goes on the page, and where the magic is. Mix them for your own kind of module.

**A rare card pull, with foil** (cards, trinkets, stickers, loot)
- **Today:** the collection as still pictures; a rare one shows its foil as a **still shine**, a gradient laid over it (or drawn into its picture), and a small mark ("★ Rare"). A box or pack waiting is a still picture with "A box to open ›".
- **Page, the pull:** one box at a time. It shakes (`transform: rotate`, a few times, then stops), the lid lifts (`transform`), a burst of sparks plays **in one canvas over the box** for about a second and a half, then the canvas is removed. Cards come out one by one (`transform` and `opacity`), and the rare one waits a beat, flips (`transform: rotateY`, with `backface-visibility: hidden`) and **its foil sweeps across**: a light stripe on a layer of its own, moved with `transform`, nothing else changing, settling as the still shine the shelf shows. Then it's still.
- **Page, opening one card large:** the foil moves again, following the person's finger as they drag across it (on `pointermove`, set the stripe's `transform`); it stops when they let go. One card large at a time; closing it lets it go.
- **Reduce Motion:** the box opens at once, the cards fade in, the rare one shows its still shine and "★ Rare".
- The foil, with tokens only (the shine is the lightest color in each mode: `var(--card)` in light, `var(--ink)` in dark). At rest it's the still shine; `is-revealed` sweeps it in once:

```css
.my-cards-card { position: relative; overflow: hidden; border-radius: 10px; }
.my-cards-foil { position: absolute; inset: 0 -60%; pointer-events: none; opacity: .55;
  --my-cards-shine: var(--card);
  background: linear-gradient(105deg, transparent 35%, var(--my-cards-shine) 48%, var(--accent-soft) 52%, transparent 65%); }
[data-mode="dark"] .my-cards-foil { --my-cards-shine: var(--ink); opacity: .35; }
@media (prefers-reduced-motion: no-preference) {
  .my-cards-card.is-revealed .my-cards-foil { animation: my-cards-sweep 1.4s ease-out 1; }
}
@keyframes my-cards-sweep { from { transform: translateX(-60%); } to { transform: none; } }
```

**A game scene** (an arcade game, a board game, a walk-around world)
- **Today:** a still line or small picture: your best score, whose turn it is, "Play ›". No game running there.
- **Page:** the game in **one canvas**, sized to its box, pixel ratio at most 2, its loop in `runWhileSeen` (above), so it stops when the person scrolls away, switches apps or leaves. Sprites as small pictures (pixel art at its own size, scaled with `imageSmoothingEnabled = false`). Load a level's pictures when it starts and let go of the last level's.
- **Where the magic is:** in the canvas, where it's cheap: particles, screen shake, lighting drawn as gradients, as much as the game wants. Keep the menus and scores around it as plain elements.
- **Reduce Motion:** the game still plays (movement is the game), but without screen shake, flashes or a busy background.

**Ambient motion** (weather, a pet, a garden, a mood scene)
- **Today:** a still scene that shows how things are: the sky as gradients (a sun's glow is a `radial-gradient`, not a blur), the pet in a pose that matches its mood. Still pictures can be lovely; that's the point of this place.
- **Page:** the scene can move, gently: a few pieces (clouds drifting, a pet breathing, a bounce when it's fed) on `transform` and `opacity`; rain, snow or anything with many pieces in one canvas. Endless motion stops when off screen, and on a phone it's worth offering it as a setting ("Move the sky"), off to begin with, so the person chooses it.
- **Where the magic is:** in the reactions: the pet jumps when fed, lightning flashes once when a storm starts. A short moment that answers the person beats a loop that runs for no one.
- **Saving:** save when the person does something (feeds, waters), never on a timer that ticks with the animation.

**A gallery of pictures** (snaps, art, a mood board)
- **Shrink before you keep:** when the person picks a photo, draw it into a canvas at the largest size your module ever shows it (say 1200 pixels on its longest side for a large view), and keep that with `core.storage.media` (which shrinks to 1600 at most).
- **Thumbnails are small pictures, not big ones shown small.** Either keep a small copy beside each one when it's added (a second `put` of a copy about 256 pixels across; it counts toward the 200 a day), or make them once per visit, one at a time: draw each picture into a 256-pixel canvas, keep the small result (`toBlob` and `URL.createObjectURL`), and let the large one go before the next.
- **Today:** the newest three or four, as small thumbnails. No slideshow there.
- **Page:** a grid of thumbnails, `loading="lazy"`, a page of 24 or so with "More"; no filter or shadow on each one (a `var(--line)` border). One large picture open at a time; closing it clears its `src`.
- **Where the magic is:** the large view: it scales up from its thumbnail (`transform`), and a swipe moves to the next (`transform`). Captions, who sent it, who saved it.

**Multiplayer and shared things** (a shared board, a group game, a chat-driven module)
- **Today:** a still summary: "Your move", "3 new", the faces of who's here (from `core.people()` and `core.presence`, small pictures already).
- **Page:** `log.watch` brings each new line (section 7); **draw only what changed**: animate the newest move or line in (`transform`, `opacity`), and leave the rest as it is. Don't draw the whole scene again for every line, and don't keep an element for every line ever: show the latest ones.
- **Where the magic is:** in the moment someone else acts: their piece slides into place, a small burst in the canvas when someone wins. Never poll, never save from a watch (rule 7).

**Charts and numbers** (a tracker, a dashboard, stats)
- **Today:** a small still chart (an SVG with a handful of shapes, in tokens) or a number with a short trend line.
- **Page:** the full chart, drawn once; it can grow in (`transform: scaleY`) on open. For thousands of points, a canvas instead of thousands of SVG shapes.

### Bringing an existing module up to the budget

**Claude, when the person gives you a module made before this section** (or asks why it's heavy on a phone): keep its look, its moments and everything it does; change **how** it's drawn and **where**. Move magic rather than cut it: from Today to the page, from always to when it's opened, from every piece to the one in front of the person.

1. **Read its places.** List what each one draws (Today, its page, its side) and every animation, filter, blend mode, shadow, picture and timer in its code and its CSS.
2. **Search the code and its CSS for:** `filter:` (`blur`, `drop-shadow`, `hue-rotate`, `saturate`…), `backdrop-filter`, `mix-blend-mode`, `infinite`, `@keyframes` that change anything but `transform` and `opacity`, `will-change`, `requestAnimationFrame` loops without a stop, pictures bigger than twice their shown size, elements in the dozens each animated, and the same work done again in every `render`.
3. **Change each one, keeping its look:**

| You find | Change it to | It keeps |
|---|---|---|
| Anything moving forever in Today's section | Still: its resting pose, or the moment's last frame | How it looks at rest |
| `filter: hue-rotate()` to color many pieces | Each color drawn once into a small canvas (below), shown as a picture | The same colors |
| Chained `drop-shadow`s on each piece (often for dark mode) | One `box-shadow`, an outline drawn into the picture, or a `var(--card)` frame (section 8, "Depth by lighter surfaces") | The edge that lifts it off the page |
| An endless filter animation (a shimmer, a rainbow cycle) | A still gradient on the shelf; a sweep on `transform` when one is opened large | The shimmer, when it's the one being looked at |
| `mix-blend-mode` on a sheen | A plain light gradient with `opacity` | Nearly the same light |
| `filter: blur()` for a glow or fog | A `radial-gradient` fading to `transparent` | The same soft light |
| Many animated elements (rain, sparks, stars) | One canvas, run with `runWhileSeen` | Every piece, moving the same way |
| Moving with `top` or `left` | `transform: translate()` | The same path |
| Pictures far bigger than shown | Kept at about twice their shown size | The same picture, sharp |
| An animation that runs under Reduce Motion | The same moment as a fade or at once | The moment itself |

   Drawing each color once, in place of `hue-rotate` on every piece (the sprite is your own picture; the colors are what your module already uses):

```js
// Once per sprite and color, then reuse: a picture with no filter left on it.
const tinted = new Map();
async function tint(src, hue) {
  const key = src + "|" + hue;
  if (tinted.has(key)) return tinted.get(key);
  const img = new Image(); img.src = src; await img.decode();
  const cv = document.createElement("canvas"); cv.width = img.naturalWidth; cv.height = img.naturalHeight;
  const g = cv.getContext("2d"); g.filter = "hue-rotate(" + hue + "deg)"; g.drawImage(img, 0, 0);
  const url = cv.toDataURL(); tinted.set(key, url); return url;   // small pixel art stays small
}
```

   (The canvas's `filter` is used once and is gone; nothing stays filtered on screen. Two things to check: an older iPhone may not have a canvas `filter` (`"filter" in g` is false), and a picture from another site can't be read back from a canvas (`toDataURL` throws). For either, draw the sprite in its colors from your own palette, as pixel art usually is, or keep the small canvas itself on screen.)

4. **Keep what people saved.** Settings and data stay as they are; a setting that turned on motion keeps working (on your page).
5. **Look at it side by side** with the old version, in light and in dark (section 8): the same colors, the same shapes, the same moments, in their new places.
6. **Raise the version** (a minor, like `1.6.0`), set `"kit": 4`, and add a CHANGELOG line that says it plainly: "Lighter on phones: Today stays still; foil and sparkles play when a card is opened."
7. **Tell the person how to check it** on a phone (below), with Reduce Motion off.

### Checking it

- **When you drop it in** Your modules, the check warns (it never refuses) about the heavy patterns above: an animation of a filter or blur that never ends, a blend mode, chained `drop-shadow`s, and, when it has a Today section, a picture written into module.js more than 460 pixels across. It reads module.js's text, so it can't see CSS your code builds while it runs, or pictures from your `imageDomains`: no warning isn't a promise (Creative Chief v0.4.0-alpha.207).
- **On a computer**, in Chrome: open your module's page and Today, then DevTools, **More tools, Layers**: a few layers, each small, and a memory estimate that doesn't keep growing while you watch. **Rendering, Paint flashing**: nothing flashing on Today while nobody touches it.
- **On the phone**, with every module the person uses switched on and Reduce Motion off: open Creative Chief, sign in, look at Today, open your page, play its big moment, go back, several times. A Mac's Safari (Develop menu, Web Inspector, Timelines) shows a connected iPhone's memory, if one is at hand.
- If the phone still ends the page, say so honestly: which place was open and what it was doing. That's what the person needs to fix it, and no number in this kit can promise it won't happen.

## 9. The template

Start from this module and change the parts marked CHANGE. It has a menu entry, a page, a synced setting, a manual path and an AI path. Before sharing, set `id`, `name`, `author`, `description` and `scope` (`"group"`).

**manifest.json**

```json
{
  "id": "my-module",
  "name": "My module",
  "version": "0.2.0",
  "author": "you@example.com",
  "basedOn": null,
  "description": "Say in one plain sentence what it does for you.",
  "summary": "Say in one line what it's for",
  "icon": "icon.svg",
  "contract": "^2.0",
  "kind": "code",
  "scope": "mine",
  "writes": "none",
  "provides": { "my-module.main": "1.0" },
  "requires": {},
  "enhancedBy": { "ai.complete": "^1.0" },
  "googleScopes": [],
  "dataFormat": {},
  "settings": [ { "key": "greeting", "label": "What it says", "type": "text", "default": "Hello" } ],
  "kit": 4,
  "sandbox": 1,
  "places": [ { "hook": "page", "id": "main", "title": "My module" }, { "hook": "nav.item", "id": "main", "label": "My module", "page": "main" } ],
  "entry": "module.js",
  "assets": []
}
```

**module.js**

```js
// My module: the template for a Creative Chief module. Copy this folder, then change the id, the
// name and the parts marked CHANGE. Keep the shape: one file, one `export default function setup(core)`, no imports.
// setup() only registers things. Read Drive in start(), never in setup(). Ask the core for everything.

export default function setup(core) {
  const greeting = () => core.settings().get().greeting || "Hello";

  // A capability of your own, so other modules can build on yours (they check core.capability("my-module.main")).
  core.provide("my-module.main", { greeting });

  // CHANGE: the app's entry (its tile in Apps) and the page it opens.
  core.hooks["nav.item"].add({ id: "main", label: "My module", page: "main" });
  core.hooks.page.add({
    id: "main",
    title: "My module",
    render(el) {
      // Draw only inside el. Use the core's classes (btn-primary, btn-secondary, hint, row-buttons) and theme
      // tokens (var(--ink), var(--accent), var(--line)…) for any color, never raw colors.
      const out = document.createElement("p");
      out.setAttribute("role", "status");
      const row = document.createElement("div");
      row.className = "row-buttons";

      // The manual path: always works, with AI off and with nobody's key.
      const manual = document.createElement("button");
      manual.type = "button";
      manual.className = "btn-primary";
      manual.textContent = "Say it";
      manual.addEventListener("click", () => { out.textContent = greeting() + "!"; });
      row.appendChild(manual);

      // The easy AI path: offered only when the AI module is on and has a key. Never the only way.
      const ai = core.capability("ai.complete");
      if (ai && typeof ai.ready === "function" && ai.ready()) {
        const ask = document.createElement("button");
        ask.type = "button";
        ask.className = "btn-secondary";
        ask.textContent = "Ask AI";
        ask.addEventListener("click", async () => {
          out.textContent = "Asking the AI…";
          try {
            const got = await ai.complete({ prompt: "Write a one-line friendly greeting.", system: "One short sentence." });
            out.textContent = (got && got.text) || greeting() + "!";
          } catch (e) {
            out.textContent = "The AI couldn't answer, so: " + greeting() + "!"; // show a line, don't throw
          }
        });
        row.appendChild(ask);
      }
      el.appendChild(row);
      el.appendChild(out);
    }
  });

  return {
    start() { /* after sign-in: read your data here (core.storage.json.read), never in setup */ },
    stop() { /* undo anything you started yourself; the core removes your hooks, actions and timers */ }
  };
}
```

**CHANGELOG.md**

```markdown
# My module

## 0.1.0
- First version.
```

The kit's own example is the template above. Creative Chief's reference modules show more: **hello-dog** (the smallest: a Settings page with a button, an action and a setting), **leaderboard** (a page with tabs, a capability other modules post to, a shared log; built into Creative Chief since alpha.110, so it isn't in the Shop), **pinboard** (pictures kept for a while with `core.storage.media`), **clip-shelf** (audio clips kept with `core.storage.files`, recorded with `core.microphone`), **book-shelf** (books kept with `core.storage.files`, an EPUB's first page shown through `core.text.clean`) and **dice-table** (a page with a side, a chat and `core.ui.tell`). If you can see them, copy their patterns.

**A right-panel section, in short:**

```js
core.hooks["today.section"].add({
  id: "main",
  title: "Plants",                       // the core draws this as the section's title
  places: ["today"],                     // Today ("sidebar" is still accepted, and shows on Today)
  render(el) {                           // draw only inside el, with theme tokens
    const p = document.createElement("p");
    p.style.color = "var(--ink-soft)";
    p.textContent = "Fern: watered today.";
    el.appendChild(p);
  },
  refresh() { /* read again: the panel's Refresh */ }
});
```

## 10. Test it: drop it in Your modules

1. In Creative Chief, open **You**, then **Your modules** (turn on **Creator mode** at its top). A drop on the Shop page works too: it opens Your modules and turns Creator mode on.
2. Drop your module's folder (or a `.zip` of it) on **Add a module of your own**. Or click **choose its files** and pick `manifest.json`, `module.js` and `icon.svg`.
3. Creative Chief checks it before anything is saved:
   - the manifest is complete;
   - it's made for this contract;
   - the id and version are free;
   - the code is one file with a default `setup`;
   - a **trial load** runs `setup` with stand-ins and Drive refused.
4. **It passed:** click **Install**. It's yours (under **Yours**, in **Your modules**), on, and it works straight away. Dropping a module in turns Creator mode on and opens Your modules. Try it with AI off.
5. **It didn't pass:** the report lists what to fix, numbered, in plain words. Click **Copy the report**, paste it into the same Claude chat, and say "fix these". Claude sends the files back whole. Drop them again.

A report looks like this:

```
Creative Chief checked "Plant log" (plant-log 1.0.0) from manifest.json, module.js.
Result: it can't be installed yet. 2 problems to fix:
1. manifest.json: missing enhancedBy.
2. The trial load failed: setup() threw: Plant log provides plant-log.plants without declaring it in its manifest.
```

**Claude, when you get a report:** fix every numbered problem, check the list in section 12 again, raise nothing else, and send every file back complete. If a problem names a limit code, don't work around it: follow section 14.

Common problems and their fixes:

| The report says | The fix |
|---|---|
| `missing <field>` | Add the field (all 18 are needed, even as `{}`, `[]` or `null`). |
| `has no export default function setup(core)` | The file must contain `export default function setup(core) { … }`. |
| `imports another file` | Put the code in module.js; no `import`. |
| `setup() used core.storage…; setup may only register things` | Move the read to `start()` or into `render`. |
| `provides X without declaring it` | List X in `provides`, or don't `core.provide` it. |
| `the action X is already registered` | Use a unique name that starts with your id. |
| `Version x is already installed. Raise the version` | Raise `version` in manifest.json. |
| `doesn't run: SyntaxError` | A typo in module.js: check every bracket and quote. |
| `icon.svg can't have …` or `icon.svg can point only inside itself` | Draw the icon again as plain shapes, with no script, no event attributes and no links outside the file ("Your module's icon", section 3). |
| `summary must be one line of text, 80 characters or fewer` | Shorten it to one line; the description holds the rest. |
| `uses a raw color (#336699)` | Use a theme token instead: `var(--ink)`, `var(--ink-soft)`, `var(--muted)`, `var(--accent)`, `var(--accent-text)`, `var(--line)`. A color that means something the tokens can't (a team, a clear sky): name it in manifest.json's `palette` and use `var(--mod-<name>)` (section 8). |
| `palette.red (#f1c40f) is 1.22:1 on Granny Smith's light paper …` | Use the shade it offers ("try …"), or a darker one; for a dark value, a lighter one. Words go in `var(--ink)` beside the color. |
| `reaches the network itself` | Remove `fetch`/`XMLHttpRequest`; read the page with `core.capability("web.fetch").get(url)` (section 6). |
| `uses web.fetch, but manifest.json lists no webDomains` | Add `"webDomains": ["the.site.com"]` to manifest.json. |
| `webDomains must be website names` | Just the name, like `"api.open-meteo.com"`: no `https://`, no `/path`. |
| `imageDomains must be website names` | Just the name of the site the pictures come from, like `"cards.scryfall.io"`: no `https://`, no `/path`. A picture that doesn't show: its site isn't in `imageDomains` (look at the address it redirects to, too). |
| `module.js tries to …, which modules can't do (limit <code> …)` | It tried something on the list in section 13. Remove it, build the closest thing that works (section 14), and write a capability request for what's missing. |
| (it installs, then is "switched off: …", or "… stopped" under Modules) | Your code threw while running. The message says where. Catch errors and show a line instead. (From Creative Chief v0.4.0-alpha.68 an error inside a capability another module calls goes back to that caller, and a failed read you didn't catch is noted without switching the module off; a bug still switches it off. From v0.4.0-alpha.134 a bare "Script error.", the browser's words for an error it won't describe, is noted too, unless more than 10 come in ten seconds; to see the real error, open your module's page on a computer with the browser's console open. **Start it again** on its Settings page starts it.) |

If the page ever stops working after you install something, open **creativechief.app/?safe=1**. (On a phone, a page that goes blank and reloads by itself is most often memory: section 8a.) Safe mode never runs installed modules, so you can switch yours off in Your modules.

## 11. Share it with your group

- **Your own module, for everyone:** put its folder (named after its `id`, holding `manifest.json`, `module.js`, `icon.svg` and `CHANGELOG.md`) in your group's shared folder, next to the other modules. Set `"scope": "group"`. Friends see it in the Shop under **From your group**, with **New**.
- **The easy way (alpha.9):** drop the folder or a `.zip` in Your modules, and click **Add to** your group's shop beside Install (or, on one of yours, **Send it to your shops** under For creators: your shop and each of your groups, with **Add to**, **Update in** or **Up to date**, and **Everywhere I'm connected** for all of them at once). Creative Chief puts it in your group's shared folder for you, with Undo. A newer version of your own module **replaces** the one there the same way (**Update in**); someone else's module is theirs to replace. (alpha.10: in several groups, it saves in the group whose tab is open. **Your module doesn't need to know which group it is in.** Its shared data (the commons) is the open group's: switching tabs redraws your page and sections, so read shared data when you draw, not once in `start()`.)
- **A new version:** raise `version`, add a `## x.y.z` section at the top of `CHANGELOG.md`, and replace the files in your module's folder (or use **Update in**, or **Everywhere I'm connected**, in Send it to your shops). Everyone who installed it sees **Update available**, with what's new, and chooses when. Nobody's copy changes by itself, and **Roll back** is one click.
- **An idea or fix for someone else's module:** don't edit their folder. Put your copy in the **Suggestions** folder (inside the group's shared folder) as `<their-id>-<your name>/`, with a line at the top of its CHANGELOG saying what you changed and why. Its author decides.
- **Building on someone's module:** copy it under a new `id`, and set `basedOn` to `{ "id", "author", "version" }` of the original. The Shop shows "based on …". (alpha.15: **Make my own version** on their module in the Shop saves it as a .zip with `MAKE-IT-MINE.txt`, the request to give Claude. Claude: give it a new `id` everywhere, in `manifest.json` and in `module.js`; set `basedOn`; make the person the `author`; start at `0.1.0` with a CHANGELOG line saying what it's based on; keep its `category`.)
- **Your own shop (alpha.15):** on one of yours, **Add to my shop** (in Send it to your shops, or beside Install on a drop) puts a module in your shop, which anyone with its link can see and install (they see your email as `author`). **Copy my shop's link** is in the Shop, so nobody goes into Drive. A group's owner can make the group's shop public the same way (its link is on the Group page).
- **Updates to someone else's module in a group (alpha.15):** a group's copy added from a shop remembers where it came from (a `cc-from.json` beside it: the core writes it; it isn't part of your module). When its author puts a newer version there, anyone in the group can **Bring** it **across**: it's still the author's. So when you update your own module, update it in your shop too.
- **An add-on to another module (alpha.63):** a module that belongs with another one (a game for Pocket Chief, say) sets `"parent": "<its id>"`. It's still a module of its own, with its own `id`, version and CHANGELOG, installed, updated and rolled back on its own. The Shop lists it under its parent; Add to group shop and Add to my shop keep its folder inside its parent's, in `addons/<id>/`, when the parent is in that shop. **If it can't work without its parent,** put the parent's capability in `requires` (like `"pocket-chief.games": "^1.0"`): Install then waits until the parent is installed, and removing the parent offers to remove it too. **If it can work alone,** put the capability in `enhancedBy` and check `core.capability(...)` for `null`, as in section 5. To show up in the parent's own screen (Pocket Chief's list of games), call a capability the parent provides for that (its `offers` say how); the parent's author decides what it offers. One level only: an add-on can't have add-ons of its own.
- **Feedback on Creative Chief itself:** use **Send feedback** in You (under Settings).

## 12. Claude: what to give back

1. If the request is unclear, ask **at most two short questions**. Otherwise, start.
2. Give back **`manifest.json`, `module.js`, `icon.svg` and `CHANGELOG.md`**, each **complete**, in its own code block, with the file name on the line before it. Never give part of a file or "the rest unchanged".
3. Then, in a few plain sentences: what the module does, where it appears (Apps, Today, a project page or Settings), what it saves and where, and how to try it ("Drop the folder in Your modules, in You"). If part of what the person asked for can't be done, say so here too, and give the capability request (section 14) in its own code block.
4. Before you send, check every point:
   - all 18 manifest fields (plus `category` and `kit` always, `summary` and `icon` (kit 4) always, `phrases` when it has actions, `webDomains` when it reads a website); `kit` is the kit version at the top of this file; `contract` is `"^2.0"` with `"sandbox": 1`, its `places`, and its `actions` and `undo` types listed (section 1a); `kind` is `"code"`; `entry` is `"module.js"`; `assets` is `[]`;
   - a `category` from the list in section 3 (a new one only when none fits), and you told the person which;
   - colors come from the Look's tokens; one that means something the tokens can't (a team, a character, a sky) is named in `palette` and used as `var(--mod-<name>, <a token>)`, never alone (a name or a shape beside it);
   - `icon.svg` is a simple square picture under 20 KB, with no script, event attributes or links outside it; `summary` is one line, 80 characters at most;
   - tools used now and then beside a page are a `page.side` (one per page); a chat is the manifest's `"chat"` with no message box of your own; what only the screen knows goes between frames with `core.ui.tell`;
   - the `id` is used everywhere: provided capabilities `<id>.x`, undo types, action names, element ids;
   - `export default function setup(core)` once; no `import` or other `export`;
   - `setup` reads nothing from Drive;
   - every write is inside `core.write`, with `core.changes.record`, and an undo type where it makes sense;
   - every thing a person can add or change has a `write: true` action (rule 8) that calls the same function as its button, and that function does its own `core.write`; each action's `description` says what it does in the module's own words, written to the person ("your plants", not "the user's plants" or "the person's") and never naming another action by its inside name (not "use upkeep_schedule": say what it does, "to set a single time, use the Schedule button");
   - a module that provides a capability describes each one in `"offers"` (does, how, example); one that uses a friend's module's capability has it in `enhancedBy`, checks it for `null`, and uses only calls from the What modules offer block the person pasted;
   - events on the person's calendar go through `w.run("create_event" | "update_event" | "delete_event", …)` inside `core.write`, keeping the event's id, with `undo: { type: "event", eventId, title }` for one just added;
   - every action people would type for has a phrase in `"phrases"` (section 6, "Phrases people can type"): its own words with the module's name in them, a `{slot}` for each required parameter, and a `said` sentence in the action's result; a read people will type again and again doesn't give the same answer every time unless that's the point;
   - no `fetch`, `XMLHttpRequest`, `localStorage`, `setInterval`, `gapi` or `google.accounts`, and no raw colors (not even `white` or `#fff`, and not inside `color-mix()`);
   - the code habits: a comment says why, in one line, with no version number or history (that goes in `CHANGELOG.md`); a long function is split into named steps (small functions above `setup`, each doing one thing); a block written three times is one helper; and for your own CSS, the habits in section 8 (tokens only, no `!important`, change the rule instead of cancelling it);
   - a module that reads a website lists it in `webDomains`, checks `core.capability("web.fetch")` for `null`, catches "Not read: …", and has a typed manual path;
   - a module that shows pictures from another website lists that site (and any site its picture addresses redirect to) in `imageDomains`;
   - a module that keeps audio clips lists them in `files` (with `"writes": "shared"` for the group's), keeps them only with `core.storage.files` inside `core.write`, plays them only from a tap, draws Remove only on its own clips (`mine`), and catches a refused `put` or `play()` with a line;
   - a module that keeps books lists `"book"` in `files`, shows how far a big book has gone with `progress`, puts a book's markup into the page only through `core.text.clean`, and offers Open in Google Drive (`link`) for a PDF;
   - a module that records lists `"microphone"` in `devices`, starts only from a tap, catches a refused `start()` with a line, and keeps working without it; a full screen button calls `core.ui.fullScreen` from the tap and takes its label from `core.events.on("fullScreen")` (drawn always, since it works everywhere but the preview), or, with the browser's own `requestFullscreen()`, only when `document.fullscreenEnabled`;
   - a right-panel section draws only inside `el`, has no title of its own, and fits about 230 px;
   - the phone budget (section 8a): Today's section still (no animation that repeats, no filters, blurs or blend modes, small pictures); on the page, only `transform` and `opacity` animate, many moving pieces are in one canvas, what's off screen or left stops, and Reduce Motion is honored;
   - no bursts (section 8a, "Talking without bursts"): it saves only what changed, says hello one at a time and stops once answered, asks for many things a few at a time, and sends a picture in one piece;
   - AI is in `enhancedBy` only, and only when the AI path is better than the module without it; the AI button is drawn only when `ai.ready()`, and there's a manual path;
   - a capability nobody asked for is offered only after the person said yes to it;
   - errors are caught and shown as a line ("Sign in to see this"), never thrown;
   - every `core.capability(...)` is checked for `null`;
   - the version is raised if the person gave you an earlier copy;
   - nothing on the list in section 13 is tried, or worked around; if the person wanted one of those, you followed section 14 and gave back a capability request too.

## 13. What modules can't do yet

Each of these has a code that never changes. When module.js tries one, the Shop's check names the code and says why. Some are deliberate safety rules: they protect people's files and the Undo everyone relies on, so a request can change them only with a design that keeps what they protect. The rest aren't built yet.

<!-- limits:start (made from Creative Chief's own table; don't edit by hand) -->
- **Save files such as pictures, audio or PDFs** (`store.files`). Every write goes through core.write, which records a Changed line and keeps an Undo. That works for small text, not yet for files: they need a size limit, a safe way to show them, and a way to undo and clean them up. What works instead: Pictures: core.storage.media (since v0.4.0-alpha.65, sandboxed modules), which keeps each one as a file, shrunk, with an expiry if you choose. Audio clips: core.storage.files (since v0.4.0-alpha.233, sandboxed modules), which keeps each one as a file of its own until whoever added it takes it out. Books (PDF, EPUB, text): core.storage.files too (since v0.4.0-alpha.234), with core.text.clean for an EPUB's pages. Other files: save small JSON in your own folder (core.storage.json) and text lines in a shared log in the commons.
- **Read another person's files or folders** (`read.others`, a safety rule). Creative Chief is signed in to your whole Google Drive, and a module someone else wrote runs with that sign-in. So a module keeps to its own data, and the Shop checks its code for that before anyone installs it. What works instead: Use your own folder (core.storage.moduleData()) and your module's folder in the group's commons (core.storage.moduleData("shared")); what friends share with the group goes there.
- **Delete files or data** (`delete.data`, a safety rule). Changed and Undo, and the backups behind them, are the one thing no module can switch off, and Undo can't bring back a deleted file. In the commons a delete would remove other people's things too. What works instead: Write a smaller version of your own JSON file (inside core.write, with Undo), or keep a list of what's hidden and leave it out when you draw.
- **Change or remove lines in a shared log** (`log.rewrite`, a safety rule). When two people write at the same moment, only adding at the end is sure to keep both. A log nobody can rewrite also means nobody can change or remove what someone else said. What works instead: Add a line that corrects or hides an earlier one ("edit: …", "hide: <id>"), and read the log with that in mind.
- **Run while Creative Chief is closed, or send notifications** (`run.background`). There is no server: everything happens in each person's open browser tab, and timers pause while the page is hidden. Waking someone up needs a server that knows when to. What works instead: Show things when Creative Chief is open: a right-panel section, a dot or count on your page, or a line at the start (core.events "opened").
- **Change how typed messages, Morning sync or the Evening debrief work** (`hooks.unavailable`). The reader's rules and the ceremonies are still one piece inside the core; opening them to installed modules safely needs that piece split first, so these hooks aren't drawn for installed modules yet. What works instead: Add a menu entry and page, a right-panel section, a project-page section, settings, agenda items ("what's on today") or actions, with phrases people can type in Main Chat ("phrases" in manifest.json; alpha.34).
<!-- limits:end -->

Also worth knowing: everything happens while Creative Chief is open on someone's device, so a few seconds is normal and nothing is truly real-time. A line someone else adds to a shared log shows on your screen a second or two after it was saved (alpha.81), not at once. There's no live voice or video between people inside the app (recording a clip with the microphone works, and a module can keep it for the group: sections 1a and 5), no bundled image files yet (draw pictures in code), and no guarantee that something shared is ever deleted. Websites can be read only through `web.fetch` (with the group's web relay) or `web.lookup` (with the AI), and only the ones listed in `webDomains`; not pages built by JavaScript, behind a sign-in or that block robots (section 6). A section can go on Today or a project page, nowhere else yet.

## 14. When something can't be done

**Claude, when the person asks for something on the list in section 13 (or anything this file doesn't offer):**

1. **Say plainly what can't be done, and why.** One or two sentences, with the limit's code and its reason from section 13 ("Modules can't save pictures yet (`store.files`): …"). Don't hide it in the code.
2. **If the goal isn't clear, ask at most two questions**, and only these: *What are you trying to achieve?* and *Who should see or change what?* Otherwise, start.
3. **Build the closest version that works**, inside the rules, and say what it lacks ("It shares a link to the photo in your Drive instead of the photo; friends who can't open that folder see the caption only."). **Never work around a limit unsafely:** no `fetch` of your own, no reading or writing outside your own folders and the commons, no pictures squeezed into JSON or a log as text, no overwriting other people's data to make it disappear, no tricks to keep running in the background. A limit that's a safety rule stays a rule.
4. **Write a capability request** in the form below, after the three files, in its own code block. Put the goal first and the mechanism second: what the person needs to happen, not which function you'd like.
5. **Tell the person how to send it:** drop the module in Your modules to test it as usual; beside the check's report, click **Request a capability**. It opens New report in Reports, as a capability request to creativechief.app, with the limit filled in and the module's manifest attached: they paste the request below what's there and click **Send**, then follow the answer in Reports (My reports). (From Creative Chief v0.4.0-alpha.70; before it, the request was saved in the group's Requests folder.)

**The capability request (copy this form exactly; fill every line):**

```markdown
## Capability request

- **Module:** <name> (<id> <version>), contract <the manifest's contract>
- **Limit:** <code> (<its title from section 13>)
- **What the person wanted, in their own words:** "<quote them>"
- **Who uses it, and how:** <who, how often, on which devices>
- **What I built instead:** <the closest version that works>
- **What's lost:** <what that can't do>
- **The goal:** <the outcome needed, in plain words, with no mechanism>
- **A possible shape (optional):** <one way the core could offer it, as a suggestion>
- **Who must see or change what:** <who can read it, who can write it, who must never see it; how long it lasts>
- **How much it matters:** <nice to have / the module is much less useful without it / the module can't exist without it>, and how many people asked
- **Examples:**
  1. <a short, concrete case>
  2. <another>
```

A worked example (the whole set is in REQUEST-EXAMPLES.md in the kit):

```markdown
## Capability request

- **Module:** Snaps (snaps 0.2.0), contract ^1.1
- **Limit:** store.files (Save files such as pictures, audio or PDFs)
- **What the person wanted, in their own words:** "Like Snapchat: I send the group a photo and it's gone the next day."
- **Who uses it, and how:** our group of five, a few photos a day, mostly from phones
- **What I built instead:** each person picks a photo that's already in their own Drive; the group log gets a line with its caption and a link; lines older than a day aren't shown
- **What's lost:** the photo has to be shared in Drive by hand first, it never actually disappears, and anyone the person shared it with can still open it
- **The goal:** a picture the group can see for about a day, that then can't be opened by anyone
- **A possible shape (optional):** core.storage.media(scope).put(file, { expires }) that resizes, stores in the commons and removes it when it expires, with Undo while it lasts
- **Who must see or change what:** everyone in the group sees it while it lasts; only the sender can take it back early; nobody outside the group, ever
- **How much it matters:** the module can't exist without it; three of us asked
- **Examples:**
  1. A photo of the finished page, gone tomorrow
  2. A funny sign, gone by evening
```
