Ui sdk

From Asymmetric-al/core · View interactive version

Ui sdk is an AI agent skill from the GitHub repository Asymmetric-al/core. Builds and maintains Core's UI SDK (@ui-sdk/react and @ui-sdk/core) components as Maia-styled wrappers in packages/ui, with keyboard, focus, ARIA, server-rendering and hydration tests. Use when evaluating or implementing a shared control where UI SDK may give better interaction, accessibility, simpl

How to use this skill

Skill file

Build with ui-sdk

Core: in Asymmetric-al/core, read This repository at the end first. It replaces the install, docs-path, styling and testing steps below where they differ. Reuse existing @asym/ui components first; the import, part, attribute and testing rules below apply to UI SDK code only.

ui-sdk is a library of UI behaviors: keyboard navigation, focus, selection, dismissal, popups, drag and drop and the ARIA they need. Its components are built from those behaviors and render no styles of their own, in React, Vue, Svelte, Solid and web components. @ui-sdk/core/web.css gives them an optional default look. When a component is missing, you build it from the same behaviors in @ui-sdk/core, and it gets the same keyboard, focus, server rendering and right to left support.

Read first

The docs for the installed version ship in each package, as Markdown:

The same docs are online at https://ui-sdk.dev/docs. Prefer the installed copy: it matches the version in the project.

A page with no build step, like an Artifact, installs nothing: it loads https://ui-sdk.dev/web.js and web.css with two tags. Read https://ui-sdk.dev/web.md instead of llms.txt. It's the web components docs in one file, for that page, and references/web-components.md has the rest.

Otherwise, if no @ui-sdk package is installed yet, install @ui-sdk/core and the framework's package with the project's package manager. In a Nuxt 4 or newer app using @ui-sdk/vue, also add "@ui-sdk/vue" to modules in nuxt.config.ts.

Pick your path

  1. Build an interface from our components, like a settings page, a form or a command palette: read references/build-interface.md.
  2. Build a component or behavior ui-sdk doesn't ship, or extend one of ours: read references/create-component.md.

Most interfaces only need path 1. When one part of it needs a component we don't have, follow path 2 for that part.

Every path ends the same way:

  1. Make it agent-ready: references/agent-ready.md.
  2. Test it: references/testing.md.

Rules for every path

When you're done

  1. Typecheck. If the root tsconfig.json has "files": [] and references, npx tsc --noEmit checks nothing: run npx tsc -b or npx tsc --noEmit -p <app config>. For Svelte, run svelte-check; for Vue, vue-tsc.
  2. Write and run tests (see testing.md). Every task gets tests, and every interface gets at least the agent test from agent-ready.md. If a test finds a bug in code you were asked only to test, mark it test.fails (or it.fails) with a one-line reason, report the bug, and leave the suite green.
  3. Read every comment in your diff. Delete it unless it names a browser quirk, an APG rule or a trade-off, and cut what's left to two lines. Turn JSDoc on app code into a plain comment or delete it. Never tell the reader to replace something.
  4. Report each command you ran with its exit code, anything you couldn't check, and anything the docs or types got wrong or left out.

<!-- CORE-OVERLAY-START -->

This repository (Asymmetric-al/core)

Adapted from vercel-labs/ui packages/core/skills/ui-sdk at commit d850982

(the @ui-sdk/core@0.1.0-beta.17 release, Apache-2.0). Modified by

Asymmetric-al/core: the description is rewritten, the Core note at the top and

this overlay were added, and three references carry marked secret-scanner

comments. The upstream text above is otherwise unchanged. Provenance is in

references/upstream.md, and LICENSE is the upstream Apache-2.0 text.

On conflict, follow the current user request, root AGENTS.md,

packages/ui/AGENTS.md (Choosing a library, UI SDK implementation) and

docs/ai/rules/frontend.md. They win

over the upstream text above. Repository paths in this section are relative to

the root of your checkout; resolve them there when you start elsewhere.

Triggers

(apps/missionary) or the donor portal (apps/donor) is evaluating or

building a control where UI SDK may be the better implementation. It is the

natural choice for what only it ships (a mixed text-and-token input, a custom

composite such as a stepper), and it may be chosen over a Base UI equivalent

for a concrete benefit. A star rating, page shortcuts and list reordering

already have shared owners, listed below: reuse them.

composition, which uses existing @asym/ui components. The upstream "Don't

hand-roll what we ship" rule does not require replacing existing shared

components such as Select, Combobox, Dialog, Menu, Tabs, Calendar, Command

or Sonner.

Workflow

  1. Reuse first, then choose. Search packages/ui/components/shadcn and

packages/ui/components/primitives, and improve the existing component

when it serves. Choose UI SDK for a concrete benefit (interaction,

accessibility, simpler or more maintainable code, demonstrated performance)

and say so in the change description; no decision document is needed. An

existing Base UI equivalent does not rule it out, and SDK availability alone

is no reason to replace a working component. One library owns a control's

internals: do not mix Base UI and UI SDK parts in one control. When the SDK

version supersedes a shared component, migrate its consumers and remove the

old one.

  1. Read the installed docs. Bun's isolated linker installs the SDK for

packages/ui only, so the upstream node_modules/@ui-sdk/... paths are

packages/ui/node_modules/@ui-sdk/... in this repo:

Read it first.

package describe each part you use.

and read docs/rendering.md and docs/server-rendering.md.

exact version. The skill bundled at

packages/ui/node_modules/@ui-sdk/core/skills/ui-sdk/ must match this

copy; tests/unit/docs/ui-sdk-skill.test.ts enforces it.

  1. Wrap it in packages/ui. Put each adopted part in a Maia-styled wrapper

