contextos-agents 2.1.0 → 2.1.1

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 (191) hide show
  1. package/.agents/adapters/aider/export.js +2 -2
  2. package/.agents/adapters/claude/export.js +53 -2
  3. package/.agents/adapters/drift-detector.js +6 -3
  4. package/.agents/adapters/pure-compiler.js +18 -6
  5. package/.agents/ctx.js +4 -4
  6. package/.agents/plugins.js +100 -4
  7. package/.agents/profiles.js +32 -11
  8. package/README.md +2 -2
  9. package/bin/commands/hook.js +50 -12
  10. package/bin/commands/scan.js +10 -3
  11. package/bin/index.js +8 -2
  12. package/bin/lib/git-snapshot.js +70 -43
  13. package/bin/lib/scan.js +108 -27
  14. package/catalog/skills/adapters/EXAMPLES.md +19 -0
  15. package/catalog/skills/adapters/SKILL.md +101 -0
  16. package/catalog/skills/adapters/TROUBLESHOOTING.md +7 -0
  17. package/catalog/skills/adapters/VALIDATION.json +12 -0
  18. package/catalog/skills/adapters/skill.yaml +13 -0
  19. package/catalog/skills/api-design/EXAMPLES.md +91 -0
  20. package/catalog/skills/api-design/SKILL.md +63 -0
  21. package/catalog/skills/api-design/TROUBLESHOOTING.md +54 -0
  22. package/catalog/skills/api-design/VALIDATION.json +11 -0
  23. package/catalog/skills/api-design/skill.yaml +14 -0
  24. package/catalog/skills/architecture-diagrams/SKILL.md +108 -0
  25. package/catalog/skills/architecture-diagrams/VALIDATION.json +12 -0
  26. package/catalog/skills/architecture-diagrams/skill.yaml +9 -0
  27. package/catalog/skills/brutalist-design/EXAMPLES.md +59 -0
  28. package/catalog/skills/brutalist-design/SKILL.md +150 -0
  29. package/catalog/skills/brutalist-design/VALIDATION.json +12 -0
  30. package/catalog/skills/brutalist-design/skill.yaml +10 -0
  31. package/catalog/skills/ci-cd/EXAMPLES.md +79 -0
  32. package/catalog/skills/ci-cd/SKILL.md +69 -0
  33. package/catalog/skills/ci-cd/TROUBLESHOOTING.md +52 -0
  34. package/catalog/skills/ci-cd/VALIDATION.json +11 -0
  35. package/catalog/skills/ci-cd/skill.yaml +13 -0
  36. package/catalog/skills/database/EXAMPLES.md +74 -0
  37. package/catalog/skills/database/SKILL.md +101 -0
  38. package/catalog/skills/database/TROUBLESHOOTING.md +18 -0
  39. package/catalog/skills/database/VALIDATION.json +11 -0
  40. package/catalog/skills/database/skill.yaml +14 -0
  41. package/catalog/skills/ddd/EXAMPLES.md +42 -0
  42. package/catalog/skills/ddd/SKILL.md +247 -0
  43. package/catalog/skills/ddd/TROUBLESHOOTING.md +19 -0
  44. package/catalog/skills/ddd/VALIDATION.json +12 -0
  45. package/catalog/skills/ddd/skill.yaml +14 -0
  46. package/catalog/skills/decisions/EXAMPLES.md +35 -0
  47. package/catalog/skills/decisions/SKILL.md +90 -0
  48. package/catalog/skills/decisions/TROUBLESHOOTING.md +13 -0
  49. package/catalog/skills/decisions/VALIDATION.json +12 -0
  50. package/catalog/skills/decisions/skill.yaml +13 -0
  51. package/catalog/skills/docker/EXAMPLES.md +56 -0
  52. package/catalog/skills/docker/SKILL.md +169 -0
  53. package/catalog/skills/docker/TROUBLESHOOTING.md +18 -0
  54. package/catalog/skills/docker/VALIDATION.json +11 -0
  55. package/catalog/skills/docker/skill.yaml +13 -0
  56. package/catalog/skills/fastapi/EXAMPLES.md +36 -0
  57. package/catalog/skills/fastapi/SKILL.md +171 -0
  58. package/catalog/skills/fastapi/TROUBLESHOOTING.md +19 -0
  59. package/catalog/skills/fastapi/VALIDATION.json +12 -0
  60. package/catalog/skills/fastapi/skill.yaml +14 -0
  61. package/catalog/skills/generators/EXAMPLES.md +19 -0
  62. package/catalog/skills/generators/SKILL.md +110 -0
  63. package/catalog/skills/generators/TROUBLESHOOTING.md +7 -0
  64. package/catalog/skills/generators/VALIDATION.json +12 -0
  65. package/catalog/skills/generators/skill.yaml +22 -0
  66. package/catalog/skills/generators/templates/API.md +77 -0
  67. package/catalog/skills/generators/templates/ARCHITECTURE.md +70 -0
  68. package/catalog/skills/generators/templates/DATABASE.md +42 -0
  69. package/catalog/skills/generators/templates/DECISION.md +46 -0
  70. package/catalog/skills/generators/templates/PRD.md +67 -0
  71. package/catalog/skills/generators/templates/PROJECT_GRAPH.md +56 -0
  72. package/catalog/skills/generators/templates/ROADMAP.md +51 -0
  73. package/catalog/skills/generators/templates/TASKS.md +43 -0
  74. package/catalog/skills/generators/templates/UI.md +73 -0
  75. package/catalog/skills/graphify/EXAMPLES.md +73 -0
  76. package/catalog/skills/graphify/SKILL.md +130 -0
  77. package/catalog/skills/graphify/VALIDATION.json +12 -0
  78. package/catalog/skills/graphify/skill.yaml +13 -0
  79. package/catalog/skills/impeccable-design/EXAMPLES.md +26 -0
  80. package/catalog/skills/impeccable-design/SKILL.md +201 -0
  81. package/catalog/skills/impeccable-design/TROUBLESHOOTING.md +19 -0
  82. package/catalog/skills/impeccable-design/VALIDATION.json +12 -0
  83. package/catalog/skills/impeccable-design/skill.yaml +15 -0
  84. package/catalog/skills/interview-me/SKILL.md +97 -0
  85. package/catalog/skills/interview-me/VALIDATION.json +12 -0
  86. package/catalog/skills/interview-me/skill.yaml +9 -0
  87. package/catalog/skills/microservices/EXAMPLES.md +38 -0
  88. package/catalog/skills/microservices/SKILL.md +164 -0
  89. package/catalog/skills/microservices/TROUBLESHOOTING.md +19 -0
  90. package/catalog/skills/microservices/VALIDATION.json +12 -0
  91. package/catalog/skills/microservices/skill.yaml +14 -0
  92. package/catalog/skills/minimalist-design/EXAMPLES.md +58 -0
  93. package/catalog/skills/minimalist-design/SKILL.md +113 -0
  94. package/catalog/skills/minimalist-design/VALIDATION.json +12 -0
  95. package/catalog/skills/minimalist-design/skill.yaml +10 -0
  96. package/catalog/skills/nestjs/EXAMPLES.md +40 -0
  97. package/catalog/skills/nestjs/SKILL.md +139 -0
  98. package/catalog/skills/nestjs/TROUBLESHOOTING.md +19 -0
  99. package/catalog/skills/nestjs/VALIDATION.json +12 -0
  100. package/catalog/skills/nestjs/skill.yaml +14 -0
  101. package/catalog/skills/nextjs/EXAMPLES.md +40 -0
  102. package/catalog/skills/nextjs/SKILL.md +163 -0
  103. package/catalog/skills/nextjs/TROUBLESHOOTING.md +19 -0
  104. package/catalog/skills/nextjs/VALIDATION.json +12 -0
  105. package/catalog/skills/nextjs/skill.yaml +14 -0
  106. package/catalog/skills/node/EXAMPLES.md +80 -0
  107. package/catalog/skills/node/SKILL.md +128 -0
  108. package/catalog/skills/node/TROUBLESHOOTING.md +19 -0
  109. package/catalog/skills/node/VALIDATION.json +12 -0
  110. package/catalog/skills/node/skill.yaml +14 -0
  111. package/catalog/skills/performance/EXAMPLES.md +30 -0
  112. package/catalog/skills/performance/SKILL.md +75 -0
  113. package/catalog/skills/performance/TROUBLESHOOTING.md +19 -0
  114. package/catalog/skills/performance/VALIDATION.json +12 -0
  115. package/catalog/skills/performance/skill.yaml +14 -0
  116. package/catalog/skills/react/EXAMPLES.md +79 -0
  117. package/catalog/skills/react/SKILL.md +132 -0
  118. package/catalog/skills/react/TROUBLESHOOTING.md +19 -0
  119. package/catalog/skills/react/VALIDATION.json +12 -0
  120. package/catalog/skills/react/skill.yaml +14 -0
  121. package/catalog/skills/react-best-practices/SKILL.md +158 -0
  122. package/catalog/skills/react-best-practices/VALIDATION.json +12 -0
  123. package/catalog/skills/react-best-practices/skill.yaml +13 -0
  124. package/catalog/skills/redesign-audit/SKILL.md +117 -0
  125. package/catalog/skills/redesign-audit/VALIDATION.json +12 -0
  126. package/catalog/skills/redesign-audit/skill.yaml +9 -0
  127. package/catalog/skills/security-audit/EXAMPLES.md +79 -0
  128. package/catalog/skills/security-audit/SKILL.md +91 -0
  129. package/catalog/skills/security-audit/TROUBLESHOOTING.md +46 -0
  130. package/catalog/skills/security-audit/VALIDATION.json +11 -0
  131. package/catalog/skills/security-audit/skill.yaml +14 -0
  132. package/catalog/skills/soft-design/EXAMPLES.md +51 -0
  133. package/catalog/skills/soft-design/SKILL.md +108 -0
  134. package/catalog/skills/soft-design/VALIDATION.json +12 -0
  135. package/catalog/skills/soft-design/skill.yaml +10 -0
  136. package/catalog/skills/state-management/EXAMPLES.md +56 -0
  137. package/catalog/skills/state-management/SKILL.md +168 -0
  138. package/catalog/skills/state-management/TROUBLESHOOTING.md +18 -0
  139. package/catalog/skills/state-management/VALIDATION.json +11 -0
  140. package/catalog/skills/state-management/skill.yaml +14 -0
  141. package/catalog/skills/subagent-orchestrator/SKILL.md +117 -0
  142. package/catalog/skills/subagent-orchestrator/VALIDATION.json +12 -0
  143. package/catalog/skills/subagent-orchestrator/skill.yaml +9 -0
  144. package/catalog/skills/system-design/EXAMPLES.md +75 -0
  145. package/catalog/skills/system-design/SKILL.md +419 -0
  146. package/catalog/skills/system-design/TROUBLESHOOTING.md +19 -0
  147. package/catalog/skills/system-design/VALIDATION.json +12 -0
  148. package/catalog/skills/system-design/skill.yaml +14 -0
  149. package/catalog/skills/terraform/EXAMPLES.md +74 -0
  150. package/catalog/skills/terraform/SKILL.md +55 -0
  151. package/catalog/skills/terraform/TROUBLESHOOTING.md +53 -0
  152. package/catalog/skills/terraform/VALIDATION.json +11 -0
  153. package/catalog/skills/terraform/skill.yaml +14 -0
  154. package/catalog/skills/testing/EXAMPLES.md +122 -0
  155. package/catalog/skills/testing/SKILL.md +70 -0
  156. package/catalog/skills/testing/TROUBLESHOOTING.md +18 -0
  157. package/catalog/skills/testing/VALIDATION.json +11 -0
  158. package/catalog/skills/testing/skill.yaml +14 -0
  159. package/catalog/skills/typescript/EXAMPLES.md +64 -0
  160. package/catalog/skills/typescript/SKILL.md +112 -0
  161. package/catalog/skills/typescript/TROUBLESHOOTING.md +19 -0
  162. package/catalog/skills/typescript/VALIDATION.json +12 -0
  163. package/catalog/skills/typescript/skill.yaml +14 -0
  164. package/catalog/skills/ui-design/EXAMPLES.md +21 -0
  165. package/catalog/skills/ui-design/SKILL.md +124 -0
  166. package/catalog/skills/ui-design/TROUBLESHOOTING.md +19 -0
  167. package/catalog/skills/ui-design/VALIDATION.json +12 -0
  168. package/catalog/skills/ui-design/skill.yaml +16 -0
  169. package/catalog/skills/ui-ux-pro/EXAMPLES.md +62 -0
  170. package/catalog/skills/ui-ux-pro/SKILL.md +418 -0
  171. package/catalog/skills/ui-ux-pro/TROUBLESHOOTING.md +19 -0
  172. package/catalog/skills/ui-ux-pro/VALIDATION.json +12 -0
  173. package/catalog/skills/ui-ux-pro/skill.yaml +14 -0
  174. package/catalog/skills/ux-design/EXAMPLES.md +36 -0
  175. package/catalog/skills/ux-design/SKILL.md +116 -0
  176. package/catalog/skills/ux-design/TROUBLESHOOTING.md +19 -0
  177. package/catalog/skills/ux-design/VALIDATION.json +12 -0
  178. package/catalog/skills/ux-design/skill.yaml +16 -0
  179. package/catalog/skills/vercel-optimize/SKILL.md +83 -0
  180. package/catalog/skills/vercel-optimize/VALIDATION.json +12 -0
  181. package/catalog/skills/vercel-optimize/scripts/collect-signals.mjs +131 -0
  182. package/catalog/skills/vercel-optimize/scripts/gate-investigations.mjs +142 -0
  183. package/catalog/skills/vercel-optimize/scripts/merge-signals.mjs +143 -0
  184. package/catalog/skills/vercel-optimize/scripts/scan-codebase.mjs +174 -0
  185. package/catalog/skills/vercel-optimize/skill.yaml +15 -0
  186. package/catalog/skills/web-accessibility/EXAMPLES.md +39 -0
  187. package/catalog/skills/web-accessibility/SKILL.md +151 -0
  188. package/catalog/skills/web-accessibility/TROUBLESHOOTING.md +19 -0
  189. package/catalog/skills/web-accessibility/VALIDATION.json +12 -0
  190. package/catalog/skills/web-accessibility/skill.yaml +14 -0
  191. package/package.json +3 -2
