/addons:write-addonfrom addons
Scaffolds and modifies claude-ui addons: themes, panes, bands, slash commands, and renderers for code fences or tool results. Guides capability selection and frame choice.
Ships in addons. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
An addon is a folder. claude-ui serves its files as committed (no build) into iframes with
sandbox="allow-scripts": no cookies, no storage, no parent DOM, no inline scripts, no network
except the net: origins the owner approves. Everything else goes through the bridge, which the
SDK wraps. Full reference: docs/site/features/addons.md in the claude-ui repository
(https://github.com/cuonghuunguyen/claude-code-ui/blob/main/docs/site/features/addons.md).
Complete working example: examples/addons/example/.
Map each wish to a part and the capabilities it needs. Ask only when the wish fits none of them.
| Wish | Manifest | Capabilities |
|---|---|---|
| Colours of the whole app | themes (and/or css) | none |
| A panel next to the chat | views[] kind: "pane" | ui.pane |
| A strip above the prompt box | views[] kind: "band" | ui.band |
/<addon>:<cmd> that fills the prompt box | commands, commandsEntry | ui.command, prompt.insert |
Draw ```<lang> blocks | renderers[] {fence} | render.fence:<lang> |
| Draw a tool's result | renderers[] {tool} | render.tool:<tool name> |
| Read the session's messages and tool calls | in a pane, band or command | session.read |
| Status bar text, toasts | ui.status, ui.toast | |
| Debug lines the owner can read in the Addons dialog | log(text, level) | log |
| Call an HTTP API | fetch from a view | net:<origin> (the API must allow CORS for Origin: null) |
Where code runs decides when it runs. A pane frame loads lazily: nothing runs until the user first shows the pane, and a pane tab in the main area runs only while that tab exists. A band and the hidden command frame load with the session that shows. Status text that must be current before the pane was ever opened belongs in a band (or, with commands, the command frame). Choose the frame by that, and tell the user which you chose and why.
Impossible, whatever is approved: send a prompt, read or write files, run shell or git, answer
permissions, read the session from a renderer (renderers get only ui.ready and ui.toast).
Say so instead of working around it.
Request no capability the addon does not use: the owner approves each one, and every new one in an update needs approval again.
<addon>/
addon.json
claude-ui-addon.js # SDK, copied, never edited
claude-ui-addon.d.ts # SDK types, copied, never edited
<view>.html, <view>.js # one pair per view, command handler or renderer
jsconfig.json # only for the type check
Copy the SDK of the claude-ui version the user runs (claude-ui --version prints it):
v=$(claude-ui --version 2>/dev/null | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
for f in claude-ui-addon.js claude-ui-addon.d.ts; do
curl -fsSL "https://raw.githubusercontent.com/cuonghuunguyen/claude-code-ui/v$v/packages/addon-sdk/$f" -o "$f" ||
curl -fsSL "https://raw.githubusercontent.com/cuonghuunguyen/claude-code-ui/main/packages/addon-sdk/$f" -o "$f"
done
From a claude-ui checkout, copy packages/addon-sdk/claude-ui-addon.{js,d.ts} instead. A tag
without the SDK (older than the SDK) falls back to main; then tell the user the SDK may be
newer than their claude-ui.
addon.json:
{
"name": "my-addon",
"version": "0.1.0",
"description": "One line shown in the Addons dialog",
"capabilities": ["ui.pane", "session.read"],
"views": [{ "id": "main", "title": "My pane", "entry": "pane.html", "kind": "pane" }]
}
name: ^[a-z0-9]+(-[a-z0-9]+)*$, at most 64. It namespaces commands (/my-addon:cmd) and
pane ids, and never changes between versions.views: {id, title, entry, kind: "pane" | "band", phone?}; phone: false hides it below 640 px.commands: {name, description, argumentHint?}; commandsEntry: the .html that handles them
(default: the first view's entry). It runs in a hidden frame per session.renderers: {fence: "<lang>", entry} or {tool: "<tool name>", entry}.themes: {id, name, light?, dark?, vars?, background?, options?, slots?, extends?, css?}. A given mode needs all 19 keys as #rrggbb: bg, card,
side, fg, muted, border, primary, pfg, kw, str, fn, type, num, cmt,
varc, err, warn, ok, info. Copy the theme of examples/addons/example/addon.json and
change the values; keep text on bg/card at a 4.5:1 contrast.assets: {<id>: {path, label?}} (id lowercase words joined by -, up to 24; at most 16): image files (png jpg jpeg webp avif gif svg) the addon names by id. The file MAY be missing (the user adds it, so ship no copyrighted art; lint says asset-missing, over 2 MB asset-large); an existing file must stay inside the addon folder.themes[].background: {light?: {image, mobile?}, dark?: {...}, veil?: 0..1, panelAlpha?: 0..1}: image and mobile are asset ids (an unknown id fails install). Shown as [data-part="backdrop"] behind the app only while the theme is picked and the image file of the current mode exists; mobile below 768 px; veil = page background over the image; panelAlpha = opacity of the main panels (--panel-alpha, default 1). <html data-backdrop> is set while it shows. No file: the theme works without a background.themes[].slots: loader, done-icon, send-icon = an asset id (the file may be missing: the built-in mark stays); thinking-phrases = {<lang>: [phrases]} (en, vi or xx / xx-XX; at most 4 languages, 12 phrases each, 1 to 60 characters of plain text). loader replaces the spinner of a running tool call, session row and tab (part loader), done-icon the check of a finished tool call (part done-icon), send-icon the arrow of the send button, phrases the "Thinking" text (one per turn). The images are decorative 16 px <img>: animate them in css ([data-part="loader"] img). <html> has data-slot-<name> while a slot is in effect.themes[].extends: "<theme>" (same addon) or "<addon>:<theme>": the base's css, vars, background, slots and options apply under the theme's own; the palette is the theme's own (a mode it lacks comes from the base). At most 3 links. A missing target, a disabled addon or a loop is only the lint extends-missing (the theme works alone); a malformed value, a self-reference or a loop inside the addon fails the install.claudeUi (top level): *, 1.5.0, >=1.5, ^1.5, ~1.5. Outside it the addon is in state error (needs Claude UI >=1.6 (this is 1.5.0)) and not served. Omit it for any version.themes[].options (at most 8): {id, label, type?, ...}: boolean (default; default?), select (choices: [{value, label}] 2 to 12, value [a-z0-9-]+, default?), range (min, max, step, default: numbers, at most 3 decimals), color (default #rrggbb). Each shows as a control in Settings > Appearance and sets --opt-<id> on <html> while the theme is picked (boolean 0/1, select the value, range the number, color the hex) plus data-opt-<id> for boolean (on/off) and select. Read them in css: calc(var(--opt-density) * 0.4), :root[data-opt-mood="storm"] ....themes[].vars: {light?, dark?}, each a map "--name": value (at most 64): your own custom properties, set only while the theme is picked, read in css as var(--name). Not the tokens the palette sets (--background, --primary, --syntax-*, --graph-*; --context-* are free). Value up to 200 characters, no ; { } < > \ @ /* or newline, balanced brackets and quotes, no url() / image-set().graph: 8 #rrggbb colours for the Git graph lanes (--graph-1..8, the first 6 also --context-1..6); optional, 3:1 on card.themes[].css: a .css for that theme only (needs Chrome 120, Safari 17.2 or Firefox 117; older browsers show the palette and vars only) (the daemon scopes it: a rule applies only while the theme is picked). Write plain selectors; :root, html, .dark still mean <html>. Prefer this over the top-level css. @font-face and @property stay global: prefix their names with the addon name. The daemon renames @keyframes, @counter-style and @font-palette-values per theme (and the animation / list-style / font-palette references), so a @keyframes spin cannot replace the app's own. A leading * also matches the root; start a ::-webkit-scrollbar selector with :root, else it matches inside the root only. Css that is broken or over 512 KB is served empty (palette stays). Move a legacy top-level css into themes[].css.css (legacy): one .css applied while enabled, for every theme (its :root and .dark token rules then override built-in themes too), in a cascade layer after the app's own styles: it wins without !important (inline style attributes and the unlayered library CSS of CodeMirror .cm-*, xterm .xterm*, KaTeX .katex* and the code highlighter need it); it cannot load external images or @import.
Select app elements with [data-part="<name>"] (stable parts, list: docs/site/features/addon-parts.md),
never [data-testid=...] or Tailwind class names: those change without notice.
React to the session with lifecycle attributes (list and budget: "Lifecycle" in the same doc): data-phase="thinking|waiting|idle" on session-area and <html>, data-just-finished on session-area (1200 ms after a turn ends), data-focus-opened on focus-page, <html data-motion="on|off"> (reduced motion: give a still version), <html data-page-hidden> (the app pauses all animations then). Animate transform and opacity only.
The Addons dialog lists lint warnings (Checks) per addon, never blocking: [data-testid] selectors, unknown or deprecated [data-part] names (and ^= $= *= |= values no part matches; a near name is suggested), @font-face / @property / top-level @keyframes names without the addon prefix (name them <addon>-spin), top-level css next to themes (move it to themes[].css), unparsable or over-512 KB css (over 256 KB warns), and palette text pairs under 4.5:1 contrast (low-contrast). Fix every one... or \, and must exist. Every view, command and renderer needs
its capability, or install fails naming it.Each .html loads its script as a module and has no inline script or style:
<!doctype html>
<meta charset="utf-8" />
<link rel="stylesheet" href="pane.css" />
<div id="out"></div>
<script type="module" src="pane.js"></script>
jsconfig.json:
{ "compilerOptions": { "checkJs": true, "strict": true, "target": "ES2023", "module": "ESNext", "moduleResolution": "Bundler", "lib": ["ES2023", "DOM", "DOM.Iterable"], "noEmit": true }, "exclude": ["claude-ui-addon.js", "*.test.mjs"] }
Start every script with // @ts-check and import from ./claude-ui-addon.js.
| SDK | Use for |
|---|---|
watchSession(fn) | Pane or band showing session data: fn(parts) after init, again with all parts on every change. Call at module top level |
on("command.run", (m) => …) | Command handler: m.name, m.args |
on("render", (m) => …) | Renderer: "fence" in m → m.fence.lang, m.fence.source; else m.tool.name, .input, .result |
on("init", (m) => …), on("theme.changed", …) | m.addon, m.view, m.role, m.session, m.theme, m.mode (light/dark) |
autoHeight() | Every band and renderer: keeps the frame as tall as the content (band 24-160 px, renderer up to 480) |
insertPrompt(text) | Fill the prompt box (≤ 32 KiB); the user sends it |
setStatus(text | null), toast(text) | ≤ 80 and ≤ 200 characters |
log(text, level?) | A line in the addon's log (≤ 500 characters, 20 per second); works in renderers too |
call(type, payload) | Any request; rejects with AddonError (code: refused, bad_request, unknown) |
Parts: narrow by p.type. The useful ones: user_text and assistant_text (text),
tool_call (tool, input, status), tool_result (toolUseId, output, isError),
turn_result (durationMs, costUsd, usage), todo_update (items), subagent. The full
union is Part in claude-ui-addon.d.ts. A part is sent again when it changes (same id):
key by id, as watchSession does.
Rules:
textContent/createElement, never innerHTML with session or tool data..css file or element.style; inline <style> and style="" attributes are
blocked by the frame's CSP.color-scheme from the app's mode; use light-dark() or
@media (prefers-color-scheme) in CSS for your own colours.node:assert script (node <name>.test.mjs). A frame
is hard to debug: catching a parsing bug there costs a page reload and a guess.Types: npx -y -p typescript tsc -p jsconfig.json in the addon folder. Fix every error; never silence one
with any or @ts-ignore.
Logic: run each *.test.mjs.
Manifest: every path exists; every view, command and renderer has its capability; no unused capability.
Run it (needs the user's claude-ui running; ask before touching their install): /addons in the
prompt box › Local folder › absolute path of the addon › Install › Approve and
enable. A local folder is re-read when the dialog opens: after an edit, reopen the dialog
(and reload the page for view scripts). A row in Error names what failed; a refused call
shows a toast and is listed under the addon's row.
Dev loop and preview (needs the user's claude-ui running): claude-ui addon dev <folder> installs the
folder in Dev mode, enables it when it has no capabilities and prints
preview: http://127.0.0.1:<port>/#/addon-preview. That page shows every part in every state (running,
error, permission, Focus, tool card statuses), light and dark, with a theme and mode picker; CSS edits
reload live. The addon's lint warnings (Checks) are in Settings › Addons. Fix every warning.
Report to the user: the folder, what each part does, the capabilities it asks for and why, and the type-check result.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
claude-ui, addon-development, scaffolding, browser-extension
npx claudepluginhub cuonghuunguyen/claude-code-ui --plugin addonsOther plugins' skills for the same job