--- name: ui-sdk-write-code description: Writes and edits ui-sdk code (core, the React, Vue, Svelte, Solid, web component and Angular adapters, examples, specs and scripts) the way an expert in that framework would, then checks it with the linters, the framework expert's checklist and a cold read. Use whenever you write or change code in this repo, before you call the change done. metadata: internal: true --- # Write ui-sdk code The bar: an expert in the framework reads the file and says "this is how I'd write it", and anyone else reads it top to bottom without stopping. Readable first, then fast, never clever. ## 1. Find the twin Every piece of code here has a twin that already does it well. Open it before you write a line, and copy its shape, names and order. | You're writing | Start from | | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | | A core component | `packages/core/src/components/tabs/tabs.ts`, or `menu/` once it passes about 400 lines (`menu.ts`, `menu-api.ts`, `menu-parts.ts`) | | A popup | `packages/core/src/components/popover/popover.ts` and its adapters, on `createPopup` in `foundation/popups/` | | A React, Vue or Solid part | The same component's file in `packages//src/`, on `createParts` | | A Svelte part | `packages/svelte/src/tabs/` | | A web component | `packages/web/src/tabs.ts`, on `createParts` | | An Angular part | `packages/angular/src/tabs.ts`, on `usePrimitive` and `usePart` | | An example | The same example in another framework: `examples/components///` | | A spec | `tests/specs/tabs*.spec.ts` | If two twins disagree, the shape is wrong in one of them. Say so instead of picking one. Copy a twin's shape, not its comments. Older files carry more comments than the rules below allow. ## 2. Load the framework Read the expert's knowledge file for every framework you touch: `.agents/experts//knowledge.md`, part 1 and "Common mistakes to flag", and its `decisions.md`. It's pinned to the versions this repo installs, so trust it over memory. Write in the current idiom of that version: - **React 19**: pure render, no `forwardRef`, `ref` as a prop, no effect where an event handler or a derived value belongs, code the React Compiler compiles without a bailout. - **Vue 3.5**: `