@ruyfranca/myskills 1.0.28 → 1.0.29

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.
@@ -0,0 +1,131 @@
1
+ ---
2
+ name: modern-javascript-patterns
3
+ description: "Master ES6+ features including async/await, destructuring, spread operators, arrow functions, promises, modules, iterators, generators, and functional programming patterns for writing clean, efficient code."
4
+ risk: unknown
5
+ source: community
6
+ date_added: "2026-02-27"
7
+ ---
8
+
9
+ # Modern JavaScript Patterns
10
+
11
+ Comprehensive guide for mastering modern JavaScript (ES6+) features, functional programming patterns, and best practices for writing clean, maintainable, and performant code.
12
+
13
+ ## Use this skill when
14
+
15
+ - Refactoring legacy JavaScript to modern syntax
16
+ - Implementing functional programming patterns
17
+ - Optimizing JavaScript performance
18
+ - Writing maintainable and readable code
19
+ - Working with asynchronous operations
20
+ - Building modern web applications
21
+ - Migrating from callbacks to Promises/async-await
22
+ - Implementing data transformation pipelines
23
+
24
+ ## Do not use this skill when
25
+
26
+ - The task is unrelated to modern javascript patterns
27
+ - You need a different domain or tool outside this scope
28
+
29
+ ## Instructions
30
+
31
+ - Clarify goals, constraints, and required inputs.
32
+ - Apply relevant best practices and validate outcomes.
33
+ - Provide actionable steps and verification.
34
+
35
+ ## Core Patterns
36
+
37
+ ### 1. Async/Await
38
+
39
+ ```javascript
40
+ // ✅ Modern async patterns
41
+ const fetchData = async (url) => {
42
+ const response = await fetch(url);
43
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
44
+ return response.json();
45
+ };
46
+
47
+ // Parallel execution
48
+ const [users, posts] = await Promise.all([fetchUsers(), fetchPosts()]);
49
+
50
+ // Error handling
51
+ const result = await fetchData(url).catch(err => ({ error: err.message }));
52
+ ```
53
+
54
+ ### 2. Destructuring & Spread
55
+
56
+ ```javascript
57
+ // Object destructuring with defaults
58
+ const { name = 'Anonymous', role = 'user', ...rest } = user;
59
+
60
+ // Array destructuring
61
+ const [first, second, ...remaining] = items;
62
+
63
+ // Function parameters
64
+ const greet = ({ name, greeting = 'Hello' }) => `${greeting}, ${name}!`;
65
+ ```
66
+
67
+ ### 3. Functional Patterns
68
+
69
+ ```javascript
70
+ // Immutable transformations
71
+ const updated = items.map(item => item.id === id ? { ...item, done: true } : item);
72
+ const active = items.filter(item => !item.done);
73
+ const total = items.reduce((sum, item) => sum + item.price, 0);
74
+
75
+ // Composition
76
+ const pipe = (...fns) => x => fns.reduce((v, f) => f(v), x);
77
+ const process = pipe(validate, normalize, format);
78
+ ```
79
+
80
+ ### 4. Modules (ESM)
81
+
82
+ ```javascript
83
+ // Named exports
84
+ export const add = (a, b) => a + b;
85
+ export const multiply = (a, b) => a * b;
86
+
87
+ // Dynamic import (lazy loading)
88
+ const module = await import('./heavy-module.js');
89
+ ```
90
+
91
+ ### 5. Generators & Iterators
92
+
93
+ ```javascript
94
+ function* range(start, end, step = 1) {
95
+ for (let i = start; i < end; i += step) yield i;
96
+ }
97
+
98
+ // Paginated data fetching
99
+ async function* paginate(fetchPage) {
100
+ let page = 1;
101
+ while (true) {
102
+ const data = await fetchPage(page++);
103
+ if (!data.length) break;
104
+ yield* data;
105
+ }
106
+ }
107
+ ```
108
+
109
+ ### 6. Proxy & Reflect
110
+
111
+ ```javascript
112
+ const handler = {
113
+ get(target, key) {
114
+ return key in target ? target[key] : `Property ${key} not found`;
115
+ },
116
+ set(target, key, value) {
117
+ if (typeof value !== 'string') throw new TypeError('Value must be string');
118
+ return Reflect.set(target, key, value);
119
+ }
120
+ };
121
+ ```
122
+
123
+ ## Anti-Patterns
124
+
125
+ | ❌ Avoid | ✅ Use Instead |
126
+ |---------|--------------|
127
+ | `var` | `const` / `let` |
128
+ | Callback hell | async/await |
129
+ | `arguments` object | Rest parameters |
130
+ | Mutating arrays | map/filter/spread |
131
+ | `eval()` | Template literals |
@@ -0,0 +1,91 @@
1
+ ---
2
+ name: monorepo-architect
3
+ description: "Expert in monorepo architecture, build systems, and dependency management at scale. Masters Nx, Turborepo, Bazel, and Lerna for efficient multi-project development."
4
+ risk: unknown
5
+ source: community
6
+ date_added: "2026-02-27"
7
+ ---
8
+
9
+ # Monorepo Architect
10
+
11
+ Expert in monorepo architecture, build systems, and dependency management at scale. Masters Nx, Turborepo, Bazel, and Lerna for efficient multi-project development. Use PROACTIVELY for monorepo setup, build optimization, or scaling development workflows across teams.
12
+
13
+ ## Use this skill when
14
+
15
+ - Setting up a new monorepo from scratch
16
+ - Migrating from polyrepo to monorepo
17
+ - Optimizing slow CI/CD pipelines
18
+ - Sharing code between multiple applications
19
+ - Managing dependencies across projects
20
+ - Implementing consistent tooling across teams
21
+
22
+ ## Do not use this skill when
23
+
24
+ - The task is unrelated to monorepo architect
25
+ - You need a different domain or tool outside this scope
26
+
27
+ ## Capabilities
28
+
29
+ - Monorepo tool selection (Nx, Turborepo, Bazel, Lerna)
30
+ - Workspace configuration and project structure
31
+ - Build caching (local and remote)
32
+ - Dependency graph management
33
+ - Affected/changed detection for CI optimization
34
+ - Code sharing and library extraction
35
+ - Task orchestration and parallelization
36
+
37
+ ## Tool Selection Guide
38
+
39
+ | Tool | Best For | Key Feature |
40
+ |------|----------|-------------|
41
+ | **Turborepo** | JS/TS projects, simple setup | Remote caching, fast incremental builds |
42
+ | **Nx** | Large teams, enterprise | Dependency graph, affected commands |
43
+ | **Bazel** | Polyglot, Google-scale | Hermetic builds, extreme scalability |
44
+ | **Lerna** | npm package publishing | Versioning/publishing automation |
45
+
46
+ ## Workflow
47
+
48
+ 1. Assess codebase size and team structure
49
+ 2. Select appropriate monorepo tooling
50
+ 3. Design workspace and project structure
51
+ 4. Configure build caching strategy
52
+ 5. Set up affected/changed detection
53
+ 6. Implement task pipelines
54
+ 7. Configure remote caching for CI
55
+ 8. Document conventions and workflows
56
+
57
+ ## Turborepo Example
58
+
59
+ ```json
60
+ // turbo.json
61
+ {
62
+ "$schema": "https://turbo.build/schema.json",
63
+ "tasks": {
64
+ "build": {
65
+ "dependsOn": ["^build"],
66
+ "outputs": [".next/**", "dist/**"]
67
+ },
68
+ "test": {
69
+ "dependsOn": ["build"],
70
+ "cache": false
71
+ },
72
+ "lint": {
73
+ "cache": true
74
+ }
75
+ },
76
+ "remoteCache": {
77
+ "enabled": true
78
+ }
79
+ }
80
+ ```
81
+
82
+ ## Best Practices
83
+
84
+ - Start with clear project boundaries
85
+ - Use consistent naming conventions
86
+ - Implement remote caching early
87
+ - Keep shared libraries focused
88
+ - Use tags for dependency constraints
89
+ - Automate dependency updates
90
+ - Document the dependency graph
91
+ - Set up code ownership rules
@@ -1,286 +1,133 @@
1
1
  ---
