agents-config 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/AGENTS.md +490 -0
  2. package/LICENSE +21 -0
  3. package/README.md +254 -0
  4. package/adapters/claude.template.md +77 -0
  5. package/adapters/codex.template.md +72 -0
  6. package/adapters/copilot.template.md +68 -0
  7. package/adapters/cursor.template.md +69 -0
  8. package/adapters/gemini.template.md +73 -0
  9. package/adapters/windsurf.template.md +81 -0
  10. package/bin/agents-init.js +699 -0
  11. package/bin/postinstall.js +28 -0
  12. package/instructions/development-standards.instructions.md +47 -0
  13. package/instructions/github-issue.instructions.md +324 -0
  14. package/instructions/github-release-notes.instructions.md +888 -0
  15. package/instructions/mui.instructions.md +50 -0
  16. package/instructions/storybook.instructions.md +55 -0
  17. package/instructions/web-interface-guidelines.instructions.md +331 -0
  18. package/package.json +56 -0
  19. package/prompts/create-pr.prompt.md +78 -0
  20. package/prompts/scaffold-component.prompt.md +57 -0
  21. package/rules/accessibility.md +36 -0
  22. package/rules/component-architecture.md +34 -0
  23. package/rules/gemini.md +547 -0
  24. package/rules/mui.md +491 -0
  25. package/rules/react-19-compiler.md +26 -0
  26. package/rules/spec-driven-development.md +36 -0
  27. package/rules/supabase.md +40 -0
  28. package/rules/tailwind-v4.md +29 -0
  29. package/rules/three-js-react.md +76 -0
  30. package/rules/web-performance.md +29 -0
  31. package/schemas/agents-project.schema.json +78 -0
  32. package/skills/accessibility-audit/SKILL.md +39 -0
  33. package/skills/integrate-gemini/SKILL.md +124 -0
  34. package/skills/scaffold-component/SKILL.md +77 -0
  35. package/skills/vercel-react-best-practices/AGENTS.md +2719 -0
  36. package/skills/vercel-react-best-practices/SKILL.md +125 -0
  37. package/skills/vercel-react-best-practices/rules/advanced-event-handler-refs.md +55 -0
  38. package/skills/vercel-react-best-practices/rules/advanced-use-latest.md +39 -0
  39. package/skills/vercel-react-best-practices/rules/async-api-routes.md +38 -0
  40. package/skills/vercel-react-best-practices/rules/async-defer-await.md +80 -0
  41. package/skills/vercel-react-best-practices/rules/async-dependencies.md +51 -0
  42. package/skills/vercel-react-best-practices/rules/async-parallel.md +28 -0
  43. package/skills/vercel-react-best-practices/rules/async-suspense-boundaries.md +99 -0
  44. package/skills/vercel-react-best-practices/rules/bundle-barrel-imports.md +59 -0
  45. package/skills/vercel-react-best-practices/rules/bundle-conditional.md +31 -0
  46. package/skills/vercel-react-best-practices/rules/bundle-defer-third-party.md +49 -0
  47. package/skills/vercel-react-best-practices/rules/bundle-dynamic-imports.md +35 -0
  48. package/skills/vercel-react-best-practices/rules/bundle-preload.md +50 -0
  49. package/skills/vercel-react-best-practices/rules/client-event-listeners.md +74 -0
  50. package/skills/vercel-react-best-practices/rules/client-localstorage-schema.md +71 -0
  51. package/skills/vercel-react-best-practices/rules/client-passive-event-listeners.md +48 -0
  52. package/skills/vercel-react-best-practices/rules/client-swr-dedup.md +56 -0
  53. package/skills/vercel-react-best-practices/rules/js-batch-dom-css.md +107 -0
  54. package/skills/vercel-react-best-practices/rules/js-cache-function-results.md +80 -0
  55. package/skills/vercel-react-best-practices/rules/js-cache-property-access.md +28 -0
  56. package/skills/vercel-react-best-practices/rules/js-cache-storage.md +70 -0
  57. package/skills/vercel-react-best-practices/rules/js-combine-iterations.md +32 -0
  58. package/skills/vercel-react-best-practices/rules/js-early-exit.md +50 -0
  59. package/skills/vercel-react-best-practices/rules/js-hoist-regexp.md +45 -0
  60. package/skills/vercel-react-best-practices/rules/js-index-maps.md +37 -0
  61. package/skills/vercel-react-best-practices/rules/js-length-check-first.md +49 -0
  62. package/skills/vercel-react-best-practices/rules/js-min-max-loop.md +82 -0
  63. package/skills/vercel-react-best-practices/rules/js-set-map-lookups.md +24 -0
  64. package/skills/vercel-react-best-practices/rules/js-tosorted-immutable.md +57 -0
  65. package/skills/vercel-react-best-practices/rules/rendering-activity.md +26 -0
  66. package/skills/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
  67. package/skills/vercel-react-best-practices/rules/rendering-conditional-render.md +40 -0
  68. package/skills/vercel-react-best-practices/rules/rendering-content-visibility.md +38 -0
  69. package/skills/vercel-react-best-practices/rules/rendering-hoist-jsx.md +46 -0
  70. package/skills/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
  71. package/skills/vercel-react-best-practices/rules/rendering-svg-precision.md +28 -0
  72. package/skills/vercel-react-best-practices/rules/rendering-usetransition-loading.md +75 -0
  73. package/skills/vercel-react-best-practices/rules/rerender-defer-reads.md +39 -0
  74. package/skills/vercel-react-best-practices/rules/rerender-dependencies.md +45 -0
  75. package/skills/vercel-react-best-practices/rules/rerender-derived-state.md +29 -0
  76. package/skills/vercel-react-best-practices/rules/rerender-functional-setstate.md +74 -0
  77. package/skills/vercel-react-best-practices/rules/rerender-lazy-state-init.md +58 -0
  78. package/skills/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
  79. package/skills/vercel-react-best-practices/rules/rerender-memo.md +44 -0
  80. package/skills/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
  81. package/skills/vercel-react-best-practices/rules/rerender-transitions.md +40 -0
  82. package/skills/vercel-react-best-practices/rules/server-after-nonblocking.md +73 -0
  83. package/skills/vercel-react-best-practices/rules/server-auth-actions.md +96 -0
  84. package/skills/vercel-react-best-practices/rules/server-cache-lru.md +41 -0
  85. package/skills/vercel-react-best-practices/rules/server-cache-react.md +76 -0
  86. package/skills/vercel-react-best-practices/rules/server-dedup-props.md +65 -0
  87. package/skills/vercel-react-best-practices/rules/server-parallel-fetching.md +83 -0
  88. package/skills/vercel-react-best-practices/rules/server-serialization.md +38 -0
  89. package/skills/workflows/sdd-workflow.md +49 -0
  90. package/skills/workflows/setup-orchestration.md +18 -0
