UI Bundle UI
Resolve the Bundle Directory
MUST run scripts/resolve-ui-bundle.sh [project-root] before applying any rule below or writing any file — an ad-hoc find/ls is not a substitute; it does not enforce the exit-code gate below. It reads sfdx-project.json's packageDirectories[0].path (does not assume force-app — the source path is configurable) and looks under <sourceDir>/main/default/uiBundles/:
- Exit 0, bundle path printed to stdout: exactly one bundle directory found — that is the bundle directory. Use that exact directory name; never substitute a different name (e.g. a generic "AcmePortal" example from a prompt template) for the one actually printed.
- Exit 2, candidates printed to stderr: multiple
uiBundles/* subdirectories exist — do not guess, and do not write to any of them, or to a bundle name not in the printed list. Ask the user which app/bundle they mean before editing or running any command.
- Exit 1:
sfdx-project.json missing/invalid, or no bundle directory found at all.
Run all npm/lint/build/dev commands from inside the resolved bundle directory, never from the project root.
Preconditions
Before applying any rule below, confirm this is an existing, scaffolded UI bundle: MUST run scripts/check-preconditions.sh <bundle-dir> with the directory resolve-ui-bundle.sh printed.
- Single-bundle (exit 0) case: run it once, on that bundle.
- Multi-bundle (exit 2) case: do not run it yet — first ask the user which app/bundle they mean, per the Resolve step above. Once the user names the bundle, run
check-preconditions.sh on that one bundle only. Never run it against multiple candidates speculatively before the user has chosen — that means touching/inspecting bundles the user didn't ask about.
- Exit 0: the bundle has
src/appLayout.tsx, src/routes.tsx, and src/components/ui/ — proceed.
- Exit 1, missing pieces listed: this is a fresh SFDX project, a non-UI-bundle React project, or a partially-scaffolded bundle — stop. Do not fall back to generic React knowledge (e.g.
react-router-dom, a hardcoded basename, or raw HTML), and do not hand-write appLayout.tsx/routes.tsx/a page/a component to "fill in" the missing scaffold, even for a casual, vague, or urgent-sounding request ("just change the header", "make the background blue"). Tell the user the bundle isn't scaffolded yet and direct them to experience-ui-bundle-app-coordinate (or experience-ui-bundle-metadata-generate) to scaffold it first. If, after the user names their intended bundle, that one turns out to be unscaffolded, stop and redirect for it — do not silently switch to scaffolding a different candidate instead.
Never invent, assume, or fall back to a bundle name that doesn't appear in the actual <sourceDir>/main/default/uiBundles/ listing on disk — including a name that only appears as example/template text elsewhere (a prompt, a directive, prior conversation). If what's on disk doesn't match that example, disk wins.
Identify the Task
Determine which category the request falls into:
| Category |
Examples |
Implementation Guide |
| Page |
New routed page (contacts, dashboard, settings) |
references/page.md |
| Header / Footer |
Site-wide nav bar, footer, branding, renaming the app |
references/header-footer.md |
| Component |
Widget, card, table, form, dialog |
references/component.md |
A request to rename/rebrand the app (e.g. "call it X everywhere a user would see it") is a Header / Footer task even though it doesn't mention "header" by name — it always touches at least two files: src/appLayout.tsx (header/nav brand text) AND index.html's <title> (browser tab title). Treat these as one atomic change; a rename that only updates one of the two is incomplete.
Pre-built Features (Check Before Hand-Building)
Some capabilities ship as pre-built, tested feature packages. The catalog evolves and is not something you can know from memory — never decide from the request wording alone whether a capability "is" or "isn't" a feature. Before hand-writing any non-trivial capability (anything beyond a plain page, component, or styling change) in this skill:
- Consult the authoritative catalog. Invoke
experience-ui-bundle-features-generate, which runs list to show the current set of installable features. Do not rely on a hardcoded or remembered list — this skill deliberately names none, because any names it listed would go stale.
- Detect whether a matching feature is already installed in the bundle — inspect
package.json dependencies and existing src/ files. If present, use it as-is; do not reinstall or re-implement.
- If a matching feature exists in the catalog but isn't installed, let
experience-ui-bundle-features-generate install the tested package. Do not build it from scratch here.
- Only hand-build a capability that has no matching catalog feature.
This gate is idempotent: when this skill runs as a phase of experience-ui-bundle-app-coordinate (which installs features earlier in its sequence), step 2 finds the feature already present and this collapses to a no-op. It only does real work when the skill was reached directly — the path that would otherwise skip feature detection.
Layout and Navigation
appLayout.tsx is the source of truth for navigation and layout. Every page shares this shell.
When making any change that affects navigation, header, footer, sidebar, theme, or layout:
- Edit
src/appLayout.tsx — the layout used by routes.tsx
- Replace all default/template nav items and labels with app-specific links and names
- Replace placeholder app name everywhere: header, nav brand, footer,
<title> in index.html
index.html lives at the bundle root (not under src/), but it is still in scope for this skill whenever branding or the app name changes — the leftover <title>React App</title> / Vite + React boilerplate is a common ship-blocker that npm run lint/npm run build never catches.
Before finishing, confirm: Did I update appLayout.tsx with real nav items and branding? Then run scripts/verify-rules.sh to check for residual boilerplate (see Verification below).
| What |
Where |
| Layout, nav, branding |
src/appLayout.tsx |
| Document title |
index.html (bundle root, outside src/ — still in scope for branding) |
| Root page content |
Component at root route in routes.tsx |
React and TypeScript Standards
Routing
Use a single router package. With createBrowserRouter / RouterProvider, all imports must come from react-router (not react-router-dom).
If the app uses a client-side router (React Router, Remix Router, Vue Router, etc.), always derive basename / basepath / base from the document's <base href> tag at runtime. Never hardcode the basename:
const basename = document.querySelector('base')
? new URL(document.querySelector('base').href).pathname.replace(/\/$/, '')
: '/';
const router = createBrowserRouter(routes, { basename });
Component Library and Styling
- shadcn/ui for components:
import { Button } from '@/components/ui/button';
- Tailwind CSS utility classes
URL and Path Handling
Apps run behind dynamic base paths. Router navigation (<Link to>, navigate()) uses absolute paths (/x). Non-router attributes (<img src>) use dot-relative (./x). Prefer Vite import for static assets.
TypeScript
- Never use
any — use proper types, generics, or unknown with type guards
- Event handlers:
(event: React.FormEvent<HTMLFormElement>): void
- State:
useState<User | null>(null) — always provide the type parameter
- No unsafe assertions (
obj as User) — use type guards instead
Module Restrictions
React UI bundles must not import Salesforce platform modules like lightning/* or @wire (LWC-only). Before writing any data-access code (GraphQL, REST, SDK initialization, or a hook that fetches data), you MUST invoke the experience-ui-bundle-salesforce-data-access skill first. Do not write fetch/axios calls or invent a different data API inline in this skill — this applies even if the clarifying-question answer only implies data fetching in passing.
Design Thinking
The rules in this section and "Frontend Aesthetics" below are creative direction, not hard constraints — they cannot be lint- or build-checked and are judged by review, not automation. Two hard, checkable exceptions: never default to Inter/Roboto/Arial/Space Grotesk/system fonts, and mobile responsiveness (Tailwind breakpoints, 44px touch targets) is a MUST, not a style preference.
Before coding, commit to a bold aesthetic direction:
- Purpose: What problem does this interface solve? Who uses it?
- Tone: Pick a clear direction — brutally minimal, maximalist, retro-futuristic, organic, luxury, playful, editorial, brutalist, art deco, soft/pastel, industrial. Use these as inspiration but design one true to the context.
- Differentiation: What makes this unforgettable? What's the one thing someone will remember?
Choose a clear conceptual direction and execute it with precision. Bold maximalism and refined minimalism both work — the key is intentionality, not intensity.
Frontend Aesthetics
Typography: Choose distinctive, characterful fonts. Pair a display font with a refined body font. Never default to Inter, Roboto, Arial, Space Grotesk, or system fonts.
Color: Commit to a cohesive palette using CSS variables. Dominant colors with sharp accents outperform timid, evenly-distributed palettes. Avoid cliched purple gradients on white.
Motion: Focus on high-impact moments — one well-orchestrated page load with staggered reveals (animation-delay) creates more delight than scattered micro-interactions. Use scroll-triggering and hover states that surprise. Prefer CSS-only solutions; use Motion library for React when available.
Spatial Composition: Unexpected layouts — asymmetry, overlap, diagonal flow, grid-breaking elements. Generous negative space OR controlled density.
Backgrounds & Depth: Create atmosphere rather than defaulting to solid colors. Gradient meshes, noise textures, geometric patterns, layered transparencies, dramatic shadows, decorative borders, grain overlays.
Mobile Responsiveness: All generated UI MUST be mobile-responsive. Use Tailwind responsive prefixes (sm:, md:, lg:) to adapt layouts across breakpoints. Stack columns on small screens, use flexible grids, and ensure touch targets are at least 44px. Test that navigation, typography, and spacing work on mobile viewports.
Match implementation complexity to the aesthetic vision. Maximalist designs need elaborate animations and effects. Minimalist designs need restraint, precision, and careful spacing/typography. No two designs should look the same — vary themes, fonts, and aesthetics across generations.
Clarifying Questions
Ask one question at a time and stop when you have enough context.
For a Page
- Name and purpose?
- URL path?
- Should it appear in navigation?
- Access control? (public, authenticated via
PrivateRoute, or unauthenticated via AuthenticationRoute)
- Content sections? (list, form, table, detail view)
- Data fetching needs?
For a Header / Footer
- Header, footer, or both?
- Contents? (logo, nav links, user avatar, copyright, social icons)
- Sticky header?
- Color scheme or style direction?
For a Component
- What should it do?
- Which page does it belong to?
- Shared/reusable or specific to one feature?
- Data or props needed?
- Internal state? (loading, toggle, form state)
- Specific shadcn components to use?
Verification
Before completing, run all of the following from the resolved UI bundle directory (see "Resolve the Bundle Directory" above):
npm run lint — must result in 0 errors.
npm run build — must succeed.
npm run dev (or the project's dev-server script) — confirm the app starts cleanly so the change is verified at runtime, not just at build time.
lint/build alone do not catch the highest-risk rules in this skill — a wrong react-router-dom import, a hardcoded basename, an inline style={{}}, or a stray lightning/* import can all lint and build clean while breaking at runtime. After any change that touches routing, layout, styling, or module imports, run scripts/verify-rules.sh <files-or-dirs-you-edited>:
- Exit 0: no violations found.
- Exit 1, violations listed by rule and file: fix every one before considering the task complete, even if lint and build passed.
1---2name: experience-ui-bundle-frontend-generate3description: MUST activate before editing ANY file under uiBundles/*/src/ (or the bundle's index.html) for visual or UI changes to an EXISTING app — pages, components, sections, layout, styling, colors, fonts, navigation, animations, branding, or any look-and-feel change. Use this skill when modifying pages, components, layout, styling, navigation, or branding in an existing UI bundle app. Activate when the project contains appLayout.tsx, routes.tsx, src/pages/, src/components/, src/styles/global.css, or the bundle's index.html. This skill contains critical project-specific conventions (appLayout.tsx shell, shadcn/ui components, Tailwind CSS, Salesforce base-path routing, module restrictions) that override general knowledge. Without this skill, generated code will use wrong imports, break routing, or ignore project structure. Do NOT use when creating a new app from scratch or the bundle has not been scaffolded yet (use experience-ui-bundle-app-coordinate instead).4---5
6# UI Bundle UI
7
8## Resolve the Bundle Directory
9
10**MUST** run `scripts/resolve-ui-bundle.sh [project-root]` before applying any rule below or writing any file — an ad-hoc `find`/`ls` is not a substitute; it does not enforce the exit-code gate below. It reads `sfdx-project.json`'s `packageDirectories[0].path` (does not assume `force-app` — the source path is configurable) and looks under `<sourceDir>/main/default/uiBundles/`:
11
12- **Exit 0**, bundle path printed to stdout: exactly one bundle directory found — that is the bundle directory. Use that exact directory name; never substitute a different name (e.g. a generic "AcmePortal" example from a prompt template) for the one actually printed.
13- **Exit 2**, candidates printed to stderr: multiple `uiBundles/*` subdirectories exist — do not guess, and do not write to any of them, or to a bundle name not in the printed list. Ask the user which app/bundle they mean before editing or running any command.
14- **Exit 1**: `sfdx-project.json` missing/invalid, or no bundle directory found at all.
15
16Run all `npm`/lint/build/dev commands from inside the resolved bundle directory, never from the project root.
17
18## Preconditions
19
20Before applying any rule below, confirm this is an existing, scaffolded UI bundle: **MUST** run `scripts/check-preconditions.sh <bundle-dir>` with the directory `resolve-ui-bundle.sh` printed.
21
22- **Single-bundle (exit 0) case**: run it once, on that bundle.
23- **Multi-bundle (exit 2) case**: do not run it yet — first ask the user which app/bundle they mean, per the Resolve step above. Once the user names the bundle, run `check-preconditions.sh` on that one bundle only. Never run it against multiple candidates speculatively before the user has chosen — that means touching/inspecting bundles the user didn't ask about.
24- **Exit 0**: the bundle has `src/appLayout.tsx`, `src/routes.tsx`, and `src/components/ui/` — proceed.
25- **Exit 1**, missing pieces listed: this is a fresh SFDX project, a non-UI-bundle React project, or a partially-scaffolded bundle — **stop**. Do not fall back to generic React knowledge (e.g. `react-router-dom`, a hardcoded basename, or raw HTML), and do not hand-write `appLayout.tsx`/`routes.tsx`/a page/a component to "fill in" the missing scaffold, even for a casual, vague, or urgent-sounding request ("just change the header", "make the background blue"). Tell the user the bundle isn't scaffolded yet and direct them to `experience-ui-bundle-app-coordinate` (or `experience-ui-bundle-metadata-generate`) to scaffold it first. If, after the user names their intended bundle, that one turns out to be unscaffolded, stop and redirect for it — do not silently switch to scaffolding a different candidate instead.
26
27Never invent, assume, or fall back to a bundle name that doesn't appear in the actual `<sourceDir>/main/default/uiBundles/` listing on disk — including a name that only appears as example/template text elsewhere (a prompt, a directive, prior conversation). If what's on disk doesn't match that example, disk wins.
28
29## Identify the Task
30
31Determine which category the request falls into:
32
33| Category | Examples | Implementation Guide |
34|----------|----------|---------------------|
35| **Page** | New routed page (contacts, dashboard, settings) | `references/page.md` |
36| **Header / Footer** | Site-wide nav bar, footer, branding, renaming the app | `references/header-footer.md` |
37| **Component** | Widget, card, table, form, dialog | `references/component.md` |
38
39A request to rename/rebrand the app (e.g. "call it X everywhere a user would see it") is a **Header / Footer** task even though it doesn't mention "header" by name — it always touches at least two files: `src/appLayout.tsx` (header/nav brand text) AND `index.html`'s `<title>` (browser tab title). Treat these as one atomic change; a rename that only updates one of the two is incomplete.
40
41---
42
43## Pre-built Features (Check Before Hand-Building)
44
45Some capabilities ship as pre-built, tested feature packages. The catalog **evolves and is not something you can know from memory** — never decide from the request wording alone whether a capability "is" or "isn't" a feature. Before hand-writing any non-trivial capability (anything beyond a plain page, component, or styling change) in this skill:
46
471. **Consult the authoritative catalog.** Invoke `experience-ui-bundle-features-generate`, which runs `list` to show the *current* set of installable features. Do not rely on a hardcoded or remembered list — this skill deliberately names none, because any names it listed would go stale.
482. **Detect whether a matching feature is already installed** in the bundle — inspect `package.json` dependencies and existing `src/` files. If present, use it as-is; do not reinstall or re-implement.
493. **If a matching feature exists in the catalog but isn't installed**, let `experience-ui-bundle-features-generate` install the tested package. Do not build it from scratch here.
504. **Only hand-build** a capability that has no matching catalog feature.
51
52This gate is **idempotent**: when this skill runs as a phase of `experience-ui-bundle-app-coordinate` (which installs features earlier in its sequence), step 2 finds the feature already present and this collapses to a no-op. It only does real work when the skill was reached directly — the path that would otherwise skip feature detection.
53
54---
55
56## Layout and Navigation
57
58`appLayout.tsx` is the source of truth for navigation and layout. Every page shares this shell.
59
60When making any change that affects navigation, header, footer, sidebar, theme, or layout:
61
621. Edit `src/appLayout.tsx` — the layout used by `routes.tsx`
632. Replace all default/template nav items and labels with app-specific links and names
643. Replace placeholder app name everywhere: header, nav brand, footer, `<title>` in `index.html`
65
66`index.html` lives at the bundle root (not under `src/`), but it is still in scope for this skill whenever branding or the app name changes — the leftover `<title>React App</title>` / `Vite + React` boilerplate is a common ship-blocker that `npm run lint`/`npm run build` never catches.
67
68Before finishing, confirm: Did I update `appLayout.tsx` with real nav items and branding? Then run `scripts/verify-rules.sh` to check for residual boilerplate (see Verification below).
69
70| What | Where |
71|------|-------|
72| Layout, nav, branding | `src/appLayout.tsx` |
73| Document title | `index.html` (bundle root, outside `src/` — still in scope for branding) |
74| Root page content | Component at root route in `routes.tsx` |
75
76---
77
78## React and TypeScript Standards
79
80### Routing
81
82Use a single router package. With `createBrowserRouter` / `RouterProvider`, all imports must come from `react-router` (not `react-router-dom`).
83
84If the app uses a client-side router (React Router, Remix Router, Vue Router, etc.), always derive basename / basepath / base from the document's `<base href>` tag at runtime. Never hardcode the basename:
85
86```js
87const basename = document.querySelector('base')
88 ? new URL(document.querySelector('base').href).pathname.replace(/\/$/, '')
89 : '/';
90const router = createBrowserRouter(routes, { basename });
91```
92
93### Component Library and Styling
94
95- **shadcn/ui** for components: `import { Button } from '@/components/ui/button';`
96- **Tailwind CSS** utility classes
97
98### URL and Path Handling
99
100Apps run behind dynamic base paths. Router navigation (`<Link to>`, `navigate()`) uses absolute paths (`/x`). Non-router attributes (`<img src>`) use dot-relative (`./x`). Prefer Vite `import` for static assets.
101
102### TypeScript
103
104- Never use `any` — use proper types, generics, or `unknown` with type guards
105- Event handlers: `(event: React.FormEvent<HTMLFormElement>): void`
106- State: `useState<User | null>(null)` — always provide the type parameter
107- No unsafe assertions (`obj as User`) — use type guards instead
108
109### Module Restrictions
110
111React UI bundles must not import Salesforce platform modules like `lightning/*` or `@wire` (LWC-only). **Before writing any data-access code (GraphQL, REST, SDK initialization, or a hook that fetches data), you MUST invoke the `experience-ui-bundle-salesforce-data-access` skill first.** Do not write `fetch`/`axios` calls or invent a different data API inline in this skill — this applies even if the clarifying-question answer only implies data fetching in passing.
112
113---
114
115## Design Thinking
116
117The rules in this section and "Frontend Aesthetics" below are creative direction, not hard constraints — they cannot be lint- or build-checked and are judged by review, not automation. Two hard, checkable exceptions: never default to Inter/Roboto/Arial/Space Grotesk/system fonts, and mobile responsiveness (Tailwind breakpoints, 44px touch targets) is a MUST, not a style preference.
118
119Before coding, commit to a bold aesthetic direction:
120
121- **Purpose:** What problem does this interface solve? Who uses it?
122- **Tone:** Pick a clear direction — brutally minimal, maximalist, retro-futuristic, organic, luxury, playful, editorial, brutalist, art deco, soft/pastel, industrial. Use these as inspiration but design one true to the context.
123- **Differentiation:** What makes this unforgettable? What's the one thing someone will remember?
124
125Choose a clear conceptual direction and execute it with precision. Bold maximalism and refined minimalism both work — the key is intentionality, not intensity.
126
127---
128
129## Frontend Aesthetics
130
131- **Typography:** Choose distinctive, characterful fonts. Pair a display font with a refined body font. Never default to Inter, Roboto, Arial, Space Grotesk, or system fonts.
132- **Color:** Commit to a cohesive palette using CSS variables. Dominant colors with sharp accents outperform timid, evenly-distributed palettes. Avoid cliched purple gradients on white.
133- **Motion:** Focus on high-impact moments — one well-orchestrated page load with staggered reveals (`animation-delay`) creates more delight than scattered micro-interactions. Use scroll-triggering and hover states that surprise. Prefer CSS-only solutions; use Motion library for React when available.
134- **Spatial Composition:** Unexpected layouts — asymmetry, overlap, diagonal flow, grid-breaking elements. Generous negative space OR controlled density.
135- **Backgrounds & Depth:** Create atmosphere rather than defaulting to solid colors. Gradient meshes, noise textures, geometric patterns, layered transparencies, dramatic shadows, decorative borders, grain overlays.
136
137- **Mobile Responsiveness:** All generated UI MUST be mobile-responsive. Use Tailwind responsive prefixes (`sm:`, `md:`, `lg:`) to adapt layouts across breakpoints. Stack columns on small screens, use flexible grids, and ensure touch targets are at least 44px. Test that navigation, typography, and spacing work on mobile viewports.
138
139Match implementation complexity to the aesthetic vision. Maximalist designs need elaborate animations and effects. Minimalist designs need restraint, precision, and careful spacing/typography. No two designs should look the same — vary themes, fonts, and aesthetics across generations.
140
141---
142
143## Clarifying Questions
144
145Ask one question at a time and stop when you have enough context.
146
147### For a Page
1481. Name and purpose?
1492. URL path?
1503. Should it appear in navigation?
1514. Access control? (public, authenticated via `PrivateRoute`, or unauthenticated via `AuthenticationRoute`)
1525. Content sections? (list, form, table, detail view)
1536. Data fetching needs?
154
155### For a Header / Footer
1561. Header, footer, or both?
1572. Contents? (logo, nav links, user avatar, copyright, social icons)
1583. Sticky header?
1594. Color scheme or style direction?
160
161### For a Component
1621. What should it do?
1632. Which page does it belong to?
1643. Shared/reusable or specific to one feature?
1654. Data or props needed?
1665. Internal state? (loading, toggle, form state)
1676. Specific shadcn components to use?
168
169---
170
171## Verification
172
173Before completing, run all of the following from the resolved UI bundle directory (see "Resolve the Bundle Directory" above):
174
1751. `npm run lint` — must result in 0 errors.
1762. `npm run build` — must succeed.
1773. `npm run dev` (or the project's dev-server script) — confirm the app starts cleanly so the change is verified at runtime, not just at build time.
178
179**`lint`/`build` alone do not catch the highest-risk rules in this skill** — a wrong `react-router-dom` import, a hardcoded basename, an inline `style={{}}`, or a stray `lightning/*` import can all lint and build clean while breaking at runtime. After any change that touches routing, layout, styling, or module imports, run `scripts/verify-rules.sh <files-or-dirs-you-edited>`:
180
181- **Exit 0**: no violations found.
182- **Exit 1**, violations listed by rule and file: fix every one before considering the task complete, even if lint and build passed.