2
2
  name: react-best-practices
3
- description: React and Next.js performance optimization from Vercel Engineering. Use when building React components, optimizing performance, eliminating waterfalls, reducing bundle size, reviewing code for performance issues, or implementing server/client-side optimizations.
4
- allowed-tools: Read, Write, Edit, Glob, Grep, Bash
3
+ description: "React and Next.js performance optimization from Vercel Engineering. Use when building React components, optimizing performance, eliminating waterfalls, reducing bundle size, reviewing code for performance issues, or implementing server/client-side optimizations."
4
+ risk: unknown
5
+ source: community
6
+ date_added: "2026-02-27"
5
7
  ---
6
8
 
7
- # Next.js & React Performance Expert
9
+ # React Best Practices (Vercel)
8
10
 
9
- > **From Vercel Engineering** - 57 optimization rules prioritized by impact
10
- > **Philosophy:** Eliminate waterfalls first, optimize bundles second, then micro-optimize.
11
+ Comprehensive performance optimization guide for React and Next.js applications, maintained by Vercel. Contains rules across 8 categories, prioritized by impact.
11
12
 
12
- ---
13
-
14
- ## 🎯 Selective Reading Rule (MANDATORY)
15
-
16
- **Read ONLY sections relevant to your task!** Check the content map below and load what you need.
17
-
18
- > 🔴 **For performance reviews: Start with CRITICAL sections (1-2), then move to HIGH/MEDIUM.**
19
-
20
- ---
13
+ ## Use this skill when
21
14
 