package/rules/mui.md ADDED
@@ -0,0 +1,491 @@
1
+ # Material-UI (MUI) Architecture & Patterns
2
+
3
+ **Framework Version**: MUI v7.3+
4
+ **Purpose**: Architectural patterns, constraints, and anti-patterns for building React applications with Material-UI.
5
+
6
+ ---
7
+
8
+ ## Component Extension Philosophy
9
+
10
+ ### When to Extend vs Compose
11
+
12
+ **Extend MUI Components** when:
13
+ - Adding custom variants to existing MUI components
14
+ - Building a design system with consistent theming
15
+ - Need to preserve all MUI component APIs and behaviors
16
+ - Creating reusable, branded versions (e.g., branded Button, Card)
17
+
18
+ **Compose MUI Components** when:
19
+ - Building domain-specific components (e.g., UserCard, ProductList)
20
+ - Combining multiple MUI components into a pattern
21
+ - Need custom logic that doesn't fit MUI's API
22
+ - Creating one-off layouts or pages
23
+
24
+ ### Extension Pattern
25
+
26
+ ```tsx
27
+ // ✅ Good: Extend with TypeScript, preserve MUI props
28
+ import { Button, ButtonProps } from '@mui/material/Button';
29
+
30
+ interface BrandedButtonProps extends ButtonProps {
31
+ customVariant?: 'primary' | 'secondary' | 'danger';
32
+ }
33
+
34
+ export const BrandedButton: React.FC<BrandedButtonProps> = ({
35
+ customVariant,
36
+ ...muiProps
37
+ }) => {
38
+ return <Button {...muiProps} />;
39
+ };
40
+ ```
41
+
42
+ ```tsx
43
+ // ❌ Bad: Reimplementing MUI functionality
44
+ const BrandedButton = ({ onClick, children }) => {
45
+ return <div onClick={onClick}>{children}</div>;
46
+ };
47
+ ```
48
+
49
+ ---
50
+
51
+ ## Theme Architecture
52
+
53
+ ### Theme Provider Structure
54
+
55
+ **Rule**: Use MUI's theme provider with `cssVariables` enabled for optimal performance and SSR support.
56
+
57
+ ```tsx
58
+ // ✅ Good: CSS variables for dynamic theming
59
+ import { Experimental_CssVarsProvider as CssVarsProvider } from '@mui/material/styles';
60
+
61
+ function App() {
62
+ return (
63
+ <CssVarsProvider>
64
+ {/* Your app */}
65
+ </CssVarsProvider>
66
+ );
67
+ }
68
+ ```
69
+
70
+ ```tsx
71
+ // ❌ Bad: Traditional theme provider (no CSS variables)
72
+ import { ThemeProvider } from '@mui/material/styles';
73
+
74
+ function App() {
75
+ return (
76
+ <ThemeProvider theme={theme}>
77
+ {/* Your app */}
78
+ </ThemeProvider>
79
+ );
80
+ }
81
+ ```
82
+
83
+ ### Theme Token Hierarchy
84
+
85
+ **Rule**: Organize theme tokens in layers of specificity.
86
+
87
+ 1. **Base tokens** - Design primitives (spacing, typography scale, breakpoints)
88
+ 2. **Semantic tokens** - Purpose-based (colors.primary, colors.error)
89
+ 3. **Component tokens** - Component-specific overrides
90
+
91
+ ```tsx
92
+ // ✅ Good: Layered theme structure
93
+ const theme = createTheme({
94
+ // Base tokens
95
+ spacing: 8,
96
+ typography: {
97
+ fontFamily: '"Inter", sans-serif',
98
+ },
99
+
100
+ // Semantic tokens
101
+ palette: {
102
+ primary: {
103
+ main: '#1976d2',
104
+ },
105
+ },
106
+
107
+ // Component tokens
108
+ components: {
109
+ MuiButton: {
110
+ styleOverrides: {
111
+ root: {
112
+ borderRadius: 8,
113
+ },
114
+ },
115
+ },
116
+ },
117
+ });
118
+ ```
119
+
120
+ ### Dark Mode Implementation
121
+
122
+ **Rule**: Respect system preference, persist user choice, prevent flash.
123
+
124
+ ```tsx
125
+ // ✅ Good: Proper dark mode setup
126
+ <CssVarsProvider
127
+ defaultMode="system"
128
+ modeStorageKey="app-color-mode"
129
+ disableTransitionOnChange={false}
130
+ >
131
+ ```
132
+
133
+ **Anti-pattern**: Manual class toggling or localStorage reading in components.
134
+
135
+ ---
136
+
137
+ ## Performance Rules
138
+
139
+ ### Import Optimization
140
+
141
+ **Rule**: Use named imports for tree-shaking, avoid barrel imports.
142
+
143
+ ```tsx
144
+ // ✅ Good: Named imports
145
+ import Button from '@mui/material/Button';
146
+ import TextField from '@mui/material/TextField';
147
+ ```
148
+
149
+ ```tsx
150
+ // ❌ Bad: Barrel import (breaks tree-shaking)
151
+ import { Button, TextField } from '@mui/material';
152
+ ```
153
+
154
+ ### `sx` Prop Usage
155
+
156
+ **Rule**: Use `sx` prop for dynamic, one-off styles. Use `styled` for reusable component variants.
157
+
158
+ ```tsx
159
+ // ✅ Good: sx for dynamic styles
160
+ <Box sx={{
161
+ p: isLarge ? 3 : 2,
162
+ color: error ? 'error.main' : 'text.primary'
163
+ }} />
164
+
165
+ // ✅ Good: styled for reusable patterns
166
+ const StyledCard = styled(Card)(({ theme }) => ({
167
+ borderRadius: theme.spacing(2),
168
+ boxShadow: theme.shadows[2],
169
+ }));
170
+ ```
171
+
172
+ ```tsx
173
+ // ❌ Bad: sx for static, reusable styles
174
+ <Card sx={{ borderRadius: 2, boxShadow: 2 }} />
175
+ <Card sx={{ borderRadius: 2, boxShadow: 2 }} />
176
+ <Card sx={{ borderRadius: 2, boxShadow: 2 }} />
177
+ ```
178
+
179
+ ### Theme Caching
180
+
181
+ **Rule**: Create theme once, memoize custom theme functions.
182
+
183
+ ```tsx
184
+ // ✅ Good: Memoized theme creation
185
+ const theme = useMemo(
186
+ () => createTheme({
187
+ palette: { mode: colorMode },
188
+ }),
189
+ [colorMode]
190
+ );
191
+ ```
192
+
193
+ ```tsx
194
+ // ❌ Bad: Theme recreation on every render
195
+ function App() {
196
+ const theme = createTheme({ /* ... */ });
197
+ return <ThemeProvider theme={theme}>...</ThemeProvider>;
198
+ }
199
+ ```
200
+
201
+ ---
202
+
203
+ ## Grid System
204
+
205
+ ### Use Grid v2 Syntax
206
+
207
+ **Rule**: Always use the new Grid2 component for layouts.
208
+
209
+ ```tsx
210
+ // ✅ Good: Grid v2 with container queries
211
+ import Grid from '@mui/material/Unstable_Grid2';
212
+
213
+ <Grid container spacing={2}>
214
+ <Grid xs={12} md={6}>Column 1</Grid>
215
+ <Grid xs={12} md={6}>Column 2</Grid>
216
+ </Grid>
217
+ ```
218
+
219
+ ```tsx
220
+ // ❌ Bad: Old Grid syntax
221
+ import Grid from '@mui/material/Grid';
222
+
223
+ <Grid container spacing={2}>
224
+ <Grid item xs={12} md={6}>Column 1</Grid>
225
+ </Grid>
226
+ ```
227
+
228
+ ---
229
+
230
+ ## Styling Constraints
231
+
232
+ ### CSS Variables Over Inline Styles
233
+
234
+ **Rule**: Use theme CSS variables instead of hardcoded values.
235
+
236
+ ```tsx
237
+ // ✅ Good: Theme-aware
238
+ <Box sx={{
239
+ bgcolor: 'background.paper',
240
+ color: 'text.primary',
241
+ p: 2,
242
+ }} />
243
+ ```
244
+
245
+ ```tsx
246
+ // ❌ Bad: Hardcoded values
247
+ <Box sx={{
248
+ backgroundColor: '#fff',
249
+ color: '#000',
250
+ padding: '16px',
251
+ }} />
252
+ ```
253
+
254
+ ### Component Style Overrides
255
+
256
+ **Rule**: Override MUI component styles through theme, not inline.
257
+
258
+ ```tsx
259
+ // ✅ Good: Theme-level overrides
260
+ const theme = createTheme({
261
+ components: {
262
+ MuiButton: {
263
+ styleOverrides: {
264
+ root: {
265
+ textTransform: 'none',
266
+ },
267
+ },
268
+ defaultProps: {
269
+ disableRipple: true,
270
+ },
271
+ },
272
+ },
273
+ });
274
+ ```
275
+
276
+ ```tsx
277
+ // ❌ Bad: Per-instance overrides
278
+ <Button sx={{ textTransform: 'none' }} disableRipple>Click</Button>
279
+ <Button sx={{ textTransform: 'none' }} disableRipple>Submit</Button>
280
+ ```
281
+
282
+ ---
283
+
284
+ ## Icon Usage
285
+
286
+ ### Material Icons
287
+
288
+ **Rule**: Use `@mui/icons-material` for MUI projects. Use SVG icons for custom designs.
289
+
290
+ ```tsx
291
+ // ✅ Good: MUI icons
292
+ import DeleteIcon from '@mui/icons-material/Delete';
293
+ <IconButton><DeleteIcon /></IconButton>
294
+ ```
295
+
296
+ ```tsx
297
+ // ❌ Bad: Icon fonts or inconsistent libraries
298
+ <i className="fa fa-trash"></i>
299
+ ```
300
+
301
+ ### Icon Size & Color
302
+
303
+ **Rule**: Let icons inherit size and color from parent component.
304
+
305
+ ```tsx
306
+ // ✅ Good: Inherited sizing
307
+ <Button startIcon={<AddIcon />}>Add Item</Button>
308
+ ```
309
+
310
+ ```tsx
311
+ // ❌ Bad: Manual sizing that breaks consistency
312
+ <Button startIcon={<AddIcon sx={{ fontSize: 20 }} />}>Add Item</Button>
313
+ ```
314
+
315
+ ---
316
+
317
+ ## Anti-Patterns
318
+
319
+ ### ❌ Don't Override Internal Class Names
320
+
321
+ ```tsx
322
+ // ❌ Bad: Brittle, breaks with MUI updates
323
+ <Button className="MuiButton-root" />
324
+ ```
325
+
326
+ ### ❌ Don't Mix Theme Systems
327
+
328
+ ```tsx
329
+ // ❌ Bad: Mixing MUI theme with external CSS variables
330
+ <Box sx={{ color: 'var(--custom-color)' }} /> // Use MUI theme instead
331
+ ```
332
+
333
+ ### ❌ Don't Bypass Theme Provider
334
+
335
+ ```tsx
336
+ // ❌ Bad: Direct theme access without provider
337
+ import { createTheme } from '@mui/material/styles';
338
+ const theme = createTheme();
339
+ <Box sx={{ p: theme.spacing(2) }} />
340
+ ```
341
+
342
+ ### ❌ Don't Use `transition: all`
343
+
344
+ ```tsx
345
+ // ❌ Bad: Performance killer
346
+ sx={{ transition: 'all 0.3s' }}
347
+
348
+ // ✅ Good: Specific properties
349
+ sx={{ transition: 'opacity 0.3s, transform 0.3s' }}
350
+ ```
351
+
352
+ ---
353
+
354
+ ## Accessibility Requirements
355
+
356
+ ### Icon-Only Buttons
357
+
358
+ **Rule**: All icon-only buttons must have `aria-label`.
359
+
360
+ ```tsx
361
+ // ✅ Good
362
+ <IconButton aria-label="Delete item">
363
+ <DeleteIcon />
364
+ </IconButton>
365
+
366
+ // ❌ Bad
367
+ <IconButton>
368
+ <DeleteIcon />
369
+ </IconButton>
370
+ ```
371
+
372
+ ### Form Components
373
+
374
+ **Rule**: All MUI form components require labels.
375
+
376
+ ```tsx
377
+ // ✅ Good: Visible label
378
+ <TextField label="Email" />
379
+
380
+ // ✅ Good: Accessible without visible label
381
+ <TextField aria-label="Search" placeholder="Search..." />
382
+
383
+ // ❌ Bad: No label
384
+ <TextField placeholder="Enter email" />
385
+ ```
386
+
387
+ ---
388
+
389
+ ## TypeScript Integration
390
+
391
+ ### Extend MUI Types
392
+
393
+ **Rule**: Augment MUI's module declarations for custom theme properties.
394
+
395
+ ```tsx
396
+ // ✅ Good: Type-safe theme extensions
397
+ declare module '@mui/material/styles' {
398
+ interface Palette {
399
+ tertiary: Palette['primary'];
400
+ }
401
+ interface PaletteOptions {
402
+ tertiary?: PaletteOptions['primary'];
403
+ }
404
+ }
405
+
406
+ const theme = createTheme({
407
+ palette: {
408
+ tertiary: {
409
+ main: '#ff9800',
410
+ },
411
+ },
412
+ });
413
+ ```
414
+
415
+ ### Strict Prop Types
416
+
417
+ **Rule**: Use MUI's provided TypeScript types, extend when needed.
418
+
419
+ ```tsx
420
+ // ✅ Good: Proper typing
421
+ import { ButtonProps } from '@mui/material/Button';
422
+
423
+ interface CustomButtonProps extends ButtonProps {
424
+ loading?: boolean;
425
+ }
426
+ ```
427
+
428
+ ---
429
+
430
+ ## Testing Considerations
431
+
432
+ ### Theme in Tests
433
+
434
+ **Rule**: Wrap components with theme provider in tests.
435
+
436
+ ```tsx
437
+ // ✅ Good: Themed test
438
+ import { ThemeProvider, createTheme } from '@mui/material/styles';
439
+
440
+ const theme = createTheme();
441
+ render(
442
+ <ThemeProvider theme={theme}>
443
+ <MyComponent />
444
+ </ThemeProvider>
445
+ );
446
+ ```
447
+
448
+ ### Snapshot Testing
449
+
450
+ **Rule**: Mock theme for consistent snapshots.
451
+
452
+ ```tsx
453
+ // ✅ Good: Stable snapshots
454
+ const testTheme = createTheme({
455
+ palette: { mode: 'light' },
456
+ });
457
+ ```
458
+
459
+ ---
460
+
461
+ ## Migration & Compatibility
462
+
463
+ ### Upgrading from MUI v5/v6
464
+
465
+ **Rule**: Use codemods for safe migrations.
466
+
467
+ ```bash
468
+ # ✅ Good: Automated migration
469
+ npx @mui/codemod v7.0.0/preset-safe <path>
470
+ ```
471
+
472
+ ### Deprecated API Usage
473
+
474
+ **Rule**: Check MUI changelog for deprecated features, replace immediately.
475
+
476
+ ```tsx
477
+ // ❌ Deprecated (v7)
478
+ import { makeStyles } from '@mui/styles';
479
+
480
+ // ✅ Current
481
+ import { styled } from '@mui/material/styles';
482
+ ```
483
+
484
+ ---
485
+
486
+ ## Related Resources
487
+
488
+ - [MUI Documentation](https://mui.com/material-ui/)
489
+ - [MUI GitHub](https://github.com/mui/material-ui)
490
+ - [CSS Theme Variables Guide](https://mui.com/material-ui/customization/css-theme-variables/usage/)
491
+ - [Dark Mode Best Practices](https://mui.com/material-ui/customization/dark-mode/)
@@ -0,0 +1,26 @@
1
+ ---
2
+ description: Guidelines for writing code optimized for the React Compiler (React 19+).
3
+ ---
4
+
5
+ **OBJECTIVE:**
6
+ Writing "Rules of React" compliant code to enable automatic memoization and optimization by the React Compiler.
7
+
8
+ **REASON:**
9
+ The React Compiler (`babel-plugin-react-compiler`) automatically optimizes components, but only if they follow strict functional purity and reactivity rules.
10
+
11
+ **DESCRIPTION:**
12
+ Best practices for ensuring components are "Compiler-safe," reducing the need for manual `useMemo` and `useCallback`.
13
+
14
+ **INSTRUCTIONS:**
15
+
16
+ ### Component Purity
17
+ - **No Mutations in Render**: Never mutate variables or objects during the render phase. Always treat props and state as immutable.
18
+ - **Pure Functions**: Ensure components and hooks are idempotent—calling them multiple times with the same inputs should produce the same results.
19
+
20
+ ### Hook Usage
21
+ - **Standard Hook Patterns**: Only use hooks at the top level and follow the standard React lifecycle.
22
+ - **Avoid Manual Memoization**: Stop using `useMemo` and `useCallback` for performance optimization; the compiler handles this. Only use them if they are required for stable references in external libraries or deep dependency arrays.
23
+
24
+ ### Compiler Safety
25
+ - **Validate with ESLint**: Ensure `eslint-plugin-react-compiler` is active to catch potential issues that would prevent optimization.
26
+ - **Side Effect Isolation**: Keep side effects strictly inside `useEffect` or event handlers.
@@ -0,0 +1,36 @@
1
+ ---
2
+ description: Methodology for Spec-Driven Development (SDD) based on the "Spec Kit" principles.
3
+ ---
4
+
5
+ **OBJECTIVE:**
6
+ Ensuring high-quality implementation by defining technical requirements and intent in a structured "Spec" before writing any code.
7
+
8
+ **REASON:**
9
+ SDD eliminates "vibe coding" (vague prompting) by providing the AI with a clear technical roadmap, reducing context loss and ensuring alignment with project standards.
10
+
11
+ **DESCRIPTION:**
12
+ The SDD process involves three distinct phases: Spec Drafting, Implementation, and Verification. The Spec serves as the "source of truth."
13
+
14
+ **INSTRUCTIONS:**
15
+
16
+ ### 1. Spec Initializing
17
+ - **Before coding starts**, create a `SPEC.md` or equivalent in the component/feature folder.
18
+ - **Spec Content**:
19
+ - **Intent**: What problem are we solving?
20
+ - **Usage**: How will the component be used (code examples)?
21
+ - **Architecture**: Tech stack, state management, and data flow.
22
+ - **Accessibility**: ARIA roles, focus management, reduced motion.
23
+ - **Performance**: Soft limits for assets, rendering loop optimizations.
24
+
25
+ ### 2. Implementation Phase
26
+ - **Pure Implementation**: The implementation phase MUST follow the Spec precisely. If the Spec is missing details, the Spec should be updated first.
27
+ - **Incremental Builds**: Build in logical steps (foundation -> features -> polish).
28
+ - **Checkpoints**: Use checkpoints after each major component or feature to verify against the Spec.
29
+
30
+ ### 3. Review & Refinement
31
+ - **Verification**: Cross-reference the final implementation against the "Implementation Checklist" in the Spec.
32
+ - **Zero Vibe Rule**: If the code "feels" right but doesn't meet a spec requirement, it is technically a failure.
33
+
34
+ ### 4. Spec Evolution
35
+ - **Living Document**: The spec is not static. If discoveries are made during OR after execution that change the architecture, update the Spec BEFORE continuing with the code, and/or AFTER final updates are made. Make sure to refactor our spec anytime an additional change or feature is added to the component.
36
+ - **Add Changelog**: Add small and concise summary and timestamp each time the spec changes.
@@ -0,0 +1,40 @@
1
+ ---
2
+ description: Best practices for integrating Supabase for auth, database, and asset storage.
3
+ ---
4
+
5
+ **OBJECTIVE:**
6
+ Implementing a secure, type-safe, and efficient integration with Supabase for data management and authentication.
7
+
8
+ **REASON:**
9
+ Ensures centralized client management, leverages TypeScript for end-to-end safety, and optimizes the handling of large 3D assets via Supabase Storage.
10
+
11
+ **DESCRIPTION:**
12
+ Guidelines for client initialization, authentication state management, and asset coordination between Supabase and Three.js.
13
+
14
+ **INSTRUCTIONS:**
15
+
16
+ ### Environment Configuration
17
+ - **Standard Naming**: Use `VITE_SUPABASE_URL` and `VITE_SUPABASE_ANON_KEY` in `.env` files.
18
+ - **Validation**: Ensure these variables are present and valid before initializing the client to prevent silent runtime failures.
19
+
20
+ ### Client Management
21
+ - **Singleton Pattern**: Initialize the Supabase client once in a dedicated file (e.g., `src/lib/supabase.ts`) and export it as a singleton.
22
+ - **Type Safety**: Generate TypeScript types using the Supabase CLI (`supabase gen types typescript --project-id ...`) and pass them to the `createClient` function for full IntelliSense support.
23
+
24
+ ### Authentication
25
+ - **Auth Context**: Wrap the application (or relevant branches) in a `SupabaseAuthProvider` to manage user sessions and profiles.
26
+ - **Protecting Routes**: Use specialized hooks (e.g., `useAuth`) to handle redirects for protected versus public views.
27
+ - **Loading States**: Always account for the initial session check to avoid "flash of unauthenticated content."
28
+
29
+ ### Database & RLS
30
+ - **RLS is Mandatory**: Never disable Row Level Security (RLS) in production. Always define specific policies for `SELECT`, `INSERT`, `UPDATE`, and `DELETE`.
31
+ - **Relational Integrity**: Use Foreign Key constraints and appropriate indexes to maintain data quality and query performance.
32
+
33
+ ### Asset Storage (Three.js Specific)
34
+ - **Bucket Organization**: Store 3D models (`.glb`, `.gltf`) and textures (`.webp`, `.ktx2`) in dedicated Supabase Storage buckets.
35
+ - **Signed URLs**: Use signed URLs for private assets or assets requiring temporary access.
36
+ - **Caching**: Leverage Supabase's built-in CDN for public storage buckets to minimize latency when loading 3D scenes.
37
+
38
+ ### Error Handling
39
+ - **User-Friendly Messages**: Transform Supabase error codes into human-readable feedback.
40
+ - **Retry Logic**: Implement exponential backoff for network-related failures, especially when uploading or downloading large assets.
@@ -0,0 +1,29 @@
1
+ ---
2
+ description: Best practices for using Tailwind CSS v4 in a performance-oriented React environment.
3
+ ---
4
+
5
+ **OBJECTIVE:**
6
+ Leveraging the CSS-first architecture of Tailwind CSS v4 to build high-performance, maintainable UIs.
7
+
8
+ **REASON:**
9
+ Tailwind v4 moves configuration into CSS and utilizes a high-performance engine (Lightning CSS), requiring a shift in how themes and utilities are managed compared to v3.
10
+
11
+ **DESCRIPTION:**
12
+ Guidelines for using Tailwind v4's `@theme` block, CSS variables, and modern engine features while avoiding legacy configuration patterns.
13
+
14
+ **INSTRUCTIONS:**
15
+
16
+ ### CSS-First Configuration
17
+ - **Use `@theme` in CSS**: Define all theme extensions (colors, fonts, spacing) inside the `@theme` block in your main CSS file, not in a JS configuration file.
18
+ - **Prefer CSS Variables**: Use CSS custom properties defined in `@theme`. Reference them as `var(--name)` when needed in custom styles.
19
+ - **Avoid `tailwind.config.js`**: Do not create or use a `tailwind.config.js` file unless strictly necessary for legacy plugin compatibility.
20
+
21
+ ### Performance & Engine
22
+ - **Leverage Lightning CSS**: Be aware that Tailwind v4 uses Lightning CSS for ultra-fast builds. Avoid complex PostCSS plugins that might slow down the pipeline.
23
+ - **Built-in Modern Features**: Use modern CSS features like `@import "tailwindcss"` and direct variable references which are optimized by the v4 engine.
24
+
25
+ ### Implementation Patterns
26
+ - **Prioritize Container Queries**: Use `@container` queries for component-level styling and layout before resorting to viewport-based media queries whenever a component's layout depends on its parent's width.
27
+ - **Dual Color Palettes**: Always define and implement both **light and dark** color mode palettes within the `@theme` block. Use native CSS color-scheme support and variables to ensure seamless transitions.
28
+ - **Utility First**: Maintain the utility-first mindset, but use standard CSS for complex layouts that utilities cannot cleanly handle.
29
+ - **Modern Color Palettes**: Use the expanded Oklch color space support provided by v4 for better perceptual uniformity in gradients and UI elements.
@@ -0,0 +1,76 @@
1
+ ---
2
+ description: Guidelines for building production-ready React applications with Three.js and AI-powered tools.
3
+ ---
4
+
5
+ **OBJECTIVE:**
6
+ Building production-ready React applications with [Three.js](https://threejs.org/manual/#en/creating-a-scene) and AI-powered APIs and tooling.
7
+
8
+ **REASON:**
9
+ Ensures high performance, proper resource management, and clean React integration when working with complex 3D scenes in a web environment.
10
+
11
+ **DESCRIPTION:**
12
+ This rule provides a comprehensive set of best practices for Three.js development within a React ecosystem, focusing on memory management, rendering optimization, and asset handling.
13
+
14
+ **INSTRUCTIONS:**
15
+
16
+ ### Resource Management
17
+ - **Always dispose** of `Geometry`, `Material`, `Texture`, and `Renderer` objects in component cleanup to prevent WebGL memory leaks.
18
+ - Call `geometry.dispose()`, `material.dispose()`, `texture.dispose()`, and `renderer.dispose()` in the `useEffect` cleanup function.
19
+ - Dispose of post-processing passes and composers when unmounting.
20
+
21
+ ### Performance Optimization
22
+ - **Cap pixel ratio** to `Math.min(window.devicePixelRatio, 2)` to balance quality and performance.
23
+ - Set `powerPreference: "high-performance"` in `WebGLRenderer` options.
24
+ - **Reuse objects** (Vector3, Color, etc.) instead of creating new instances in the animation loop.
25
+ - Use `BufferGeometry` instead of legacy `Geometry`.
26
+ - Limit particle counts and geometry complexity based on device capabilities.
27
+
28
+ ### React Integration
29
+ - Use `useRef` for canvas elements and Three.js objects (scene, camera, renderer).
30
+ - Initialize Three.js in `useEffect` with proper cleanup in the return function.
31
+ - Cancel `requestAnimationFrame` on component unmount to prevent memory leaks.
32
+ - **Avoid storing Three.js objects in React state**; use refs instead.
33
+
34
+ ### Responsive Design
35
+ - Handle window resize events to update camera aspect ratio and renderer size.
36
+ - Update post-processing composer and pass resolutions on resize.
37
+ - Debounce resize handlers if performing expensive recalculations.
38
+
39
+ ### Animation Loop
40
+ - Use `requestAnimationFrame` for smooth 60fps rendering.
41
+ - Store the animation frame ID and cancel it in cleanup.
42
+ - Implement delta time for frame-rate independent animations when needed.
43
+
44
+ ### Scene Organization
45
+ - Use `THREE.Group` to organize related objects for easier transformation and cleanup.
46
+ - Separate static and dynamic objects for optimization opportunities.
47
+ - Use meaningful names for objects to aid debugging (`object.name = "particleSystem"`).
48
+
49
+ ### Asset Loading
50
+ - Use `GLTFLoader` for 3D models (preferred format for web).
51
+ - Implement `LoadingManager` for coordinated loading with progress tracking.
52
+ - Use `DRACOLoader` for compressed GLTF files to reduce file size.
53
+ - Handle loading errors gracefully with user feedback.
54
+ - Consider lazy loading non-critical 3D assets.
55
+
56
+ ### Shaders and Materials
57
+ - Minimize dynamic lights; prefer baked lighting or environment maps (HDRI).
58
+ - Use `ShaderMaterial` for custom effects but keep shaders optimized.
59
+ - Avoid heavy branching and loops in fragment shaders.
60
+ - Use `MeshStandardMaterial` or `MeshPhysicalMaterial` for PBR workflows.
61
+ - Set `depthWrite: false` and `transparent: true` appropriately for particle systems.
62
+
63
+ ### Post-Processing
64
+ - Use `EffectComposer` for post-processing effects.
65
+ - Order passes efficiently (RenderPass → effects → FXAA/SMAA last).
66
+ - Disable unused passes to save performance.
67
+ - Update pass resolutions on window resize.
68
+
69
+ ### Interaction
70
+ - Throttle or debounce mouse/touch event handlers for expensive calculations.
71
+ - Use raycasting efficiently; limit the number of objects tested.
72
+ - Implement smooth camera controls with lerping for better UX.
73
+
74
+ ### Framework Consideration
75
+ - For complex scenes, consider migrating to `@react-three/fiber` and `@react-three/drei` for declarative Three.js in React.
76
+ - These libraries provide React-friendly abstractions, automatic disposal, and helpful hooks.