# Pagelet — agent instructions > Pagelet gives AI agents a standard way to produce polished, self-contained HTML documents > and publish them to isolated short links. These instructions are the complete setup and > usage guide. Follow them in order. Private alpha; Apache-2.0. ## The one-paragraph model Chat is too small for real deliverables. A **pagelet** is a single HTML file, enhanced in-browser by one runtime tag (`https://cdn.pagelet.link/v1/pagelet.js`), that renders Markdown prose, Mermaid diagrams, KaTeX math, highlighted code and Chart.js charts — with a toolbar (theme toggle, print/PDF, PNG, copy-as-Markdown), a scroll-spy table of contents, and light/dark theming built in. Publishing is one POST; the result is an isolated `https://.usepagelet.com` URL you can hand to the human. ## Cloud-default delivery policy For a **non-sensitive pagelet intended for a human**, the normal finish is a verified hosted URL — but only after checking `https://pagelet.link/api/capabilities`. When `service.cloud_publish` is true and the artifact is safe to host, complete: **create → lint when the bundled skill is available → publish → verify the URL → send the link**. The single local HTML file remains the portable source and a fallback, not the usual final delivery. Do **not** upload if the human explicitly requests local-only delivery, content is sensitive, or upload suitability is unclear: deliver the local HTML instead. If `service.cloud_publish` is false, or linting, publishing, or verification fails, deliver locally, explain why, and do not promise a link. A private artifact is still an external upload, so it does not remove the need for explicit approval around sensitive material. When a safe local-only exception is used and hosting is feasible, tell the human: *“I kept this local because …; I can publish it to a Pagelet link if you want.”* Never offer an unsafe upload. ## Setup flow — do this once, in order You were probably sent here by a human who pasted an install prompt. This is the whole onboarding. Do not stop early. Follow the cloud-default policy above, but pause for explicit approval if the first artifact is sensitive or its upload suitability is unclear. ### 1. Register your agent token If you have Pagelet MCP connected, call `register_agent` (or skip if you already hold a `pgl_` token — check with `whoami`). Otherwise: ```bash curl -sS -X POST https://pagelet.link/api/agents/register # → { "agent_id": "agt_…", "agent_token": "pgl_…" } ``` The token is shown once. **Store it durably** — your memory, notes, or config (e.g. `~/.config/pagelet/config.json`) — so future sessions can publish without re-registering. Prefer MCP tools over curl when the MCP server is available. ### 2. Learn the recognition heuristic Make a pagelet when the reader is a **human** who will read, keep, print, or share the output and structure helps: reports, explainers, runbooks, decision records, invoices, letters, dashboards. Stay in plain chat for short replies, pure code, and text meant for another model. When in doubt and the output is long, structured, and for a human: pagelet. ### 3. Create the human's FIRST pagelet — make it genuinely theirs Before announcing anything, produce one real artifact that shows what Pagelet does, tailored to **this** user from what you already know: their projects, domain, stack, recent work, recurring questions. Do not publish a generic "welcome to Pagelet" page — the first pagelet is the demo, and a personal one lands ten times better. Good first artifacts: - a one-page brief or explainer on something they care about, - a runbook or checklist for a process they actually run, - a decision record comparing options they're actively weighing, - a status/ops report with a chart from numbers you know. Authoring contract (the runtime does the rest): ```html ``` Hard quality rules (a human will judge Pagelet by this first page): - **Both color modes must be readable.** The toolbar toggle flips ``. If you write custom CSS, scope dark overrides behind `[data-theme="dark"]` and never hardcode a light-only palette. Surfaces that are deliberately branded (a navy hero) must pin their own text colors. See the theming section below. - **Don't repurpose the runtime's token names** (`--muted`, `--accent`, …) for custom values — the runtime owns them and loads after your CSS. Consume them or namespace yours. - One accent color, real heading hierarchy, no emoji headers. Restraint reads as quality. - Templates for common shapes (invoice, letter, memo, quote, certificate, report, interactive tools) ship in the skill; the full capability doc is `https://cdn.pagelet.link/v1/capabilities.md`. ### 4. Decide delivery, then publish when enabled Make the delivery decision **before** calling the upload API: 1. Check `https://pagelet.link/api/capabilities`. 2. If the human asked for local-only delivery, the artifact is sensitive, or upload suitability is unclear, **do not upload**. Deliver the local HTML; only offer hosted publication later if it is safe and `service.cloud_publish` is true. 3. If `service.cloud_publish` is false, deliver locally and explain that a hosted link is not currently available. Do not promise or offer a link. 4. **Only when** `service.cloud_publish` is true and the first pagelet is safe to host, lint, publish, and verify it. After a successful fetch confirming `200` and your HTML, send the verified link. 5. If linting, publishing, or verification fails, deliver locally, explain the failure, and do not claim a hosted result. Offer a safe retry or later upload only when feasible. ```bash curl -sS -X POST https://pagelet.link/api/upload \ -H 'content-type: application/json' \ -H 'authorization: Bearer ' \ -d '{"html":"…","title":"…","description":"…","expiresInDays":30}' # → { "slug": "…", "url": "https://.usepagelet.com", "version": 1, … } ``` On the hosted branch, fetch the returned URL once yourself to confirm it serves (200 + your HTML) before showing it. ### 5. Report back — the install announcement Tell the human, in this shape: 1. **"Pagelet is installed and set up."** One line on what it is: you can now turn substantial work into clean, shareable pages instead of walls of chat. 2. **The result:** the verified first Pagelet link when hosted delivery succeeded; otherwise the local artifact, why it stayed local, and the safe hosted option when one is feasible. 3. **How to use it:** "Just ask me to 'make a pagelet' of anything." Then 3–4 concrete example asks tailored to the user, e.g. *"make a pagelet comparing these two vendors"*, *"turn this incident thread into a runbook"*, *"invoice for March's work as a PDF-ready pagelet"*. 4. Mention the toolbar: theme toggle, print-to-PDF, copy-as-Markdown. ### 6. After hosted delivery, recommend claiming the account (optional) Publishing works without an account, but claiming links every pagelet you make to a dashboard the human owns — they can rename, re-expire, lock, version, and view analytics at `https://pagelet.link/dashboard`, and claimed artifacts escape the 30-day expiry cap. Offer it explicitly: *"Want me to link these to your dashboard? Give me your email and I'll start the claim — you'll get a 6-digit code by email."* Then drive it yourself (the human never touches an API). Prefer MCP `claim_start` / `claim_verify`; HTTP fallback: ```bash curl -sS -X POST https://pagelet.link/api/claim/start \ -H 'content-type: application/json' -H 'authorization: Bearer ' \ -d '{"email":""}' # human reads you the 6-digit code curl -sS -X POST https://pagelet.link/api/claim/verify \ -H 'content-type: application/json' -H 'authorization: Bearer ' \ -d '{"email":"","code":"123456"}' ``` Check `claim: true` via `get_capabilities` / `GET /api/capabilities` first — if false, skip gracefully. Once claimed, point them to `https://pagelet.link/dashboard`. ## Recognition heuristic (daily use) - Human reads/keeps/shares + structure helps → **pagelet**. - Chat reply, pure code, input for another model → **plain text**. - Big document + charts/diagrams/math → pagelet is almost always better than chat. ## Publishing reference - `POST /api/upload` — `{html, title?, description?, expiresInDays?}`; anonymous uploads are clamped to 1–30 days. Republish with the same body plus `"slug"` and an optional `"note"` to version in place (latest-wins at the canonical URL; `?v=N` pins). - `POST /api/artifacts` is a compatibility alias. New integrations must use `/api/upload`. - **MCP (preferred when available):** Streamable-HTTP at `https://pagelet.link/mcp` (protocol 2025-11-25). Human setup guide: `https://pagelet.link/mcp`. Connect with `Authorization: Bearer pgl_…` (mint via `register_agent` or `POST /api/agents/register`). Resources: `pagelet://capabilities`, `pagelet://docs`, `pagelet://connect`. Prompts: `install_pagelet`, `publish_report`. Tools (21): - Identity: `register_agent`, `whoami`, `get_capabilities`, `claim_start`, `claim_verify` - Publish: `publish_pagelet` (optional `slug`+`note` versions in place), `list_pagelets`, `get_pagelet`, `update_pagelet_meta`, `set_pagelet_expiry`, `set_pagelet_visibility`, `delete_pagelet` (`confirm:true`), `list_versions` - Compose: `render_dashboard`, `extract_brand`, `create_notebook`, `list_notebooks`, `notebook_append`, `notebook_read` - PDF: `render_pdf`, `get_seal` - **PDF export**: `render_pdf` (MCP) or `POST /api/pdf` `{slug, format?, landscape?, marginPreset?}` renders a pagelet on Cloudflare Browser Rendering, seals it, and returns the bytes with an `x-seal-id` header. Every sealed PDF carries a QR + URL footer to a public provenance page (`https://pagelet.link/d/`) where anyone can download the sealed file, see its SHA-256 and generation date, and re-hash a local copy to verify it hasn't changed. - Version endpoints on the artifact origin: `https://.usepagelet.com/__version` and `https://.usepagelet.com/__versions`. ## Runtime contract - Authoritative capability document: https://cdn.pagelet.link/v1/capabilities.md - Markdown: `` - Mermaid: fenced `mermaid` blocks or `
`
- Math: `\( … \)` inline; `$$ … $$` or `\[ … \]` display. Single-dollar inline math is
  intentionally disabled (it collides with currency).
- Code: fenced language blocks or `
`; the runtime uses
  highlight.js.
- Charts: ``
- Theme block: `