22
- ## 📑 Content Map
15
+ - Building React components with Next.js App Router
16
+ - Optimizing performance or eliminating waterfalls
17
+ - Reducing bundle size or improving Core Web Vitals
18
+ - Reviewing code for performance issues
23
19
 
24
- | File | Impact | Rules | When to Read |
25
- | --------------------------------------- | ------------------ | -------- | --------------------------------------------------------------- |
26
- | `1-async-eliminating-waterfalls.md` | 🔴 **CRITICAL** | 5 rules | Slow page loads, sequential API calls, data fetching waterfalls |
27
- | `2-bundle-bundle-size-optimization.md` | 🔴 **CRITICAL** | 5 rules | Large bundle size, slow Time to Interactive, First Load issues |
28
- | `3-server-server-side-performance.md` | 🟠 **HIGH** | 7 rules | Slow SSR, API route optimization, server-side waterfalls |
29
- | `4-client-client-side-data-fetching.md` | 🟡 **MEDIUM-HIGH** | 4 rules | Client data management, SWR patterns, deduplication |
30
- | `5-rerender-re-render-optimization.md` | 🟡 **MEDIUM** | 12 rules | Excessive re-renders, React performance, memoization |
31
- | `6-rendering-rendering-performance.md` | 🟡 **MEDIUM** | 9 rules | Rendering bottlenecks, virtualization, image optimization |
32
- | `7-js-javascript-performance.md` | ⚪ **LOW-MEDIUM** | 12 rules | Micro-optimizations, caching, loop performance |
33
- | `8-advanced-advanced-patterns.md` | 🔵 **VARIABLE** | 3 rules | Advanced React patterns, useLatest, init-once |
20
+ ## Do not use this skill when
34
21
 
35
- **Total: 57 rules across 8 categories**
22
+ - The task is unrelated to React/Next.js
23
+ - You need basic React syntax explanations
36
24
 
37
- ---
25
+ ## Rule Categories by Priority
38
26
 
39
- ## 🚀 Quick Decision Tree
27
+ ### 1. Eliminating Waterfalls (CRITICAL)
40
28
 
41
- **What's your performance issue?**
29
+ ```tsx
30
+ // ❌ Sequential — waterfall
31
+ const user = await getUser();
32
+ const posts = await getPosts(user.id); // waits for user
42
33
 
34
+ // ✅ Parallel — no waterfall
35
+ const [user, posts] = await Promise.all([getUser(), getPosts()]);
43
36
  ```
44
- 🐌 Slow page loads / Long Time to Interactive
45
- → Read Section 1: Eliminating Waterfalls
46
- → Read Section 2: Bundle Size Optimization
47
-
48
- 📦 Large bundle size (> 200KB)
49
- → Read Section 2: Bundle Size Optimization
50
- → Check: Dynamic imports, barrel imports, tree-shaking
51
37
 
