Skip to content

Plugin guide for coding agents ​

This is the brief every UnCorded plugin workspace starts with: the desktop app writes it into the plugin folder as AGENTS.md. It's the one place the rules and the quality bar are written down. Everything else links here or to the reference pages.

UnCorded is a self-hosted platform where every feature is a plugin. A plugin is a folder with a manifest.json, an optional backend (a sandboxed Bun subprocess with its own SQLite database), and an optional frontend (a sandboxed iframe inside the UnCorded app). People will use what you build next to the platform's own UI, so it has to feel like part of it.

How to work ​

  1. Plan before code. Write PLAN.md in the plugin folder and agree it with the person you're building for. Cover:

    • what the user is trying to get done
    • each screen and the path through them
    • every state: empty, loading, error, permission denied, offline
    • the data you store
    • the permissions you need

    Keep it short; it's a contract, not an essay.

  2. Build in small steps. Get each step working in the real app before starting the next.

  3. Finish with the checklist at the end of this page.

Rules ​

These are enforced by the runtime or will cost you hours if ignored.

Identity and the manifest:

  • Don't rename the plugin folder. Its name is the plugin's slug. It must equal name in manifest.json, and the install directory, the database file and every URL key off it.
  • Declare every capability you use in the manifest's permissions. The runtime rejects any call to a capability you didn't declare.
  • The manifest is strictly validated. Unknown top-level fields are rejected.
  • Keep api_version at ^1.2. The UI kit, tooltips and toasts with an action need a 1.2 server; with ^1.2 an older server refuses the install cleanly instead of showing a half-working plugin.

Backend:

  • Register handlers synchronously at the top level of backend/index.ts, before any await. Async setup comes after.
  • Migrations run once each, in number order (001_init.sql, 002_….sql, …).
    • Editing a file that already ran does nothing. Put changes in a new file.
    • Numbers must have no gaps: a gap fails the plugin's load with MIGRATION_GAP.
    • Never renumber or delete a migration that has shipped.
  • Catch SDK failures by their stable .code, not by message text.

Frontend:

  • The frontend is the frontend/ folder, served into a sandboxed iframe. No build step is required. If you use one, ship its output in frontend/: the runtime serves files and never builds anything.
  • Load the SDK from the runtime, never bundle it: <script src="/sdk/plugin-frontend.js"></script>, then await window.UncodedPlugin.createPluginFrontend().

Dependencies:

  • The backend SDK comes from the runtime. Import @uncorded/plugin-sdk freely, but never add it to package.json. It isn't on npm, so listing it makes bun install fail.
  • Third-party packages must resolve from this folder's own node_modules. Run bun add <pkg> here; the runtime doesn't install dependencies.
  • Don't add a tsconfig.json to the plugin folder. The runtime resolves the SDK through a tsconfig one directory up, and a nearer one shadows it.

Testing it in the app ​

With the UnCorded MCP tools connected, call preview_plugin_change. Show the owner its summary and permissions, and call install_plugin only after they agree.

Otherwise, the owner uses the desktop app: Server settings → Plugins → Develop, picks the plugin, and chooses Install into this server. That copies it into the server and restarts the server. Install again after each change to try the new version.

The quality bar ​

Users judge the whole platform by the worst plugin they open. Build to the standard of the app around you, using the pieces the platform gives you instead of re-making them.

Use the platform's UI.

  • Link the UI kit with <link rel="stylesheet" href="/sdk/plugin-ui.css">. Build common controls from its uc-* classes: buttons, fields, lists, dialogs, empty states, skeletons.
  • Style your own parts with its --uc-* tokens. Never hardcode colours, so the panel follows the user's theme, light or dark, and their accent. Text: --uc-foreground, --uc-muted-foreground. Surfaces: --uc-background, --uc-card. The user's colour: --uc-brand. Hover fill: --uc-hover.
  • The /sdk/plugin-frontend.js script wires the kit's behaviour: data-open="id" opens a <dialog>, data-close and a backdrop click close it, and a popover menu is placed under its button and gets arrow keys. Don't hand-write these.

The kit's classes (exact names; the UI kit page shows each one):

