diff --git a/.changeset/agents-md-rac-convention-guidance.md b/.changeset/agents-md-rac-convention-guidance.md new file mode 100644 index 000000000..ef1379d61 --- /dev/null +++ b/.changeset/agents-md-rac-convention-guidance.md @@ -0,0 +1,4 @@ +--- +--- + +docs: strengthen RAC convention guidance in AGENTS.md — direct agents to follow React Aria/React Spectrum API conventions (not only behavior) and to consult React Aria first when exploring new problems. No package changes. diff --git a/AGENTS.md b/AGENTS.md index 64e072124..dbfdae60f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -56,7 +56,9 @@ A package's typical shape: `src/` (one `.tsx` per component, plus `index.ts` bar Follow these when writing or changing component code: - **Use existing LaunchPad components and packages** (`@launchpad-ui/components`, `@launchpad-ui/icons`, etc.). Never create a custom component when a LaunchPad equivalent exists. -- **React Aria Components is the foundation.** Wrap and theme RAC primitives; do not reimplement keyboard/ARIA/focus behavior. The sanctioned escape hatches are `defaultProps`, slots, `useContextProps`, and render-props composition — see https://react-aria.adobe.com/customization. (`docs/adr-008-component-foundation.md`) +- **React Aria Components is the foundation.** Wrap and theme RAC primitives; do not reimplement keyboard/ARIA/focus behavior. The sanctioned escape hatches are `defaultProps`, slots, `useContextProps`, and render-props composition — see https://react-aria.adobe.com/customization. **Follow RAC's API conventions, not only its behavior:** when adding a prop, variant, or composition pattern, mirror the names and shapes RAC — and its reference implementation, [React Spectrum](https://react-spectrum.adobe.com) — already use (e.g. `description`/`errorMessage` for helper and validation text, `isDisabled`/`isInvalid` booleans, slot-based composition) rather than inventing new ones. Deviate only with a reason noted in the PR. (`docs/adr-008-component-foundation.md`) +- **Consult React Aria when exploring a new problem.** Before designing a new component, prop, or interaction, check how RAC and React Spectrum model the same thing and follow their lead. Their docs are the default starting reference, not a fallback — reaching for a blank-slate or external design when RAC already has a sanctioned pattern is the most common source of API drift (including drift from the Figma library, which mirrors these conventions). +- **Fetch those docs as Markdown.** When retrieving React Aria / React Spectrum docs programmatically, use the Markdown version: append `.md` to the page URL (e.g. `react-aria.adobe.com/customization.md`), or replace a trailing `.html` with `.md`. It's far more token-efficient than the rendered HTML page. - **Named exports only.** `export default` is reserved for stories and config files (Biome-enforced). - **Named imports** following `import { Button, Alert } from '@launchpad-ui/components'` and `import { Icon } from '@launchpad-ui/icons'`. - **String union prop types, never enums** (`size="medium"`, not `Size.Medium`). (`docs/adr-002-string-unions-for-prop-types.md`)