52
- 🖥️ Slow Server-Side Rendering
53
- Read Section 3: Server-Side Performance
54
- Check: Parallel data fetching, streaming
38
+ **Key rules:**
39
+ - Fetch all parallel data with `Promise.all`
40
+ - Move data fetching to the closest Server Component
41
+ - Avoid client-side fetch when SSR/RSC is available
55
42
 
56
- 🔄 Too many re-renders / UI lag
57
- → Read Section 5: Re-render Optimization
58
- → Check: React.memo, useMemo, useCallback
43
+ ### 2. Bundle Size Optimization (CRITICAL)
59
44
 
60
- 🎨 Rendering performance issues
61
- Read Section 6: Rendering Performance
62
- Check: Virtualization, layout thrashing
45
+ ```tsx
46
+ // Imports everything
47
+ import _ from 'lodash';
63
48
 
64
- 🌐 Client-side data fetching problems
65
- Read Section 4: Client-Side Data Fetching
66
- → Check: SWR deduplication, localStorage
49
+ // ✅ Tree-shakeable import
50
+ import { debounce } from 'lodash-es';
67
51
 
68
- Need advanced patterns
69
- Read Section 8: Advanced Patterns
52
+ // Dynamic import for heavy components
53
+ const Chart = dynamic(() => import('./Chart'), { ssr: false });
70
54
  ```
71
55
 
72
- ---
73
-
74
- ## 📊 Impact Priority Guide
56
+ ### 3. Server-Side Performance (HIGH)
75
57
 
76
- **Use this order when doing comprehensive optimization:**
58
+ ```tsx
59
+ // ✅ Server Component — no client JS
60
+ export default async function UserProfile({ id }: { id: string }) {
61
+ const user = await db.user.findUnique({ where: { id } });
62
+ return <div>{user.name}</div>;
63
+ }
77
64
 
65
+ // ✅ Streaming with Suspense
66
+ <Suspense fallback={<Skeleton />}>
67
+ <SlowComponent />
68
+ </Suspense>
78
69
  ```
