fecode-cli 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 (74) hide show
  1. package/dist/App.d.ts +33 -0
  2. package/dist/App.js +2224 -0
  3. package/dist/approvalResolver.d.ts +12 -0
  4. package/dist/approvalResolver.js +112 -0
  5. package/dist/commands.d.ts +11 -0
  6. package/dist/commands.js +33 -0
  7. package/dist/index.d.ts +3 -0
  8. package/dist/index.js +15175 -0
  9. package/dist/ui/AppShell.d.ts +14 -0
  10. package/dist/ui/AppShell.js +25 -0
  11. package/dist/ui/ApprovalPrompt.d.ts +31 -0
  12. package/dist/ui/ApprovalPrompt.js +55 -0
  13. package/dist/ui/BlockedView.d.ts +13 -0
  14. package/dist/ui/BlockedView.js +7 -0
  15. package/dist/ui/CommandPalette.d.ts +8 -0
  16. package/dist/ui/CommandPalette.js +18 -0
  17. package/dist/ui/CurrentStepView.d.ts +16 -0
  18. package/dist/ui/CurrentStepView.js +28 -0
  19. package/dist/ui/DiagnosticsView.d.ts +45 -0
  20. package/dist/ui/DiagnosticsView.js +23 -0
  21. package/dist/ui/ExecutionTimeline.d.ts +15 -0
  22. package/dist/ui/ExecutionTimeline.js +51 -0
  23. package/dist/ui/ExecutionView.d.ts +42 -0
  24. package/dist/ui/ExecutionView.js +20 -0
  25. package/dist/ui/Header.d.ts +15 -0
  26. package/dist/ui/Header.js +47 -0
  27. package/dist/ui/HelpView.d.ts +3 -0
  28. package/dist/ui/HelpView.js +35 -0
  29. package/dist/ui/MessageBubble.d.ts +9 -0
  30. package/dist/ui/MessageBubble.js +58 -0
  31. package/dist/ui/PlanStep.d.ts +16 -0
  32. package/dist/ui/PlanStep.js +71 -0
  33. package/dist/ui/PlanView.d.ts +26 -0
  34. package/dist/ui/PlanView.js +24 -0
  35. package/dist/ui/ProgressBar.d.ts +10 -0
  36. package/dist/ui/ProgressBar.js +14 -0
  37. package/dist/ui/RecoveryView.d.ts +20 -0
  38. package/dist/ui/RecoveryView.js +19 -0
  39. package/dist/ui/ReplanView.d.ts +16 -0
  40. package/dist/ui/ReplanView.js +21 -0
  41. package/dist/ui/ResumeView.d.ts +15 -0
  42. package/dist/ui/ResumeView.js +25 -0
  43. package/dist/ui/RiskNotice.d.ts +10 -0
  44. package/dist/ui/RiskNotice.js +21 -0
  45. package/dist/ui/RunHistoryView.d.ts +15 -0
  46. package/dist/ui/RunHistoryView.js +39 -0
  47. package/dist/ui/StatusBar.d.ts +16 -0
  48. package/dist/ui/StatusBar.js +104 -0
  49. package/dist/ui/TaskInput.d.ts +15 -0
  50. package/dist/ui/TaskInput.js +8 -0
  51. package/dist/ui/ThinkingBlock.d.ts +8 -0
  52. package/dist/ui/ThinkingBlock.js +13 -0
  53. package/dist/ui/ThinkingIndicator.d.ts +7 -0
  54. package/dist/ui/ThinkingIndicator.js +20 -0
  55. package/dist/ui/TurnView.d.ts +13 -0
  56. package/dist/ui/TurnView.js +11 -0
  57. package/dist/ui/WorkspaceStatus.d.ts +20 -0
  58. package/dist/ui/WorkspaceStatus.js +23 -0
  59. package/dist/ui/index.d.ts +26 -0
  60. package/dist/ui/index.js +26 -0
  61. package/package.json +42 -0
  62. package/skills/accessibility/SKILL.md +98 -0
  63. package/skills/css/SKILL.md +90 -0
  64. package/skills/frontend-debugging/SKILL.md +201 -0
  65. package/skills/frontend-design/SKILL.md +358 -0
  66. package/skills/frontend-performance/SKILL.md +89 -0
  67. package/skills/frontend-testing/SKILL.md +87 -0
  68. package/skills/nextjs/SKILL.md +75 -0
  69. package/skills/react/SKILL.md +213 -0
  70. package/skills/responsive-design/SKILL.md +190 -0
  71. package/skills/svelte/SKILL.md +86 -0
  72. package/skills/tailwind/SKILL.md +74 -0
  73. package/skills/ui-review/SKILL.md +245 -0
  74. package/skills/vue/SKILL.md +72 -0