at packages/ui/components/primitives/<name>.tsx. The existing

./components/primitives/* export publishes it; do not add it to a barrel

or re-export the SDK. Start the file with "use client", import

per-component entries such as @ui-sdk/react/rating (there is no root

entry, and never @ui-sdk/core/internal/*), and import shared helpers

through @asym/ui/... or relative paths, not @/. Apps import the wrapper

(@asym/ui/components/primitives/<name>) and never declare or import

@ui-sdk/*. A behavior-only wrapper, such as a shortcut hook, lives there

too, so it gets the same narrow export.

  1. Style with Maia tokens. Target the SDK's data-slot and state

attributes (data-filled, data-checked, data-open and so on) with

Tailwind data variants and semantic tokens such as text-muted-foreground

and ring-ring/50. Do not import the optional @ui-sdk/core/web.css or

use the CDN web.js page setup, and add no --ui-* theme, raw colors or

inline styles. @layer ui-sdk; already opens

packages/ui/styles/globals.css and appears in

apps/admin/app/css-layer-order.css; keep both. On touch screens Core's

base layer gives buttons a 44px minimum height, so size the part that holds

an SDK button to match (the Rating star uses pointer-coarse:size-11).

  1. Name every control. Core's Base UI Field and FieldLabel do not name

UI SDK parts. Pass aria-label or aria-labelledby; the reference

wrapper's types require one.

  1. Keep boundaries. SDK component entries already carry "use client"; a

wrapper with state, callbacks or render functions needs its own. Ordinary

use needs no provider, Preferences or CSP change. Core has one agent

bridge owner (below): never call createAgent or registerTools anywhere

else; mount no other bridge unless the user asks for agent integration.

Base UI and native controls are operated through their accessible names,

roles and states, not the bridge. "Make it agent-ready" above applies to

every SDK-backed control: name it, keep its checks in change callbacks, and

put data-agent-confirm on anything that deletes, pays or sends. The SDK's

layer stack (modal pausing, dismissal order) only knows SDK popups; the

shared shortcut owner already guards Base UI overlays, so guard

outside-press behavior yourself when a Base UI dialog or menu can be open.

An SDK control may sit inside a Base UI dialog, popover or form, and the

reverse. Test focus order and return, accessible names, Escape and

outside-press dismissal, and overlay stacking across that boundary.

  1. Test first. Follow docs/ai/skills/tdd/SKILL.md. Write a jsdom test

under tests/unit/packages/ui/components/primitives/ (names, one tab stop,

keys, values, server render plus hydration). For layout, focus movement,

touch or popups, add a real-browser spec like

tests/e2e/ui-sdk-rating.spec.ts (server HTML, hydration, keyboard, token

colors, touch targets, axe). Register it in two allowlists, the testMatch

list in tests/e2e/playwright-isolated.config.ts and the

test:e2e:production-gate script in the root package.json, or CI never

runs it. Tests outside packages/ui cannot import @ui-sdk/* by bare

specifier, so test through the wrapper; if you need

@ui-sdk/core/testing, add an exact-file alias in vitest.config.mts

beside its existing packages/ui/node_modules pins. Use Core's installed

Vitest and Playwright, not the upstream install commands. Never mark a

failing test test.fails or it.fails to keep a suite green: fix the bug,

or report it as a blocker.

  1. Verify with Core commands. Run

bunx turbo run typecheck --filter=@asym/ui plus each consuming app,

bun run lint, focused bunx vitest run <files>, and

node node_modules/@playwright/test/cli.js test --config=tests/e2e/playwright-isolated.config.ts <spec>.

Do not use npx tsc or install packages as part of UI work. Editing

packages/ui/styles/globals.css, packages/ui/AGENTS.md or

docs/ai/rules/frontend.md stales hash-bound review proofs in

tooling/shadcn/upstream-review-baseline.json; rebind them after review as

bun run verify:shadcn-diff reports.

  1. Upgrade deliberately. UI SDK is beta. Never bump it as a side effect. A

bump moves both exact pins together, rereads that release's docs, reruns

the wrapper tests and refreshes this skill from the same release.

Core's shared UI SDK owners, all in packages/ui/components/primitives/:

always with a description), its hint and aria-keyshortcuts

(useShortcutHint, ShortcutHint), and the list behind the help

(listShortcuts). It decides typing, open Base UI overlays, regions, held

keys and hydration-safe hints. Never add a keydown listener for a

shortcut.

that work where focus is, also from inside a dialog or sheet, mounted once

per app shell (a second host stays inert).

pick-up, announcements and an agent move action.

renders SDK-backed controls (Mission Control's shell and its Web Studio

layout today) with a deny-by-default allowlist pinned to each list's label.

It sees only SDK-backed controls; never mirror a Base UI or native control

into it.

and tests/e2e/ui-sdk-pattern-conformance.spec.ts runs checkPattern

over Core's retained Base UI wrappers in Chromium, recording each accepted

deviation and its reason. Give a new shared interactive wrapper a check

there.

The reference implementation is

packages/ui/components/primitives/rating.tsx, with its unit test

tests/unit/packages/ui/components/primitives/rating.test.tsx and its browser

proof tests/e2e/ui-sdk-rating.spec.ts (fixture

tests/e2e/fixtures/ui-sdk-rating.tsx).

Checklist

and the change description says why UI SDK was chosen

per-component SDK entries; apps import only the wrapper

web.css, raw colors, inline styles or new theme

targets and axe were checked, in a real browser spec that CI runs when

the change affects layout, focus movement, touch or popups

and update references/upstream.md

before running bun run skills:sync and the non-mutating

bun run skills:verify

<!-- CORE-OVERLAY-END -->

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.