@@ -0,0 +1,79 @@
1
+ # React Examples - Anti-patterns vs ContextOS Standard
2
+
3
+ ## Example 1: Derived State vs. useEffect
4
+
5
+ ### Anti-pattern: Anti-pattern (Redundant state + extra render with useEffect)
6
+
7
+ ```tsx
8
+ // BAD: causes an unnecessary extra render cycle and potential state desync
9
+ function OrderSummary({ items }: { items: CartItem[] }) {
10
+ const [total, setTotal] = useState(0);
11
+
12
+ useEffect(() => {
13
+ const calculated = items.reduce((sum, item) => sum + item.price * item.quantity, 0);
14
+ setTotal(calculated);
15
+ }, [items]);
16
+
17
+ return <div>Total: ${total}</div>;
18
+ }
19
+ ```
20
+
21
+ ### Best practice: ContextOS Standard (Inline derived calculation / useMemo)
22
+
23
+ ```tsx
24
+ // GOOD: calculated instantly during render with zero extra render pass
25
+ function OrderSummary({ items }: { items: CartItem[] }) {
26
+ const total = useMemo(
27
+ () => items.reduce((sum, item) => sum + item.price * item.quantity, 0),
28
+ [items]
29
+ );
30
+
31
+ return <div>Total: ${total.toFixed(2)}</div>;
32
+ }
33
+ ```
34
+
35
+ ---
36
+
37
+ ## Example 2: Custom Hook Encapsulation
38
+
39
+ ### Anti-pattern: Anti-pattern (Scattered listener logic inside component)
40
+
41
+ ```tsx
42
+ // BAD: window listener logic cluttering UI component
43
+ function NavHeader() {
44
+ const [isScrolled, setIsScrolled] = useState(false);
45
+ useEffect(() => {
46
+ const handleScroll = () => setIsScrolled(window.scrollY > 50);
47
+ window.addEventListener('scroll', handleScroll);
48
+ return () => window.removeEventListener('scroll', handleScroll);
49
+ }, []);
50
+ return <header className={isScrolled ? 'scrolled' : ''}>Header</header>;
51
+ }
52
+ ```
53
+
54
+ ### Best practice: ContextOS Standard (Reusable Custom Hook)
55
+
56
+ ```tsx
57
+ // GOOD: extracted into a reusable, testable custom hook
58
+ export function useScrollThreshold(threshold = 50): boolean {
59
+ const [isPassed, setIsPassed] = useState(() => typeof window !== 'undefined' && window.scrollY > threshold);
60
+
61
+ useEffect(() => {
62
+ let ticking = false;
63
+ const handleScroll = () => {
64
+ if (!ticking) {
65
+ window.requestAnimationFrame(() => {
66
+ setIsPassed(window.scrollY > threshold);
67
+ ticking = false;
68
+ });
69
+ ticking = true;
70
+ }
71
+ };
72
+
73
+ window.addEventListener('scroll', handleScroll, { passive: true });
74
+ return () => window.removeEventListener('scroll', handleScroll);
75
+ }, [threshold]);
76
+
77
+ return isPassed;
78
+ }
79
+ ```
@@ -0,0 +1,132 @@
1
+ ---
2
+ name: React
3
+ description: >
4
+ ContextOS skill for modern React (v18/v19), component architecture, state colocation, render optimization, and Vercel performance rules.
5
+ ---
6
+
7
+ # React Engineering & Performance Best Practices
8
+
9
+ ## Overview
10
+
11
+ Enforces declarative, component-driven UI architecture with optimal re-render cycles, state colocation, responsive optimistic updates, and robust accessibility standards.
12
+
13
+ ## When to Use
14
+
15
+ Activate whenever creating, refactoring, or optimizing React functional components, custom hooks, context providers, or UI interaction states.
16
+
17
+ ## Negative Constraints (What NOT to Do)
18
+
19
+ 1. **NEVER use `useEffect` to synchronize or compute derived state**: Calculate derived state inline during render. Use `useMemo` only for computationally intensive derivations.
20
+ 2. **NEVER use array indices as `key` props on dynamic or reorderable lists**: Always use stable, unique entity identifiers (`item.id`).
21
+ 3. **NEVER mutate React state directly**: Always return new immutable references (`[...prev, newItem]` or `{ ...prev, key: value }`).
22
+ 4. **NEVER declare subcomponents inside the render body of parent components**: Declare components at module scope or in dedicated files to prevent DOM node remounting and lost focus state.
23
+ 5. **NEVER create memory leaks in `useEffect`**: Always provide clean-up functions for event listeners, `AbortController`, timers, and websocket subscriptions.
24
+ 6. **NEVER lift state higher than necessary**: Colocate state to the nearest common ancestor or leaf component to prevent wasteful re-renders of unrelated subtrees.
25
+
26
+ ## Rules & Patterns
27
+
28
+ ### 1. State Colocation & Re-render Optimization
29
+
30
+ - **State Colocation**: Keep state as close as possible to the components that consume it.
31
+ - **Composition to Prevent Re-renders**: Pass expensive static subtrees as `children` to wrapper components holding state so the children do not re-render when the wrapper updates.
32
+
33
+ ```tsx
34
+ export function ExpandableCard({ title, children }: { title: string; children: React.ReactNode }) {
35
+ const [isOpen, setIsOpen] = useState(false);
36
+
37
+ return (
38
+ <div className="rounded-xl border p-4">
39
+ <button
40
+ type="button"
41
+ onClick={() => setIsOpen(v => !v)}
42
+ className="flex w-full justify-between font-semibold"
43
+ aria-expanded={isOpen}
44
+ >
45
+ <span>{title}</span>
46
+ <span>{isOpen ? '−' : '+'}</span>
47
+ </button>
48
+ {isOpen && <div className="mt-3 pt-3 border-t">{children}</div>}
49
+ </div>
50
+ );
51
+ }
52
+ ```
53
+
54
+ ### 2. Optimistic UI Updates & Concurrent Actions (`useOptimistic`, `useTransition`)
55
+
56
+ - Provide instantaneous visual feedback for user actions without waiting for server network roundtrips.
57
+
58
+ ```tsx
59
+ import { useOptimistic, useTransition } from 'react';
60
+
61
+ export function TodoList({ todos, onAdd }: { todos: Todo[]; onAdd: (text: string) => Promise<void> }) {
62
+ const [isPending, startTransition] = useTransition();
63
+ const [optimisticTodos, addOptimisticTodo] = useOptimistic(
64
+ todos,
65
+ (state, newText: string) => [...state, { id: 'temp-' + Date.now(), text: newText, isPending: true }]
66
+ );
67
+
68
+ const handleAction = async (formData: FormData) => {
69
+ const text = formData.get('todo') as string;
70
+ if (!text?.trim()) return;
71
+
72
+ startTransition(async () => {
73
+ addOptimisticTodo(text);
74
+ await onAdd(text);
75
+ });
76
+ };
77
+
78
+ return (
79
+ <form action={handleAction} className="space-y-4">
80
+ <input name="todo" placeholder="Add a new task..." className="border p-2 rounded" />
81
+ <button type="submit" disabled={isPending} className="bg-primary text-white px-4 py-2 rounded">
82
+ {isPending ? 'Saving...' : 'Add'}
83
+ </button>
84
+ <ul className="divide-y">
85
+ {optimisticTodos.map(todo => (
86
+ <li key={todo.id} className={todo.isPending ? 'opacity-50 italic' : ''}>
87
+ {todo.text}
88
+ </li>
89
+ ))}
90
+ </ul>
91
+ </form>
92
+ );
93
+ }
94
+ ```
95
+
96
+ ### 3. Derived State vs. Effects Anti-Pattern
97
+
98
+ ```tsx
99
+ // [GOOD] Computed directly during render (or memoized if expensive)
100
+ function SearchResults({ query, items }: { query: string; items: Item[] }) {
101
+ const filtered = useMemo(() => {
102
+ const q = query.trim().toLowerCase();
103
+ if (!q) return items;
104
+ return items.filter(i => i.title.toLowerCase().includes(q));
105
+ }, [query, items]);
106
+
107
+ return <List items={filtered} />;
108
+ }
109
+ ```
110
+
111
+ ## Code Examples
112
+
113
+ See `EXAMPLES.md` for detailed code examples and hook implementations.
114
+
115
+ ## Validation Checklist
116
+
117
+ - [ ] Zero `useEffect` hooks used for derived calculations.
118
+ - [ ] Every list mapping has a unique, non-index entity ID key.
119
+ - [ ] Subcomponents declared in parent render functions are extracted to top-level scope.
120
+ - [ ] Effects with event listeners, timers, or abortable requests include clean-up returns.
121
+ - [ ] Reusable components are composed cleanly via `children` or render props.
122
+
123
+ ## Common Mistakes
124
+
125
+ - Setting state inside `useEffect` based on prop changes rather than deriving values inline.
126
+ - Declaring nested components within component bodies.
127
+ - Using index keys causing input focus loss or animations breaking on list mutations.
128
+
129
+ ## Integration Notes
130
+
131
+ - Pairs with `typescript` for type safety on props, generics, and ref forwarding.
132
+ - Pairs with `ui-ux-pro` and `web-accessibility` for UI tokens and ARIA standards.
@@ -0,0 +1,19 @@
1
+ # react Troubleshooting & Common Mistakes
2
+
3
+ ## 1. Infinite Render Loops in useEffect
4
+
5
+ - **Symptom**: Browser freezes, "Maximum update depth exceeded" error.
6
+ - **Root Cause**: Creating new object or array literals inside component body and passing them to useEffect dependency array.
7
+ - **Fix**: Colocate state, compute derived state during render without useEffect, or use primitive dependency values.
8
+
9
+ ## 2. Stale Closures in Callbacks
10
+
11
+ - **Symptom**: Event handler or setTimeout accesses outdated state values.
12
+ - **Root Cause**: Callback closing over initial state without updated dependency.
13
+ - **Fix**: Use functional state updates (`setCount(c => c + 1)`) or `useRef` for mutable references.
14
+
15
+ ## 3. Prop Drilling vs Context Performance
16
+
17
+ - **Symptom**: Changing a small state variable causes the entire component tree to re-render.
18
+ - **Root Cause**: Storing rapidly changing state in a single monolithic React Context.
19
+ - **Fix**: Split contexts by domain or migrate client UI state to Zustand with granular selectors.
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "type": "object",
4
+ "properties": {
5
+ "rules_followed": {
6
+ "type": "boolean"
7
+ }
8
+ },
9
+ "required": [
10
+ "rules_followed"
11
+ ]
12
+ }
@@ -0,0 +1,14 @@
1
+ schemaVersion: 2
2
+ id: react
3
+ name: React
4
+ category: frontend
5
+ type: instruction-only
6
+ requires: [typescript]
7
+ optional: [tailwind, react-query, zustand, next-auth]
8
+ conflicts: [vue, angular, svelte]
9
+ weight: 8
10
+ resources:
11
+ - EXAMPLES.md
12
+ - SKILL.md
13
+ - TROUBLESHOOTING.md
14
+ - VALIDATION.json
@@ -0,0 +1,158 @@
1
+ ---
2
+ name: vercel-react-best-practices
3
+ description: React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.
4
+ license: MIT
5
+ metadata:
6
+ author: vercel
7
+ version: "1.0.0"
8
+ ---
9
+
10
+ # Vercel React Best Practices
11
+
12
+ ## Overview
13
+
14
+ Comprehensive performance optimization guide for React and Next.js applications, maintained by Vercel. Contains 70 rules across 8 categories, prioritized by impact to guide automated refactoring, code generation, and production review.
15
+
16
+ ## When to Use
17
+
18
+ - When authoring new React functional components or Next.js App Router pages.
19
+ - When implementing data fetching (client or server-side Server Actions, RSC).
20
+ - When reviewing pull requests for rendering bottlenecks or memory leaks.
21
+ - When optimizing bundle size, eliminating network waterfalls, or improving Core Web Vitals (LCP, INP, CLS).
22
+
23
+ ## Rules & Patterns
24
+
25
+ ### Rule Categories by Priority
26
+
27
+ | Priority | Category | Impact | Prefix |
28
+ |----------|----------|--------|--------|
29
+ | 1 | Eliminating Waterfalls | CRITICAL | `async-` |
30
+ | 2 | Bundle Size Optimization | CRITICAL | `bundle-` |
31
+ | 3 | Server-Side Performance | HIGH | `server-` |
32
+ | 4 | Client-Side Data Fetching | MEDIUM-HIGH | `client-` |
33
+ | 5 | Re-render Optimization | MEDIUM | `rerender-` |
34
+ | 6 | Rendering Performance | MEDIUM | `rendering-` |
35
+ | 7 | JavaScript Performance | LOW-MEDIUM | `js-` |
36
+ | 8 | Advanced Patterns | LOW | `advanced-` |
37
+
38
+ ### 1. Eliminating Waterfalls (CRITICAL)
39
+
40
+ - `async-cheap-condition-before-await` - Check cheap sync conditions before awaiting flags or remote values.
41
+ - `async-defer-await` - Move await into branches where actually used.
42
+ - `async-parallel` - Use `Promise.all()` for independent asynchronous operations.
43
+ - `async-dependencies` - Use better-all for partial dependencies.
44
+ - `async-api-routes` - Start promises early, await late in API routes.
45
+ - `async-suspense-boundaries` - Use Suspense to stream content progressively.
46
+
47
+ ### 2. Bundle Size Optimization (CRITICAL)
48
+
49
+ - `bundle-barrel-imports` - Import directly from specific modules, avoid broad barrel files (`index.ts`).
50
+ - `bundle-analyzable-paths` - Prefer statically analyzable import paths to avoid bloated traces.
51
+ - `bundle-dynamic-imports` - Use `next/dynamic` or `React.lazy()` for heavy interactive components.
52
+ - `bundle-defer-third-party` - Load analytics and logging scripts after hydration.
53
+ - `bundle-conditional` - Load modules only when feature flags or user actions require them.
54
+ - `bundle-preload` - Preload assets on hover or focus for perceived instant navigation.
55
+
56
+ ### 3. Server-Side Performance (HIGH)
57
+
58
+ - `server-auth-actions` - Always authenticate server actions like API routes.
59
+ - `server-cache-react` - Use `React.cache()` for per-request deduplication.
60
+ - `server-cache-lru` - Use LRU cache for cross-request caching.
61
+ - `server-dedup-props` - Avoid duplicate serialization in RSC props.
62
+ - `server-hoist-static-io` - Hoist static I/O to module level.
63
+ - `server-no-shared-module-state` - Avoid module-level mutable request state in RSC/SSR.
64
+ - `server-serialization` - Minimize data passed across the server-client boundary.
65
+ - `server-parallel-fetching` - Restructure components to parallelize fetches.
66
+ - `server-after-nonblocking` - Use `after()` for non-blocking operations like analytics logging.
67
+
68
+ ### 4. Client-Side Data Fetching (MEDIUM-HIGH)
69
+
70
+ - `client-swr-dedup` - Use SWR or TanStack Query for automatic request deduplication.
71
+ - `client-event-listeners` - Deduplicate global event listeners.
72
+ - `client-passive-event-listeners` - Use passive listeners for scroll and touch.
73
+ - `client-localstorage-schema` - Version and minimize data stored in localStorage.
74
+
75
+ ### 5. Re-render Optimization (MEDIUM)
76
+
77
+ - `rerender-defer-reads` - Don't subscribe to state only used in callbacks.
78
+ - `rerender-memo` - Extract expensive work into memoized components.
79
+ - `rerender-memo-with-default-value` - Hoist default non-primitive props.
80
+ - `rerender-dependencies` - Use primitive dependencies in effects and callbacks.
81
+ - `rerender-derived-state` - Subscribe to derived booleans, not raw high-frequency values.
82
+ - `rerender-derived-state-no-effect` - Derive state during render, never in `useEffect`.
83
+ - `rerender-functional-setstate` - Use functional `setState` for stable callback references.
84
+ - `rerender-lazy-state-init` - Pass initializer functions to `useState` for expensive computations.
85
+ - `rerender-transitions` - Use `startTransition` for non-urgent state updates.
86
+ - `rerender-use-deferred-value` - Defer expensive renders to keep input responsive.
87
+ - `rerender-no-inline-components` - Never define subcomponents inside component render bodies.
88
+
89
+ ### 6. Rendering Performance (MEDIUM)
90
+
91
+ - `rendering-content-visibility` - Use `content-visibility: auto` for long offscreen lists.
92
+ - `rendering-hoist-jsx` - Extract static JSX elements outside components.
93
+ - `rendering-conditional-render` - Use ternary (`condition ? <Comp /> : null`), not `&&` to avoid 0 rendering.
94
+ - `rendering-usetransition-loading` - Prefer `useTransition` for loading state indicators.
95
+
96
+ ### 7. JavaScript Performance (LOW-MEDIUM)
97
+
98
+ - `js-index-maps` - Build `Map` for repeated lookups instead of repeated array searches.
99
+ - `js-cache-property-access` - Cache object properties in tight loops.
100
+ - `js-early-exit` - Return early from functions to avoid nested complexity.
101
+ - `js-hoist-regexp` - Hoist RegExp creation outside loops and functions.
102
+ - `js-set-map-lookups` - Use `Set` / `Map` for O(1) lookups.
103
+
104
+ ### 8. Advanced Patterns (LOW)
105
+
106
+ - `advanced-effect-event-deps` - Don't put `useEffectEvent` results in effect deps.
107
+ - `advanced-event-handler-refs` - Store event handlers in refs for stable listener attachments.
108
+ - `advanced-init-once` - Initialize app singletons once per lifecycle.
109
+ - `advanced-compound-components` - Use React Context with compound components for composable sub-parts instead of monolithic prop bags.
110
+ - `advanced-error-boundary-colocation` - Colocate Error Boundaries and Suspense boundaries close to the fault-prone tree, preserving the rest of the UI.
111
+
112
+ ## Code Examples
113
+
114
+
115
+ ```tsx
116
+ // [GOOD] Parallel server fetching without waterfall
117
+ import { cache } from 'react';
118
+
119
+ export const getUser = cache(async (id: string) => {
120
+ return db.user.findUnique({ where: { id } });
121
+ });
122
+
123
+ export default async function UserPage({ params }: { params: { id: string } }) {
124
+ // Parallel dispatch
125
+ const userPromise = getUser(params.id);
126
+ const postsPromise = getPosts(params.id);
127
+
128
+ const [user, posts] = await Promise.all([userPromise, postsPromise]);
129
+
130
+ return (
131
+ <main>
132
+ <h1>{user.name}</h1>
133
+ <PostList posts={posts} />
134
+ </main>
135
+ );
136
+ }
137
+ ```
138
+
139
+ ## Validation Checklist
140
+
141
+ - [ ] All independent async fetches use `Promise.all()` instead of sequential `await`.
142
+ - [ ] Direct imports used instead of barrel file imports for large libraries.
143
+ - [ ] No `useEffect` used for deriving computed state from props or state.
144
+ - [ ] Heavy interactive modals/drawers loaded dynamically via `next/dynamic`.
145
+ - [ ] Server actions perform authentication checks before data mutations.
146
+ - [ ] Zero subcomponents defined inside the body of parent components.
147
+
148
+ ## Common Mistakes
149
+
150
+ - Writing sequential `await fetchA(); await fetchB();` creating avoidable network waterfalls.
151
+ - Importing from package root barrel files triggering full bundle inclusion.
152
+ - Setting state inside `useEffect` in response to prop changes.
153
+ - Serializing full database models with sensitive or unused fields to Client Components.
154
+
155
+ ## Integration Notes
156
+
157
+ - Pairs with `react` and `nextjs` skills for idiomatic App Router patterns.
158
+ - Complements `performance` for Lighthouse and Core Web Vitals verification.
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "type": "object",
4
+ "properties": {
5
+ "rules_followed": {
6
+ "type": "boolean"
7
+ }
8
+ },
9
+ "required": [
10
+ "rules_followed"
11
+ ]
12
+ }
@@ -0,0 +1,13 @@
1
+ schemaVersion: 2
2
+ name: react-best-practices
3
+ category: frontend
4
+ type: instruction-only
5
+ description: React and Next.js performance optimization guidelines from Vercel Engineering.
6
+ version: 1.0.0
7
+ deprecated: true
8
+ canonical: react
9
+ requires:
10
+ - react
11
+ resources:
12
+ - SKILL.md
13
+ - VALIDATION.json
@@ -0,0 +1,117 @@
1
+ ---
2
+ name: redesign-existing-projects
3
+ description: Upgrades existing websites and apps to premium quality. Audits current design, identifies generic AI patterns, and applies high-end design standards without breaking functionality. Works with any CSS framework or vanilla CSS.
4
+ ---
5
+
6
+ # Redesign Skill & UI Audit
7
+
8
+ ## Overview
9
+
10
+ A systematic redesign and auditing protocol designed to elevate existing websites, dashboards, and web applications to world-class agency quality. It diagnoses and eradicates generic AI design fingerprints, sloppy typography, inconsistent palettes, and absent interaction states without breaking business logic or underlying component contracts.
11
+
12
+ ## When to Use
13
+
14
+ - When auditing an existing UI codebase for design quality, responsiveness, or accessibility.
15
+ - When modernizing a legacy application or uplifting generic templates.
16
+ - When tasked to "redesign", "clean up the layout", "audit UI", or "make it look expensive and modern".
17
+
18
+ ## Rules & Patterns
19
+
20
+ ### 1. Workflow: Scan → Diagnose → Fix
21
+
22
+ 1. **Scan:** Read the codebase. Identify the framework, styling method (Tailwind v3/v4, vanilla CSS, CSS Modules), and established design tokens.
23
+ 2. **Diagnose:** Run through the design audit categories. Catalog generic patterns, missing states, and optical alignment flaws.
24
+ 3. **Fix:** Apply surgical, targeted upgrades working within the existing stack. Do not rewrite from scratch.
25
+
26
+ ### 2. Design Audit Categories
27
+
28
+ #### Typography
29
+
30
+ - **Replace Browser Defaults:** Swap generic `Inter`, `Roboto`, or system fonts with expressive typefaces (`Geist`, `Outfit`, `Cabinet Grotesk`, `Satoshi`).
31
+ - **Presence & Scale:** Increase display text size, tighten letter-spacing (`-0.02em` to `-0.04em`), reduce line-height on headlines.
32
+ - **Reading Comfort:** Limit body text to 65 characters per line (`max-w-prose`), increase line-height to 1.6.
33
+ - **Figures:** Enable tabular figures (`font-variant-numeric: tabular-nums`) for numbers in tables and data readouts.
34
+ - **Orphan Prevention:** Apply `text-wrap: balance` on headlines and `text-wrap: pretty` on paragraphs.
35
+
36
+ #### Color and Surfaces
37
+
38
+ - **No Pure Black Backgrounds:** Replace `#000000` with tinted dark charcoal (`#0A0A0A`, `#121212`).
39
+ - **Desaturate Accents:** Keep accent saturation below 80% so it blends harmoniously with neutrals.
40
+ - **Single Accent Color:** Commit to one dominant accent hue; remove conflicting secondary tints.
41
+ - **Tinted Shadows:** Tint shadows to match the background hue rather than harsh black opacity.
42
+ - **Background Depth:** Prevent sterile flat sections by layering subtle noise overlays, ambient gradients, or masked imagery.
43
+
44
+ #### Layout and Space
45
+
46
+ - **Asymmetry & Bento Grids:** Break repetitive 3-column Bootstrap grids with asymmetrical spans or offset cards.
47
+ - **Mobile Viewport Bug Fix:** Never use `height: 100vh`; always use `min-height: 100dvh`.
48
+ - **Vertical Alignment:** Pin action buttons to the bottom of card groups (`mt-auto` or grid alignment) to maintain horizontal baseline harmony across differing text heights.
49
+ - **Optical Centering:** Adjust icons, badges, and play buttons optically by 1-2px rather than relying solely on pure mathematical centering.
50
+
51
+ #### Interactivity and States
52
+
53
+ - **Interactive Feedback:** Add 200-300ms transitions, distinct hover shifts, and physical active presses (`scale(0.98)`).
54
+ - **Visible Focus Rings:** Mandatory `:focus-visible` styling for keyboard navigation.
55
+ - **States Completeness:** Always provide designed skeleton loaders, empty states, and inline error messages.
56
+
57
+ #### Content & Code Quality
58
+
59
+ - **Eradicate AI Clichés:** Remove buzzwords ("Elevate", "Seamless", "Unleash", "Next-Gen") and placeholder latin text.
60
+ - **Semantic HTML:** Replace nested div containers with `<nav>`, `<main>`, `<article>`, `<section>`, `<aside>`.
61
+ - **Relative Units:** Use `rem`, `%`, and CSS Grid rather than hardcoded pixel widths.
62
+
63
+ ### 3. Fix Priority
64
+
65
+ 1. **Font Swap:** Biggest instant aesthetic elevation with lowest regression risk.
66
+ 2. **Palette Cleanup:** Eliminate clashing or oversaturated colors.
67
+ 3. **States & Feedback:** Add hover, active, focus, loading, and empty states.
68
+ 4. **Layout & Alignment:** Fix container widths, baseline alignment, and mobile viewport heights.
69
+ 5. **Component Polish:** Replace generic cards and accordion boxes with modern minimal equivalents.
70
+
71
+ ## Code Examples
72
+
73
+ ```tsx
74
+ // [BEFORE] Generic, misaligned card with generic shadow
75
+ <div className="bg-white border rounded shadow p-4">
76
+ <h2>{title}</h2>
77
+ <p>{desc}</p>
78
+ <button className="bg-blue-500 text-white p-2">Click</button>
79
+ </div>
80
+
81
+ // [AFTER] Polished card with optical baseline alignment, tinted surface, and micro-interaction
82
+ <div className="flex flex-col bg-[#FFFFFF] dark:bg-[#121212] border border-black/5 dark:border-white/10 rounded-2xl p-6 hover:shadow-[0_4px_20px_rgba(0,0,0,0.04)] transition-all duration-200">
83
+ <h3 className="font-semibold text-lg tracking-tight text-neutral-900 dark:text-neutral-100 text-balance mb-2">
84
+ {title}
85
+ </h3>
86
+ <p className="text-sm text-neutral-600 dark:text-neutral-400 leading-relaxed text-pretty mb-6">
87
+ {desc}
88
+ </p>
89
+ <button
90
+ type="button"
91
+ className="mt-auto inline-flex items-center justify-center font-medium text-sm px-4 py-2.5 rounded-xl bg-neutral-900 dark:bg-neutral-100 text-white dark:text-black hover:bg-neutral-800 active:scale-[0.98] transition-transform duration-150 focus-visible:ring-2 focus-visible:ring-neutral-400"
92
+ >
93
+ Continue
94
+ </button>
95
+ </div>
96
+ ```
97
+
98
+ ## Validation Checklist
99
+
100
+ - [ ] All headings have `text-wrap: balance` and appropriate negative letter tracking.
101
+ - [ ] No pure black `#000000` backgrounds or oversaturated accent colors (>80% saturation).
102
+ - [ ] All interactive elements include `:hover`, `:active`, and `:focus-visible` styles.
103
+ - [ ] Cards in side-by-side grids align primary CTA buttons along the same bottom baseline.
104
+ - [ ] Viewport containers use `100dvh` instead of `100vh`.
105
+ - [ ] All lists, tables, and feeds have a designed empty state.
106
+
107
+ ## Common Mistakes
108
+
109
+ - Rewriting components from scratch and breaking existing prop contracts or unit tests.
110
+ - Forcing full-width sections without `max-w` constraints on ultra-wide screens.
111
+ - Leaving action buttons at random heights inside differing text content cards.
112
+ - Introducing external UI libraries without checking existing `package.json` dependencies.
113
+
114
+ ## Integration Notes
115
+
116
+ - Complements `impeccable-design` for hard 50-rule QA verification.
117
+ - Works alongside `ui-ux-pro` for token generation and color theory.
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "type": "object",
4
+ "properties": {
5
+ "rules_followed": {
6
+ "type": "boolean"
7
+ }
8
+ },
9
+ "required": [
10
+ "rules_followed"
11
+ ]
12
+ }
@@ -0,0 +1,9 @@
1
+ schemaVersion: 2
2
+ name: redesign-audit
3
+ category: design
4
+ type: instruction-only
5
+ description: Audits and upgrades existing web codebases with high-end typography, color, layout, and interaction polish.
6
+ version: 1.0.0
7
+ resources:
8
+ - SKILL.md
9
+ - VALIDATION.json
@@ -0,0 +1,79 @@
1
+ # Security Audit - Examples & Verification Scenarios
2
+
3
+ ## Example 1: Adversarial Validation of Path Traversal
4
+
5
+ ### Hunter Report (Initial Finding)
6
+ ```markdown
7
+ ID: CANDIDATE-01
8
+ Component: User Avatar Download
9
+ Location: src/routes/avatar.ts:18
10
+ Sink: fs.createReadStream(path.join(__dirname, '../../uploads', req.query.file))
11
+ Hypothesis: Attacker passes `?file=../../etc/passwd` to read arbitrary host files.
12
+ ```
13
+
14
+ ### Verifier Execution (Disproving Attempt)
15
+ The verifier inspects the middleware chain and creates an isolated reproduction test:
16
+ ```typescript
17
+ import { describe, it } from 'node:test';
18
+ import assert from 'node:assert/strict';
19
+ import path from 'node:path';
20
+
21
+ function resolveAvatarPath(baseDir: string, requestedFile: string): string {
22
+ const safePath = path.resolve(baseDir, requestedFile);
23
+ if (!safePath.startsWith(baseDir)) {
24
+ throw new Error('Access denied: directory traversal detected');
25
+ }
26
+ return safePath;
27
+ }
28
+
29
+ describe('Avatar Path Resolution', () => {
30
+ const uploadsDir = path.resolve('/var/app/uploads');
31
+
32
+ it('rejects traversal attempts escaping uploads root', () => {
33
+ assert.throws(
34
+ () => resolveAvatarPath(uploadsDir, '../../etc/passwd'),
35
+ /Access denied: directory traversal detected/
36
+ );
37
+ });
38
+
39
+ it('allows safe filenames inside uploads root', () => {
40
+ const resolved = resolveAvatarPath(uploadsDir, 'user-123.png');
41
+ assert.equal(resolved, path.join(uploadsDir, 'user-123.png'));
42
+ });
43
+ });
44
+ ```
45
+
46
+ ### Verifier Verdict
47
+ - If `resolveAvatarPath` was missing in source: Finding is **CONFIRMED** with source trace.
48
+ - If middleware sanitized input before the handler: Finding is **DISPROVEN** and logged as invalid candidate with reason.
49
+
50
+ ---
51
+
52
+ ## Example 2: Minimal Remediated Code Block
53
+
54
+ ```typescript
55
+ // Vulnerable:
56
+ // app.get('/files', (req, res) => {
57
+ // res.sendFile(path.join(PUBLIC_DIR, req.query.path as string));
58
+ // });
59
+
60
+ // Remediated (Surgical Blast Radius):
61
+ import path from 'node:path';
62
+
63
+ app.get('/files', (req, res) => {
64
+ const rawPath = String(req.query.path ?? '');
65
+ const normalizedPath = path.normalize(rawPath).replace(/^(\.\.[\/\\])+/, '');
66
+ const resolved = path.resolve(PUBLIC_DIR, normalizedPath);
67
+
68
+ if (!resolved.startsWith(PUBLIC_DIR)) {
69
+ return res.status(403).json({
70
+ error: {
71
+ code: 'FORBIDDEN',
72
+ message: 'Path traversal attempted'
73
+ }
74
+ });
75
+ }
76
+
77
+ res.sendFile(resolved);
78
+ });
79
+ ```