PartMarkup
Buttonbutton.uc-btn + uc-primary / uc-secondary / uc-ghost / uc-destructive / uc-destructive-outline / uc-link; sizes uc-xs uc-sm uc-lg; uc-icon-only; aria-busy="true" while working
Fielddiv.uc-field > label.uc-label[for] + .uc-input (input, textarea, or select inside span.uc-select) + p.uc-description / p.uc-error, linked with aria-describedby
Choiceslabel.uc-choice > input.uc-checkbox / input.uc-radio / input.uc-switch[role=switch]; one-of-a-few: div.uc-segmented[role=radiogroup] > label > input[type=radio].uc-sr-only; filters: div.uc-pills > button.uc-pill[aria-pressed]
Listh2.uc-group-label above div.uc-card.uc-flush > div.uc-list (uc-dense, uc-long) > .uc-row > .uc-row-content (.uc-row-title, .uc-row-description) + .uc-row-end
Statusspan.uc-badge (+ uc-success uc-warning uc-destructive uc-brand uc-outline); div.uc-alert (same colours) > .uc-icon + .uc-alert-content (.uc-alert-title, .uc-alert-description) + .uc-alert-actions; span.uc-dot only beside words
Empty / loadingdiv.uc-empty > .uc-empty-media + h3.uc-empty-title + p.uc-empty-description + one uc-btn uc-primary; span.uc-skeleton in an aria-busy="true" region; span.uc-spinner
Dialog / sheetdialog.uc-dialog or dialog.uc-sheet (uc-left, uc-bottom) > optional form[method=dialog] > header.uc-dialog-header (.uc-dialog-title, .uc-dialog-description) + div.uc-dialog-panel + footer.uc-dialog-footer; close button .uc-dialog-close[data-close]
Menubutton[popovertarget=id][aria-haspopup=menu] + div.uc-menu[popover][role=menu]#id > button.uc-menu-item[role=menuitem] (or menuitemradio in a role=group), .uc-menu-label, hr.uc-menu-separator
Otheruc-kbd, uc-num (tabular figures), uc-muted (muted text), uc-sr-only, uc-touch-label, uc-separator

Use the shell for anything that belongs to the app:

  • For a yes/no question before something destructive, use sdk.platform.modal.confirm. Never window.confirm or alert.
  • For a reversible action, act at once and offer Undo with sdk.platform.toast.show({ message, action: { label: "Undo", onAction } }). That beats asking first.
  • Use sdk.platform.userCard.show for people.
  • Use sdk.platform.files.preview and sdk.platform.files.download for files.

Tooltips come for free, with a mouse.

  • An icon-only button needs an aria-label. It names the button for screen readers and becomes its tooltip.
  • Use data-tooltip (or title) for a hint, and data-tooltip-key for a shortcut.
  • Tooltips never open on touch, because a tap must act. Anything a user needs, say in words: an icon button can show <span class="uc-touch-label">Add</span>, which only a touch screen sees.
  • A disabled button says why: data-tooltip for the mouse, plus the same words next to it, linked with aria-describedby, for touch and screen readers.

Design every state.

  • An empty state teaches what goes here and offers the one action that starts it.
  • Loading holds the layout with skeletons; a spinner is only for short waits.
  • An error says what happened and what to do next, and keeps whatever the user typed.
  • Denied and offline states say so plainly.

Touch and small screens.

  • Make targets at least 44px. Inputs use 16px text; the kit does both.
  • On touch, leave var(--uc-top-gap) at the top for the shell's panel toolbar.
  • Check a narrow panel as well as a wide one.

Words.

  • Write plain, specific, sentence-case copy.
  • Buttons say what they do: "Save bill", not "OK".
  • Show numbers in tabular figures (uc-num) so columns don't jitter.

Keyboard and screen readers.

  • Everything is reachable. Focus is always visible. Escape closes what's open, and focus returns to what opened it.
  • Use native controls (<button>, <dialog>, radios, checkboxes) before ARIA roles. A role promises keys: a role="menu" without arrow keys is worse than plain buttons. The kit's menu gets its keys from the SDK script.
  • When something changes on its own, say so: loading sets aria-busy="true" on the region, plus one role="status" line ("Loading bills…", then "12 bills"). A form error goes in the field's .uc-error (role="alert"), and on submit, focus moves to the first invalid field.
  • Colour is never the only signal: a red dot needs the word "Overdue" beside it.

Before calling it done ​

  • [ ] PLAN.md matches what you built.
  • [ ] Every state in the plan has been seen working: empty, loading, error, denied, offline.
  • [ ] Checked in light and dark, narrow and wide, with a mouse and by keyboard.
  • [ ] No window.confirm / alert, no hardcoded colours, no icon button without an aria-label, no uc-* class that isn't in the table above.
  • [ ] Every capability used is declared in the manifest; nothing undeclared is called.
  • [ ] Migrations are numbered with no gaps and none that shipped were edited.

Reference ​

Fetch these when you need them; don't read the whole site up front.