79
- 1️⃣ CRITICAL (Biggest Gains - Do First):
80
- ├─ Section 1: Eliminating Waterfalls
81
- │ └─ Each waterfall adds full network latency (100-500ms+)
82
- └─ Section 2: Bundle Size Optimization
83
- └─ Affects Time to Interactive and Largest Contentful Paint
84
-
85
- 2️⃣ HIGH (Significant Impact - Do Second):
86
- └─ Section 3: Server-Side Performance
87
- └─ Eliminates server-side waterfalls, faster response times
88
-
89
- 3️⃣ MEDIUM (Moderate Gains - Do Third):
90
- ├─ Section 4: Client-Side Data Fetching
91
- ├─ Section 5: Re-render Optimization
92
- └─ Section 6: Rendering Performance
93
-
94
- 4️⃣ LOW (Polish - Do Last):
95
- ├─ Section 7: JavaScript Performance
96
- └─ Section 8: Advanced Patterns
97
- ```
98
-
99
- ---
100
-
101
- ## 🔗 Related Skills
102
-
103
- | Need | Skill |
104
- | ----------------------- | --------------------------------- |
105
- | API design patterns | `@[skills/api-patterns]` |
106
- | Database optimization | `@[skills/database-design]` |
107
- | Testing strategies | `@[skills/testing-patterns]` |
108
- | UI/UX design principles | `@[skills/frontend-design]` |
109
- | TypeScript patterns | `@[skills/typescript-expert]` |
110
- | Deployment & DevOps | `@[skills/deployment-procedures]` |
111
-
112
- ---
113
-
114
- ## ✅ Performance Review Checklist
115
-
116
- Before shipping to production:
117
-
118
- **Critical (Must Fix):**
119
-
120
- - [ ] No sequential data fetching (waterfalls eliminated)
121
- - [ ] Bundle size < 200KB for main bundle
122
- - [ ] No barrel imports in app code
123
- - [ ] Dynamic imports used for large components
124
- - [ ] Parallel data fetching where possible
125
-
126
- **High Priority:**
127
-
128
- - [ ] Server components used where appropriate
129
- - [ ] API routes optimized (no N+1 queries)
130
- - [ ] Suspense boundaries for data fetching
131
- - [ ] Static generation used where possible
132
-
133
- **Medium Priority:**
134
-
135
- - [ ] Expensive computations memoized
136
- - [ ] List rendering virtualized (if > 100 items)
137
- - [ ] Images optimized with next/image
138
- - [ ] No unnecessary re-renders
139
-
140
- **Low Priority (Polish):**
141
-
142
- - [ ] Hot path loops optimized
143
- - [ ] RegExp patterns hoisted
144
- - [ ] Property access cached in loops
145
-
146
- ---
147
-
148
- ## ❌ Anti-Patterns (Common Mistakes)
149
-
150
- **DON'T:**
151
-
152
- - ❌ Use sequential `await` for independent operations
153
- - ❌ Import entire libraries when you need one function
154
- - ❌ Use barrel exports (`index.ts` re-exports) in app code
155
- - ❌ Skip dynamic imports for large components/libraries
156
- - ❌ Fetch data in useEffect without deduplication
157
- - ❌ Forget to memoize expensive computations
158
- - ❌ Use client components when server components work
159
-
160
- **DO:**
161
-
162
- - ✅ Fetch data in parallel with `Promise.all()`
163
- - ✅ Use dynamic imports: `const Comp = dynamic(() => import('./Heavy'))`
164
- - ✅ Import directly: `import { specific } from 'library/specific'`
165
- - ✅ Use Suspense boundaries for better UX
166
- - ✅ Leverage React Server Components
167
- - ✅ Measure performance before optimizing
168
- - ✅ Use Next.js built-in optimizations (next/image, next/font)
169
-
170
- ---
171
-
172
- ## 🎯 How to Use This Skill
173
70
 
174
- ### For New Features:
71
+ ### 4. Client-Side Data Fetching (MEDIUM-HIGH)
175
72
 
176
- 1. Check **Section 1 & 2** while building (prevent waterfalls, keep bundle small)
177
- 2. Use server components by default (Section 3)
178
- 3. Apply memoization for expensive operations (Section 5)
179
-
180
- ### For Performance Reviews:
181
-
182
- 1. Start with **Section 1** (waterfalls = biggest impact)
183
- 2. Then **Section 2** (bundle size)
184
- 3. Then **Section 3** (server-side)
185
- 4. Finally other sections as needed
186
-
187
- ### For Debugging Slow Performance:
188
-
189
- 1. Identify the symptom (slow load, lag, etc.)
190
- 2. Use Quick Decision Tree above
191
- 3. Read relevant section
192
- 4. Apply fixes in priority order
193
-
194
- ---
195
-
196
- ## 📚 Learning Path
197
-
198
- **Beginner (Focus on Critical):**
199
- → Section 1: Eliminating Waterfalls
200
- → Section 2: Bundle Size Optimization
201
-
202
- **Intermediate (Add High Priority):**
203
- → Section 3: Server-Side Performance
204
- → Section 5: Re-render Optimization
205
-
206
- **Advanced (Full Optimization):**
207
- → All sections + Section 8: Advanced Patterns
208
-
209
- ---
210
-
211
- ## 🔍 Validation Script
212
-
213
- | Script | Purpose | Command |
214
- | -------------------------------------- | --------------------------- | ------------------------------------------------------------ |
215
- | `scripts/react_performance_checker.py` | Automated performance audit | `python scripts/react_performance_checker.py <project_path>` |
216
-
217
- ---
218
-
219
- ## 📖 Section Details
220
-
221
- ### Section 1: Eliminating Waterfalls (CRITICAL)
222
-
223
- **Impact:** Each waterfall adds 100-500ms+ latency
224
- **Key Concepts:** Parallel fetching, Promise.all(), Suspense boundaries, preloading
225
-
226
- ### Section 2: Bundle Size Optimization (CRITICAL)
227
-
228
- **Impact:** Directly affects Time to Interactive, Largest Contentful Paint
229
- **Key Concepts:** Dynamic imports, tree-shaking, barrel import avoidance
230
-
231
- ### Section 3: Server-Side Performance (HIGH)
232
-
233
- **Impact:** Faster server responses, better SEO
234
- **Key Concepts:** Parallel server fetching, streaming, API route optimization
235
-
236
- ### Section 4: Client-Side Data Fetching (MEDIUM-HIGH)
237
-
238
- **Impact:** Reduces redundant requests, better UX
239
- **Key Concepts:** SWR deduplication, localStorage caching, event listeners
240
-
241
- ### Section 5: Re-render Optimization (MEDIUM)
242
-
243
- **Impact:** Smoother UI, less wasted computation
244
- **Key Concepts:** React.memo, useMemo, useCallback, component structure
245
-
246
- ### Section 6: Rendering Performance (MEDIUM)
73
+ ```tsx
74
+ // SWR for client-side data
75
+ const { data, isLoading } = useSWR('/api/user', fetcher, {
76
+ revalidateOnFocus: false,
77
+ dedupingInterval: 60000,
78
+ });
79
+ ```
247
80
 
248
- **Impact:** Better rendering efficiency
249
- **Key Concepts:** Virtualization, image optimization, layout thrashing
81
+ ### 5. Re-render Optimization (MEDIUM)
250
82
 
251
- ### Section 7: JavaScript Performance (LOW-MEDIUM)
83
+ ```tsx
84
+ // ✅ Memoize only when profiler shows it helps
85
+ const MemoComponent = memo(Component, (prev, next) =>
86
+ prev.id === next.id
87
+ );
252
88
 