@@ -0,0 +1,358 @@
1
+ ---
2
+ name: frontend-design
3
+ description: Professional frontend design methodology for creating, modifying, and polishing user interfaces. Apply when creating new pages or components, redesigning existing interfaces, implementing UI from product requirements, improving visual quality, or working on responsive layout. This skill teaches design thinking, visual hierarchy, typography, color, spatial composition, interaction design, and how to avoid generic AI-generated UI in favor of deliberate, product-appropriate interfaces.
4
+ category: frontend
5
+ version: 2.0.0
6
+ ---
7
+
8
+ # Frontend Design
9
+
10
+ ## When to use
11
+ - Creating new UI pages, views, or components
12
+ - Modifying or redesigning an existing interface
13
+ - Implementing UI from a design brief or written requirements
14
+ - Polishing visual quality of an existing interface
15
+ - Responsive layout work
16
+ - Improving interaction states or motion
17
+
18
+ ## When not to use
19
+ - Pure backend or API work with no UI surface
20
+ - Database schema or server-side logic work
21
+ - Writing tests unrelated to UI behavior
22
+
23
+ ## Instructions
24
+ - Make deliberate design choices appropriate to the product — never default to the nearest generic template.
25
+ - Before writing any UI code, understand the product, its users, and the primary task the interface must accomplish.
26
+ - When modifying an existing interface, preserve its design language unless explicitly asked to redesign it.
27
+ - When creating new UI in an existing project, inspect and reuse existing design tokens, components, and conventions.
28
+ - Design for the user's primary task first; everything else is supporting.
29
+ - Every visual decision must earn its place — eliminate anything decorative without purpose.
30
+
31
+ ## Design Thinking
32
+
33
+ Before writing any UI code, reason through these questions:
34
+
35
+ 1. **What is this interface?** A dashboard, a form, a detail page, a list view, a marketing page?
36
+ 2. **Who uses it?** A consumer in a hurry, a professional doing analytical work, an administrator configuring a system?
37
+ 3. **What is the primary task?** The single most important thing a user must be able to do efficiently.
38
+ 4. **What information is most important?** Establish a hierarchy — not all elements deserve equal visual weight.
39
+ 5. **What should the user notice first?** Design entry points deliberately.
40
+ 6. **What visual personality fits the product?** Technical tools feel different from consumer apps, which feel different from luxury products.
41
+ 7. **What existing design language must be preserved?** For existing projects, this question overrides all others.
42
+
43
+ Design is a series of deliberate choices. Make those choices consciously rather than generating the first plausible layout.
44
+
45
+ ## Existing Products vs New Interfaces
46
+
47
+ ### Modifying an existing interface
48
+
49
+ **The existing design system is the source of truth.**
50
+
51
+ Before implementing anything:
52
+ - Read existing components in the project
53
+ - Identify design tokens (colors, spacing, radius, shadows, typography)
54
+ - Understand existing layout patterns and grid conventions
55
+ - Examine interaction patterns (hover, focus, active states)
56
+ - Identify component naming conventions
57
+
58
+ Then implement the change **within** that language. Do not introduce new color palettes, new radius conventions, or new spacing scales. Do not "improve" a product's aesthetic unless the user explicitly requests a redesign.
59
+
60
+ Signs you are drifting from the existing system:
61
+ - You are introducing a new color not present in existing components
62
+ - You are using radius values unlike anything else in the project
63
+ - Your component has a completely different spacing density than its neighbors
64
+
65
+ ### Creating a new interface
66
+
67
+ When the project is genuinely new or the user requests a redesign, establish a deliberate visual direction.
68
+
69
+ Possible directions (choose what fits the product):
70
+ - **Minimal** — whitespace-driven, restrained, high readability
71
+ - **Editorial** — strong typographic hierarchy, expressive layouts
72
+ - **Technical** — dense, information-rich, precise
73
+ - **Utilitarian** — clarity and efficiency above expression
74
+ - **Playful** — expressive color, rounded forms, energetic
75
+ - **Luxury** — restrained, premium materials, deliberate pacing
76
+ - **Industrial** — structured, mechanical, systematic
77
+
78
+ Choose a direction. Then build everything within it consistently. Do not blend incompatible directions accidentally.
79
+
80
+ ## Typography
81
+
82
+ Typography is the primary instrument of visual hierarchy.
83
+
84
+ **Hierarchy**
85
+ - Establish a clear scale: display/heading/subheading/body/caption/label
86
+ - Not every page needs every level — use what the content requires
87
+ - Contrast between levels creates hierarchy; too-similar sizes create visual noise
88
+
89
+ **Display and body roles**
90
+ - Display type draws attention and communicates personality
91
+ - Body type must be legible at length — optimize for readability over expression
92
+ - Do not use display treatments for body-length content
93
+
94
+ **Weight, leading, and tracking**
95
+ - Use weight to differentiate hierarchy, not decoration
96
+ - Line height for body text: 1.5–1.7 for comfortable reading
97
+ - Line height for headings: 1.1–1.3 for tight, assertive display
98
+ - Tight letter-spacing on large display type typically improves appearance
99
+ - Loose letter-spacing on small caps/labels can improve legibility
100
+
101
+ **Measure**
102
+ - Body text reads best between 55–80 characters per line
103
+ - Full-width body text on wide screens is almost always wrong — constrain it
104
+
105
+ **Existing projects**
106
+ - Use the project's established type scale, not a new one
107
+ - If the project already uses Inter or Roboto, do not introduce a new typeface
108
+ - If the project has no clear type system, establish one and be consistent
109
+
110
+ ## Color
111
+
112
+ **Semantics before aesthetics**
113
+ Understand what colors mean in context before choosing them:
114
+ - Primary: the interface's brand/action color
115
+ - Secondary: supporting actions or alternative emphasis
116
+ - Semantic: success, warning, error, info
117
+ - Surface hierarchy: background → surface → elevated surface
118
+ - On-colors: text/icons placed on each surface
119
+
120
+ **Contrast**
121
+ - Body text on backgrounds must meet WCAG AA contrast at minimum
122
+ - Critical interactive elements must be distinguishable without color alone
123
+
124
+ **Accent discipline**
125
+ - Use accent colors for actions, not decoration
126
+ - More than two or three accent colors in one interface is usually noise
127
+
128
+ **Design tokens**
129
+ - Prefer existing CSS variables or design tokens over arbitrary hex values
130
+ - Introduce new tokens only when filling a genuine gap
131
+
132
+ **Dark mode**
133
+ - Surface hierarchy inverts in dark mode — darker isn't always correct
134
+ - Avoid pure black surfaces; slightly elevated grays produce better depth
135
+
136
+ ## Spatial Composition
137
+
138
+ Space communicates relationships. It is not filler.
139
+
140
+ **Proximity**: elements that belong together should be close; elements that are separate should breathe
141
+ **Alignment**: consistent grid alignment creates calm; misalignment creates visual tension
142
+ **Rhythm**: consistent vertical rhythm through spacing scales creates cohesion
143
+ **Density**: match density to use case — dashboards can be dense, reading views need space
144
+ **Grouping**: use space and visual weight before reaching for borders and dividers
145
+
146
+ **Spacing scale**
147
+ Use the project's spacing scale (or establish one: 4px base unit, multiples thereof). Avoid arbitrary pixel values that break rhythm.
148
+
149
+ **Container width**
150
+ - Reading content: constrain to ~65–75ch
151
+ - Data-dense interfaces: allow wider containers
152
+ - Full-bleed elements need intention — not everything should fill the viewport
153
+
154
+ **Grid and flex**
155
+ Use CSS Grid for two-dimensional layout; Flexbox for one-dimensional alignment. Do not reach for absolute positioning when flow-based layout is cleaner.
156
+
157
+ ## Components
158
+
159
+ **Inspect before building**
160
+ Before creating a new component, search the codebase for:
161
+ - Existing components that may already serve the purpose
162
+ - Existing primitives (Button, Card, Input, Modal) that should be composed
163
+ - Existing patterns for how similar UI is assembled
164
+
165
+ **Composition over creation**
166
+ Prefer composing existing primitives over building new ones from scratch. Every new primitive must be maintained.
167
+
168
+ **Component size**
169
+ - Components with more than three or four major responsibilities are usually too large
170
+ - Extract sub-components when a section has independent visual logic
171
+ - Do not extract purely for abstraction's sake when it adds no clarity
172
+
173
+ **Avoid duplication**
174
+ Do not create a `PrimaryButton` alongside an existing `Button` with a `variant="primary"` prop. Understand the existing component API first.
175
+
176
+ ## Responsive Design
177
+
178
+ Think about the interface's behavior at every width, not just at defined breakpoints.
179
+
180
+ **Layout strategy**
181
+ - Start from the most constrained layout the content requires
182
+ - Define breakpoints where the layout naturally breaks, not at arbitrary device widths
183
+ - Fluid layouts that adapt gracefully often require fewer breakpoints than rigid ones
184
+
185
+ **Fluid width vs fixed columns**
186
+ - Let containers grow to a max-width, then center
187
+ - Avoid pixel-fixed widths on components that must live in fluid parents
188
+ - Grid columns should collapse meaningfully at smaller sizes
189
+
190
+ **Typography and spacing respond to viewport**
191
+ - Headings that work at 1400px may be overwhelming on mobile — scale them
192
+ - Spacing density can increase at wider viewports
193
+ - Use relative units and clamp() for fluid typographic scaling
194
+
195
+ **Navigation at small sizes**
196
+ - Horizontal nav bars often cannot survive narrow viewports — plan mobile navigation early
197
+ - Collapsed navigation patterns (hamburger, drawer, bottom bar) each have trade-offs; choose deliberately
198
+
199
+ **Overflow**
200
+ - Horizontal overflow is almost always a bug, not a design choice
201
+ - Tables and data-dense elements need explicit overflow strategies on small screens
202
+
203
+ **Between breakpoints**
204
+ Test by resizing gradually, not just by snapping between sm/md/lg. Fix anything that breaks awkwardly in between.
205
+
206
+ ## Interaction Design
207
+
208
+ Every interactive element has multiple states. Design all of them.
209
+
210
+ **Required states for interactive elements**
211
+ - `hover` — shows the element is actionable
212
+ - `focus-visible` — must be visibly distinct for keyboard users (do not remove outlines)
213
+ - `active` / `pressed` — confirms the action is being triggered
214
+ - `disabled` — communicates unavailability; reduce opacity or alter appearance
215
+ - `loading` — prevents double submission and communicates progress
216
+ - `error` — communicates failure clearly, without blame
217
+ - `success` — confirms completion
218
+
219
+ **Additional states as needed**
220
+ - `selected` / `checked` / `on` for toggles and selections
221
+ - `empty` — design empty states, not blank voids
222
+ - `skeleton` / `loading placeholder` — prefer structural loading over spinners for content-heavy surfaces
223
+
224
+ Hover is not the only interaction state. A button that looks identical when focused, hovered, and pressed is incomplete.
225
+
226
+ ## Motion
227
+
228
+ Motion should communicate, not decorate.
229
+
230
+ **Purposeful transitions**
231
+ - Transitions should reinforce spatial relationships (drawers slide, modals appear from their trigger, lists animate in sequence)
232
+ - State changes benefit from transitions that indicate what changed and why
233
+
234
+ **Duration and easing**
235
+ - Most UI transitions: 150–300ms
236
+ - Complex motion (modals, page transitions): 300–500ms
237
+ - Ease-out for elements entering; ease-in for elements leaving; ease-in-out for state transitions
238
+
239
+ **Reduced motion**
240
+ - Always respect `prefers-reduced-motion`
241
+ - Provide no-animation fallbacks; never disable reduced-motion support
242
+
243
+ **What to avoid**
244
+ - Animation that fires without user intent
245
+ - Decorative animation that competes with content
246
+ - Excessive bounce, spin, or particle effects in productivity interfaces
247
+ - Animation that delays the user from completing their task
248
+
249
+ ## Content as Design
250
+
251
+ Content is not a placeholder. It is the interface.
252
+
253
+ **Copy**
254
+ - Labels, headings, and button text should be specific, not generic ("Save changes" not "Submit")
255
+ - Error messages should explain what went wrong and what to do next
256
+ - Empty states should explain the situation and offer a next action
257
+
258
+ **Content length realism**
259
+ - Design for realistic content — not just the 15-character happy-path name
260
+ - Test with long names, long descriptions, many list items, empty lists
261
+ - Define truncation behavior explicitly (ellipsis, clamping, expand)
262
+
263
+ **Localization considerations**
264
+ - Text expands significantly in many languages (German, Finnish); build layouts that tolerate it
265
+ - Avoid fixed-width containers sized tightly to English text
266
+
267
+ ## Basic Accessibility
268
+
269
+ (The dedicated accessibility skill contains deeper guidance.)
270
+
271
+ Minimum requirements regardless of design style:
272
+ - Use semantic HTML elements for their intended purpose
273
+ - All interactive elements must be keyboard-reachable and operable
274
+ - Visible `:focus-visible` styles on all interactive elements — do not remove them
275
+ - Text must meet WCAG AA contrast ratios on its background
276
+ - Images must have meaningful alt text; decorative images use `alt=""`
277
+ - UI actions must not depend solely on color to communicate state
278
+ - Respect `prefers-reduced-motion` in all animations and transitions
279
+
280
+ ## Avoiding Generic AI-Generated UI
281
+
282
+ The most common failure mode of AI-generated frontend code is visual genericness. The interface looks assembled from an anonymous template rather than designed for a specific product.
283
+
284
+ **Signs of generic AI UI to detect and correct**
285
+ - Interchangeable card grids filling every surface regardless of content type
286
+ - Hero sections with a centered headline, subtext, and two buttons — used when not appropriate
287
+ - Excessive rounded corners applied uniformly regardless of brand personality
288
+ - Purple/blue gradient text fills on headings with no product reason
289
+ - Glassmorphism effects applied decoratively without contributing to hierarchy
290
+ - Decorative blobs, particles, or abstract shapes placed behind content
291
+ - Every section wrapped in a card, inside another card, inside another card
292
+ - All text set in the same weight, creating a flat hierarchy
293
+ - Gradients that exist because "gradients feel modern," not because they communicate anything
294
+ - Bento grids populated with unrelated icons as substitutes for actual content
295
+
296
+ **The principle**
297
+ These are failure modes, not absolute prohibitions. Gradients, rounded corners, and cards are legitimate design tools. The failure is using them automatically, without a product reason.
298
+
299
+ The corrective question: *Why does this specific product need this specific visual treatment?*
300
+ If the answer is "because it looks good" without connection to the product — reconsider it.
301
+
302
+ ## Design Workflow
303
+
304
+ 1. **Understand the request** — What specifically is being created or changed? What outcome is the user trying to achieve?
305
+ 2. **Inspect the existing project** — Read existing components, design tokens, colors, spacing, typography. For existing projects, this step determines most of what follows.
306
+ 3. **Identify the primary task** — What must the user be able to do? Design around that.
307
+ 4. **Determine visual direction** — For existing projects: maintain it. For new interfaces: choose deliberately.
308
+ 5. **Establish structure** — Layout, information hierarchy, component breakdown.
309
+ 6. **Implement structure** — Semantic HTML, layout, component composition.
310
+ 7. **Implement visual styling** — Typography, color, spacing, depth.
311
+ 8. **Implement responsive behavior** — Test from narrow to wide; fix what breaks between breakpoints.
312
+ 9. **Implement interaction states** — All states for all interactive elements.
313
+ 10. **Implement motion** — Where purposeful; none where not.
314
+ 11. **Self-review** — Run the checklist below before considering the work complete.
315
+ 12. **Verify** — Run project checks; review actual output.
316
+
317
+ ## Self-Review Checklist
318
+
319
+ Before considering UI work complete:
320
+
321
+ - Does this interface feel specific to this product, or could it belong to any SaaS?
322
+ - Does the visual hierarchy communicate the intended priority of information?
323
+ - Is there anything decorative without purpose?
324
+ - Are spacing and alignment consistent throughout?
325
+ - Does the layout work at narrow and wide viewports, and between them?
326
+ - Are all interactive states complete (hover, focus, active, disabled, loading, error)?
327
+ - Does this preserve the existing design system, or does it introduce inconsistencies?
328
+ - Does it feel like a coherent interface rather than a collection of independently styled components?
329
+
330
+ ## Verification
331
+
332
+ After implementing UI changes:
333
+ - Inspect the actual rendered output or diff carefully
334
+ - Run any existing visual or component tests in the project
335
+ - Run the project's type and lint checks
336
+ - Verify responsive behavior by considering the layout at multiple widths
337
+ - Confirm interaction states are present by reviewing the implementation
338
+
339
+ ## Examples
340
+
341
+ ### Example: Dashboard primary action
342
+
343
+ **Generic approach:**
344
+ Create a dashboard with 12 metric cards in a responsive grid.
345
+
346
+ **Better approach:**
347
+ Identify the dashboard's primary decision. Design the layout hierarchy around that one thing. Surface the most actionable metric prominently. Use supporting data as secondary context. The number of cards follows from the content, not from filling a grid.
348
+
349
+ ### Example: Modifying an existing component
350
+
351
+ **Wrong approach:**
352
+ The component uses gray-100 for its background. The AI decides to "improve" it with a subtle gradient and more rounded corners, introducing design system inconsistency.
353
+
354
+ **Correct approach:**
355
+ Read the existing Button, Card, and Input components first. Match their background, radius, shadow, and spacing conventions exactly. The new component is invisible relative to the design system — which is correct.
356
+
357
+ ## References
358
+ - Design System: Check project source for existing tokens and component conventions before writing new styles
@@ -0,0 +1,89 @@
1
+ ---
2
+ name: frontend-performance
3
+ description: Performance optimization, bottleneck diagnosis, and core web vitals.
4
+ category: frontend
5
+ version: 2.1.0
6
+ ---
7
+
8
+ ## When to use
9
+
10
+ - diagnosing slow performance
11
+ - optimizing loading times
12
+ - fixing jank or slow interactions
13
+
14
+ ## Instructions
15
+
16
+ ### Project Detection & Existing Rules
17
+ - **Inspect first**: Check `package.json`, build configuration, and existing performance tooling (like Lighthouse CI or bundle analyzers).
18
+ - **Respect existing architecture**: Do not introduce new dependencies or rewrite build tools unless required.
19
+
20
+ ### Core Mental Model
21
+ - Performance is about user-visible outcomes such as loading, responsiveness, interaction latency, rendering, network, and memory.
22
+ - Optimization follows: MEASURE → IDENTIFY → CHANGE → VERIFY.
23
+ - Do not optimize hypothetical problems.
24
+
25
+ ## Rules
26
+
27
+ ### Diagnosis & Optimization Process
28
+ Before optimizing:
29
+ 1. Identify the symptom.
30
+ 2. Measure or inspect evidence.
31
+ 3. Locate the bottleneck.
32
+ 4. Make the smallest meaningful change.
33
+ 5. Verify the improvement.
34
+
35
+ ### Loading Performance
36
+ - **Bundle Size**: Monitor the impact of new dependencies.
37
+ - **Code Splitting**: Split code by route or large feature to reduce initial payload.
38
+ - **Lazy Loading**: Use lazy loading for offscreen or low-priority components. Do not blindly lazy-load above-the-fold content.
39
+ - **Caching**: Ensure static assets are cacheable.
40
+
41
+ ### Runtime Performance
42
+ - **Unnecessary Work**: Avoid running expensive calculations on every render.
43
+ - **Large Lists**: Use virtualization or pagination for massive lists.
44
+ - **Layout Thrashing**: Avoid interleaving DOM reads and writes in the same synchronous frame.
45
+ - **Event Handlers**: Debounce or throttle high-frequency events (like scroll or resize).
46
+
47
+ ### Images
48
+ - Specify dimensions (`width` and `height`) to prevent layout shifts.
49
+ - Use responsive images (`srcset`, `sizes`).
50
+ - Use modern formats (`WebP`, `AVIF`) where appropriate.
51
+ - Lazy-load below-the-fold images (`loading="lazy"`).
52
+
53
+ ### Fonts
54
+ - Limit the number of font files and weights.
55
+ - Use `font-display: swap` for better perceived loading.
56
+ - Subsetting fonts can drastically reduce file size.
57
+
58
+ ### JavaScript
59
+ - Avoid unnecessary client-side JavaScript.
60
+ - Audit large client-side libraries and prefer lighter alternatives when permitted.
61
+
62
+ ### Rendering
63
+ - Prevent unnecessary rerenders (framework-neutral principle).
64
+ - Minimize expensive DOM updates and long tasks that block the main thread.
65
+
66
+ ## Anti-Patterns
67
+
68
+ - **Optimizing without measurement**
69
+ - *What*: Applying "performance hacks" blindly across the codebase.
70
+ - *Why*: It complicates the code without guaranteeing any actual user benefit, and often introduces bugs.
71
+ - *Instead*: Measure first, locate the bottleneck, then optimize.
72
+ - **Lazy-loading everything**
73
+ - *What*: Lazy-loading above-the-fold hero images or the main routing shell.
74
+ - *Why*: It delays the loading of critical content, worsening the Largest Contentful Paint (LCP).
75
+ - *Instead*: Eagerly load critical assets and only lazy-load what is offscreen.
76
+ - **Excessive memoization**
77
+ - *What*: Wrapping every single function in memoization hooks.
78
+ - *Why*: Memoization costs memory and execution time. If the function is cheap, the overhead of memoizing it is worse than recalculating it.
79
+ - *Instead*: Only memoize demonstrably expensive calculations or stable props passed to pure child components.
80
+
81
+ ## Workflow
82
+
83
+ ### Debugging
84
+ - Check network tabs for excessive payload sizes or waterfall blocking.
85
+ - Check profiling tools for long tasks or layout thrashing.
86
+
87
+ ### Verification
88
+ - Use actual project tooling when available (e.g., build output, bundle analysis, profiling, Lighthouse, browser performance tools).
89
+ - **Never claim a performance improvement without evidence.** Verify via build sizes or test run metrics.
@@ -0,0 +1,87 @@
1
+ ---
2
+ name: frontend-testing
3
+ description: Frontend testing strategy, component tests, integration tests, and behavioral assertions.
4
+ category: testing
5
+ version: 2.1.0
6
+ ---
7
+
8
+ ## When to use
9
+
10
+ - writing frontend tests
11
+ - fixing failing tests
12
+ - implementing testing strategy
13
+
14
+ ## Instructions
15
+
16
+ ### Project Detection & Existing Rules
17
+ - **Inspect package.json & Configuration**: Check existing test scripts, testing libraries (Jest, Vitest, Cypress, Playwright, React Testing Library), and conventions.
18
+ - **Follow existing patterns**: Do not introduce another testing framework when one already exists.
19
+
20
+ ### Core Mental Model
21
+ - Tests should provide confidence about behavior.
22
+ - Prefer testing what the user/system observes over testing internal implementation details.
23
+
24
+ ## Rules
25
+
26
+ ### Testing Layers
27
+ - **Unit Tests**: Good for pure functions, utilities, and complex logic isolation.
28
+ - **Component Tests**: Good for verifying UI state, props, and user interaction.
29
+ - **Integration/E2E Tests**: Good for verifying that the entire system coordinates correctly.
30
+ - Do not insist every project needs every layer. Match the project's strategy.
31
+
32
+ ### What to Test
33
+ Prioritize:
34
+ - important user behavior (submitting a form, navigating)
35
+ - business logic
36
+ - regressions
37
+ - edge cases, error states, and loading states
38
+
39
+ ### What Not to Test
40
+ Avoid tests that only verify:
41
+ - internal implementation details (e.g. checking if a specific internal variable is set to true)
42
+ - trivial framework behavior (e.g. testing that a React component renders a div)
43
+ - exact DOM structure without behavioral significance
44
+
45
+ ### Mocking
46
+ Before mocking:
47
+ - Ask whether the real dependency can safely be used (e.g., testing against the real DOM or an in-memory database).
48
+ - Avoid excessive mocking that makes tests pass while hiding genuine integration bugs.
49
+
50
+ ### Async UI
51
+ Test loading, success, error, retry, and empty states.
52
+ - **Do not assert immediately** before asynchronous behavior completes. Use asynchronous finders (`findBy`, `waitFor`).
53
+
54
+ ### Forms
55
+ Test valid submission, invalid input, validation errors, disabled/loading states, and submission failure.
56
+
57
+ ### Accessibility
58
+ Where appropriate, include accessible queries (e.g., `getByRole`) and basic accessibility verification to implicitly test a11y alongside behavior.
59
+
60
+ ## Anti-Patterns
61
+
62
+ - **Brittle selectors**
63
+ - *What*: Querying elements by CSS classes (e.g., `.btn-primary-wrapper > div`).
64
+ - *Why*: Any minor styling or DOM structure change breaks the test, even if the user behavior is intact.
65
+ - *Instead*: Query by accessible roles, labels, or explicit test IDs (`getByRole('button', { name: /submit/i })`).
66
+ - **Testing implementation details**
67
+ - *What*: Asserting that a component called `setState(true)` internally.
68
+ - *Why*: Refactoring the component (e.g., to use `useReducer`) breaks the test even if the UI still works perfectly.
69
+ - *Instead*: Assert on the visible UI changes (e.g., expecting a loading spinner to appear).
70
+ - **Excessive mocking**
71
+ - *What*: Mocking every child component in a tree.
72
+ - *Why*: The test passes, but the application might crash in production because the components don't actually integrate correctly.
73
+ - *Instead*: Use shallow rendering sparingly. Render the real components unless they trigger expensive or un-mockable side effects.
74
+
75
+ ## Workflow
76
+
77
+ ### Debugging
78
+ When a test fails:
79
+ 1. Understand the failure.
80
+ 2. Determine whether the application behavior or the test assumptions are wrong.
81
+ 3. Inspect relevant code and reproduce the failure.
82
+ 4. Make the smallest appropriate fix.
83
+ 5. Do not modify tests merely to make failures disappear.
84
+
85
+ ### Verification
86
+ - Run targeted tests during iteration to get fast feedback.
87
+ - Run the broader suite (the project's actual test command) before completion.
@@ -0,0 +1,75 @@
1
+ ---
2
+ name: nextjs
3
+ description: Next.js App Router, Pages Router, Server/Client components, routing, and data fetching.
4
+ category: framework
5
+ version: 2.1.0
6
+ ---
7
+
8
+ ## When to use
9
+
10
+ - building Next.js pages or components
11
+ - authoring Server/Client components
12
+ - Next.js routing and data fetching
13
+ - Next.js API routes
14
+
15
+ ## Instructions
16
+
17
+ ### Project Detection & Existing Rules
18
+ - **Inspect package.json**: Identify Next.js version (e.g. 13, 14, 15).
19
+ - **Determine Router**: Check if the project uses App Router (`app/`) or Pages Router (`pages/`). **Never assume**. Do not force App Router patterns onto a Pages Router project.
20
+ - **Follow existing patterns**: Follow existing routing, data fetching, and component conventions unless explicitly requested otherwise.
21
+
22
+ ### Core Mental Model
23
+ - Server vs Client execution: Understand where code runs (Server Components, Client Components, SSR, SSG).
24
+ - Routing is filesystem-based.
25
+ - Layouts wrap pages and preserve state across navigations.
26
+ - Data fetching happens at the server when possible for performance.
27
+
28
+ ### Server / Client Boundary (App Router)
29
+ - React Server Components are the default. They run only on the server, have access to backend resources, and send zero JS to the client.
30
+ - Client Components (`'use client'`) are needed for browser APIs, client state (`useState`), event handlers (`onClick`), and client-only hooks (`useEffect`).
31
+ - **Do not automatically add "use client"** everywhere. Keep Client Components as small as practical and push them down the tree to the leaf interactive elements.
32
+
33
+ ### Routing
34
+ - **App Router**: Organise by folders (`app/dashboard/page.tsx`). Utilize `layout.tsx`, `loading.tsx`, `error.tsx`, and `not-found.tsx`.
35
+ - **Pages Router**: Organise by files (`pages/dashboard.tsx`). Utilize `_app.tsx`, `_document.tsx`.
36
+ - Respect dynamic segments and route structure conventions.
37
+
38
+ ### Data
39
+ - Prefer server-side data loading.
40
+ - Use client-side fetching (e.g., SWR, React Query, or `useEffect`) only where appropriate.
41
+ - Manage loading and error states gracefully.
42
+ - Understand caching considerations (e.g. `fetch` cache options in App Router).
43
+ - Do not prescribe a single data library unless already established.
44
+
45
+ ### Metadata / Assets
46
+ - Use the Next.js Metadata API for head tags and SEO (App Router) or `next/head` (Pages Router).
47
+ - Optimize images using `next/image`.
48
+ - Optimize fonts using `next/font`.
49
+ - Handle static assets correctly from the `public/` folder.
50
+
51
+ ### Common Failure Modes
52
+ - **Unnecessary client boundaries**: Wrapping an entire page in `'use client'` instead of just the interactive leaf nodes.
53
+ - **Server/Client mismatch**: Hydration problems caused by rendering different content on the server vs client (e.g., using `window` directly in render).
54
+ - **Incorrect data-fetching assumptions**: Mixing Pages Router data fetching (`getServerSideProps`) in App Router components.
55
+ - **Caching surprises**: Next.js App Router aggressively caches `fetch`; beware of stale data.
56
+ - **Route structure mistakes**: Placing components in the `pages/` directory instead of standard directories, causing accidental route creation (Pages Router).
57
+
58
+ ## Anti-Patterns
59
+
60
+ - **Using browser APIs in Server Components**
61
+ - *What*: Calling `window.localStorage` inside a Server Component.
62
+ - *Why*: Server Components run in Node.js/Edge, where `window` or `document` do not exist, causing crashes.
63
+ - *Instead*: Move the logic requiring browser APIs to a Client Component or use a `useEffect` inside a Client Component.
64
+
65
+ ## Workflow
66
+
67
+ ### Debugging
68
+ - Check if an error happens on the Server or Client.
69
+ - Inspect network tabs for hydration errors.
70
+ - Verify Next.js caching headers and tags if data is stale.
71
+
72
+ ### Verification
73
+ - Inspect the actual Next.js version.
74
+ - Typecheck the codebase (`tsc --noEmit`).
75
+ - Run project build and tests.