Reference
Templates
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 write pages and TSX templates, follow its "Templates" section. Run `cubek check` after every edit until it is clean.
- Components: plain functions, may be
asyncand querydb. HTML attribute names (class,for,maxlength),selected={isOn},<>...</>; no{...props}, no<Ui.Button>. Text is escaped; trusted HTML:raw(markdown.render(text)). SVG is TSX (<path d={d} />); JSON-LD:{jsonLd({ "@type": "Event", name })};asset(path)linkspublic/<path>.
// src/pages/home.tsx
import { asset, type JSX } from "cubek"
import type { Note } from "../lib/notes"
export function Layout(props: { title: string; children?: JSX.Child }): JSX.Element {
return <html lang="en"><head><meta charset="utf-8" /><title>{props.title}</title><link rel="stylesheet" href={asset("styles.css")} /></head><body>{props.children}</body></html>
}
export function Home(props: { notes: Note[] }): JSX.Element {
return (
<Layout title="Notes">
<form method="post" action="/notes"><input name="title" required maxlength={200} /><textarea name="body"></textarea><button>Add</button></form>
{props.notes.length === 0 ? <p>No notes yet.</p> : <ul>{props.notes.map((n) => <li key={n.id}><a href={`/notes/${n.id}`}>{n.title}</a></li>)}</ul>}
</Layout>
)
}Sessions are app code (sign-up, sign-in, sign-out: copy auth.md): a
random token in c.setCookie("sid", token, { httpOnly: true, sameSite: "lax", path: "/" }), its SHA-256 in sessions, passwords via
crypto.password.hash/verify.
async function currentUserId(c: Context): Promise<string | null> {
const token = c.cookie("sid")
if (token === null) return null
const s = await db.sessions.findOne({ where: { tokenHash: crypto.hash("sha256", token) } })
return s === null ? null : s.userId
}