253
- **Impact:** Incremental improvements in hot paths
254
- **Key Concepts:** Loop optimization, caching, RegExp hoisting
89
+ // Stable selectors with Zustand
90
+ const user = useStore(state => state.user); // not state => ({ user: state.user })
91
+ ```
255
92
 
256
- ### Section 8: Advanced Patterns (VARIABLE)
93
+ ### 6. Rendering Performance (MEDIUM)
257
94
 
258
- **Impact:** Specific use cases
259
- **Key Concepts:** useLatest hook, init-once patterns, event handler refs
95
+ ```tsx
96
+ // Virtualize long lists
97
+ import { FixedSizeList as List } from 'react-window';
260
98
 
261
- ---
99
+ <List height={600} itemCount={10000} itemSize={35} width={300}>
100
+ {({ index, style }) => <div style={style}>Row {index}</div>}
101
+ </List>
102
+ ```
262
103
 
263
- ## 🎓 Best Practices Summary
104
+ ### 7. Image & Asset Optimization
264
105
 
265
- **Golden Rules:**
106
+ ```tsx
107
+ // ✅ Always use Next.js Image
108
+ import Image from 'next/image';
109
+ <Image src="/hero.jpg" alt="Hero" width={800} height={600} priority />
110
+ ```
266
111
 
267
- 1. **Measure first** - Use React DevTools Profiler, Chrome DevTools
268
- 2. **Biggest impact first** - Waterfalls → Bundle → Server → Micro
269
- 3. **Don't over-optimize** - Focus on real bottlenecks
270
- 4. **Use platform features** - Next.js has optimizations built-in
271
- 5. **Think about users** - Real-world conditions matter
112
+ ### 8. Advanced Patterns
272
113
 
273
- **Performance Mindset:**
114
+ ```tsx
115
+ // ✅ useOptimistic for instant feedback
116
+ const [optimisticLikes, addOptimisticLike] = useOptimistic(likes);
274
117
 
275
- - Every `await` in sequence = potential waterfall
276
- - Every `import` = potential bundle bloat
277
- - Every re-render = wasted computation (if unnecessary)
278
- - Server components = less JavaScript to ship
279
- - Measure, don't guess
118
+ // Server Actions for mutations
119
+ async function updateUser(formData: FormData) {
120
+ 'use server';
121
+ await db.user.update({ ... });
122
+ revalidatePath('/profile');
123
+ }
124
+ ```
280
125
 
281
- ---
126
+ ## Decision Tree
282
127
 
283
- **Source:** Vercel Engineering
284
- **Date:** January 2026
285
- **Version:** 1.0.0
286
- **Total Rules:** 57 across 8 categories
128
+ ```
129
+ Is data needed at render?
130
+ Yes → Use Server Component (RSC)
131
+ No, user-triggered Use Server Action
132
+ → Real-time/subscription → Client Component + SWR/WebSocket
133
+ ```