Reference

Primitives

For your agentCopy this and give it to the AI you're building with.
Run `cubek skill`, read all of it and follow it exactly (no CLI: download https://cubek.dev/SKILL.md verbatim with curl; don't summarize it); when you use tasks, storage, secrets or outbound fetch, follow its "Primitives" section.
Run `cubek check` after every edit until it is clean.
  • kv.get<T>(k), set(k, v, { ttl: "10m" }), incr(k, by?, { ttl: "1m" }) (ttl from creation), delete(k).
  • task.on("name", async (p: { id: string }) => {...}), task.run("name", { id }, { delay: "5m", retries: 3 }), task.schedule("name", "0 8 * * *") (cron, UTC); tasks may run twice: be idempotent.
  • storage.put(key, bytesOrString, { contentType }), get(key) → Bytes | null, delete, list(prefix), signed url(key) / uploadUrl(key, { maxSize }).
  • realtime.publish("room:1", event) → EventSource("/_cubek/realtime?channel=room:1").
  • fetch(url, { method, headers, body, timeout: "5s" }) (≤ 10 s) → res.status, res.json<T>(), res.text(); public addresses only (http.md).
  • secrets.get("NAME") → string | null; log.info/warn/error(msg, data?), console.log.
  • mail.send({ to, subject, text, html?, attachments? }) (tasks.md).
  • validate.string/number/boolean/literal/enum/array/object/record, .optional() .nullable(); .parse throws, .safeParse → { success, data | error }; Infer<typeof v>.
  • crypto.hmac/timingSafeEqual (webhooks: http.md), crypto.randomUUID(), randomInt(max) (0 ≤ n < max); encoding.base64/hex.encode/decode; markdown.render(s) → SafeHtml, markdown.html(s) → string (feeds); csv.parse(text, { header: true }); fmt.date(iso, { format: "date" }), fmt.number(n, { decimals: 2 }), fmt.currency(n, "EUR").
  • Several apps: cubek init --workspace photos --apps web,media; apps.media.fn() calls, events.publish/on (workspaces.md).