@uocnv1998/agent-kit 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 (77) hide show
  1. package/README.md +56 -0
  2. package/bin/index.js +161 -0
  3. package/package.json +14 -0
  4. package/templates/.agent/ARCHITECTURE.md +37 -0
  5. package/templates/.agent/common/workflows/brainstorm.md +113 -0
  6. package/templates/.agent/designer/ARCHITECTURE.md +24 -0
  7. package/templates/.agent/designer/rules/GEMINI.md +110 -0
  8. package/templates/.agent/designer/skills/SKILL.md +46 -0
  9. package/templates/.agent/designer/workflows/designer-workflow.md +29 -0
  10. package/templates/.agent/dev/backend/ARCHITECTURE.md +49 -0
  11. package/templates/.agent/dev/backend/agents/backend-specialist.md +116 -0
  12. package/templates/.agent/dev/backend/rules/GEMINI.md +114 -0
  13. package/templates/.agent/dev/backend/skills/clichouse-expert/SKILL.md +144 -0
  14. package/templates/.agent/dev/backend/skills/docker/SKILL.md +409 -0
  15. package/templates/.agent/dev/backend/skills/laravel/SKILL.md +63 -0
  16. package/templates/.agent/dev/backend/skills/laravel-tdd/SKILL.md +146 -0
  17. package/templates/.agent/dev/backend/skills/mysql/SKILL.md +83 -0
  18. package/templates/.agent/dev/backend/skills/mysql/references/character-sets.md +66 -0
  19. package/templates/.agent/dev/backend/skills/mysql/references/composite-indexes.md +59 -0
  20. package/templates/.agent/dev/backend/skills/mysql/references/connection-management.md +70 -0
  21. package/templates/.agent/dev/backend/skills/mysql/references/covering-indexes.md +47 -0
  22. package/templates/.agent/dev/backend/skills/mysql/references/data-types.md +69 -0
  23. package/templates/.agent/dev/backend/skills/mysql/references/deadlocks.md +72 -0
  24. package/templates/.agent/dev/backend/skills/mysql/references/explain-analysis.md +66 -0
  25. package/templates/.agent/dev/backend/skills/mysql/references/fulltext-indexes.md +28 -0
  26. package/templates/.agent/dev/backend/skills/mysql/references/index-maintenance.md +110 -0
  27. package/templates/.agent/dev/backend/skills/mysql/references/isolation-levels.md +49 -0
  28. package/templates/.agent/dev/backend/skills/mysql/references/json-column-patterns.md +77 -0
  29. package/templates/.agent/dev/backend/skills/mysql/references/n-plus-one.md +77 -0
  30. package/templates/.agent/dev/backend/skills/mysql/references/online-ddl.md +53 -0
  31. package/templates/.agent/dev/backend/skills/mysql/references/partitioning.md +92 -0
  32. package/templates/.agent/dev/backend/skills/mysql/references/primary-keys.md +70 -0
  33. package/templates/.agent/dev/backend/skills/mysql/references/query-optimization-pitfalls.md +117 -0
  34. package/templates/.agent/dev/backend/skills/mysql/references/replication-lag.md +46 -0
  35. package/templates/.agent/dev/backend/skills/mysql/references/row-locking-gotchas.md +63 -0
  36. package/templates/.agent/dev/common/rules/GIT_COMMIT.md +9 -0
  37. package/templates/.agent/dev/common/skills/tdd-workflow/SKILL.md +149 -0
  38. package/templates/.agent/dev/common/workflows/dev-workflow.md +46 -0
  39. package/templates/.agent/dev/frontend/ARCHITECTURE.md +47 -0
  40. package/templates/.agent/dev/frontend/agents/frontend-specialist.md +593 -0
  41. package/templates/.agent/dev/frontend/rules/GEMINI.md +117 -0
  42. package/templates/.agent/dev/frontend/skills/frontend-design/SKILL.md +418 -0
  43. package/templates/.agent/dev/frontend/skills/frontend-design/animation-guide.md +331 -0
  44. package/templates/.agent/dev/frontend/skills/frontend-design/color-system.md +311 -0
  45. package/templates/.agent/dev/frontend/skills/frontend-design/decision-trees.md +418 -0
  46. package/templates/.agent/dev/frontend/skills/frontend-design/motion-graphics.md +306 -0
  47. package/templates/.agent/dev/frontend/skills/frontend-design/scripts/accessibility_checker.py +183 -0
  48. package/templates/.agent/dev/frontend/skills/frontend-design/scripts/ux_audit.py +722 -0
  49. package/templates/.agent/dev/frontend/skills/frontend-design/typography-system.md +345 -0
  50. package/templates/.agent/dev/frontend/skills/frontend-design/ux-psychology.md +1116 -0
  51. package/templates/.agent/dev/frontend/skills/frontend-design/visual-effects.md +383 -0
  52. package/templates/.agent/dev/frontend/skills/nextjs-react-expert/1-async-eliminating-waterfalls.md +312 -0
  53. package/templates/.agent/dev/frontend/skills/nextjs-react-expert/2-bundle-bundle-size-optimization.md +240 -0
  54. package/templates/.agent/dev/frontend/skills/nextjs-react-expert/3-server-server-side-performance.md +490 -0
  55. package/templates/.agent/dev/frontend/skills/nextjs-react-expert/4-client-client-side-data-fetching.md +264 -0
  56. package/templates/.agent/dev/frontend/skills/nextjs-react-expert/5-rerender-re-render-optimization.md +581 -0
  57. package/templates/.agent/dev/frontend/skills/nextjs-react-expert/6-rendering-rendering-performance.md +432 -0
  58. package/templates/.agent/dev/frontend/skills/nextjs-react-expert/7-js-javascript-performance.md +684 -0
  59. package/templates/.agent/dev/frontend/skills/nextjs-react-expert/8-advanced-advanced-patterns.md +150 -0
  60. package/templates/.agent/dev/frontend/skills/nextjs-react-expert/SKILL.md +286 -0
  61. package/templates/.agent/dev/frontend/skills/nextjs-react-expert/scripts/convert_rules.py +222 -0
  62. package/templates/.agent/dev/frontend/skills/nextjs-react-expert/scripts/react_performance_checker.py +252 -0
  63. package/templates/.agent/dev/frontend/skills/tailwind-patterns/SKILL.md +269 -0
  64. package/templates/.agent/dev/frontend/skills/web-design-guidelines/SKILL.md +57 -0
  65. package/templates/.agent/po_ba/ARCHITECTURE.md +28 -0
  66. package/templates/.agent/po_ba/agents/documentation-writer.md +104 -0
  67. package/templates/.agent/po_ba/agents/product-manager.md +112 -0
  68. package/templates/.agent/po_ba/agents/product-owner.md +95 -0
  69. package/templates/.agent/po_ba/rules/GEMINI.md +142 -0
  70. package/templates/.agent/po_ba/skills/SKILL.md +42 -0
  71. package/templates/.agent/po_ba/workflows/po_ba-workflow.md +21 -0
  72. package/templates/.agent/tester/ARCHITECTURE.md +27 -0
  73. package/templates/.agent/tester/agents/qa-automation-engineer.md +103 -0
  74. package/templates/.agent/tester/agents/test-engineer.md +158 -0
  75. package/templates/.agent/tester/rules/GEMINI.md +147 -0
  76. package/templates/.agent/tester/skills/SKILL.md +57 -0
  77. package/templates/.agent/tester/workflows/tester-workflow.md +32 -0
@@ -0,0 +1,240 @@
1
+ # 2. Bundle Size Optimization
2
+
3
+ > **Impact:** CRITICAL
4
+ > **Focus:** Reducing initial bundle size improves Time to Interactive and Largest Contentful Paint.
5
+
6
+ ---
7
+
8
+ ## Overview
9
+
10
+ This section contains **5 rules** focused on bundle size optimization.
11
+
12
+ ---
13
+
14
+ ## Rule 2.1: Avoid Barrel File Imports
15
+
16
+ **Impact:** CRITICAL
17
+ **Tags:** bundle, imports, tree-shaking, barrel-files, performance
18
+
19
+ ## Avoid Barrel File Imports
20
+
21
+ Import directly from source files instead of barrel files to avoid loading thousands of unused modules. **Barrel files** are entry points that re-export multiple modules (e.g., `index.js` that does `export * from './module'`).
22
+
23
+ Popular icon and component libraries can have **up to 10,000 re-exports** in their entry file. For many React packages, **it takes 200-800ms just to import them**, affecting both development speed and production cold starts.
24
+
25
+ **Why tree-shaking doesn't help:** When a library is marked as external (not bundled), the bundler can't optimize it. If you bundle it to enable tree-shaking, builds become substantially slower analyzing the entire module graph.
26
+
27
+ **Incorrect (imports entire library):**
28
+
29
+ ```tsx
30
+ import { Check, X, Menu } from 'lucide-react'
31
+ // Loads 1,583 modules, takes ~2.8s extra in dev
32
+ // Runtime cost: 200-800ms on every cold start
33
+
34
+ import { Button, TextField } from '@mui/material'
35
+ // Loads 2,225 modules, takes ~4.2s extra in dev
36
+ ```
37
+
38
+ **Correct (imports only what you need):**
39
+
40
+ ```tsx
41
+ import Check from 'lucide-react/dist/esm/icons/check'
42
+ import X from 'lucide-react/dist/esm/icons/x'
43
+ import Menu from 'lucide-react/dist/esm/icons/menu'
44
+ // Loads only 3 modules (~2KB vs ~1MB)
45
+
46
+ import Button from '@mui/material/Button'
47
+ import TextField from '@mui/material/TextField'
48
+ // Loads only what you use
49
+ ```
50
+
51
+ **Alternative (Next.js 13.5+):**
52
+
53
+ ```js
54
+ // next.config.js - use optimizePackageImports
55
+ module.exports = {
56
+ experimental: {
57
+ optimizePackageImports: ['lucide-react', '@mui/material']
58
+ }
59
+ }
60
+
61
+ // Then you can keep the ergonomic barrel imports:
62
+ import { Check, X, Menu } from 'lucide-react'
63
+ // Automatically transformed to direct imports at build time
64
+ ```
65
+
66
+ Direct imports provide 15-70% faster dev boot, 28% faster builds, 40% faster cold starts, and significantly faster HMR.
67
+
68
+ Libraries commonly affected: `lucide-react`, `@mui/material`, `@mui/icons-material`, `@tabler/icons-react`, `react-icons`, `@headlessui/react`, `@radix-ui/react-*`, `lodash`, `ramda`, `date-fns`, `rxjs`, `react-use`.
69
+
70
+ Reference: [How we optimized package imports in Next.js](https://vercel.com/blog/how-we-optimized-package-imports-in-next-js)
71
+
72
+ ---
73
+
74
+ ## Rule 2.2: Conditional Module Loading
75
+
76
+ **Impact:** HIGH
77
+ **Tags:** bundle, conditional-loading, lazy-loading
78
+
79
+ ## Conditional Module Loading
80
+
81
+ Load large data or modules only when a feature is activated.
82
+
83
+ **Example (lazy-load animation frames):**
84
+
85
+ ```tsx
86
+ function AnimationPlayer({ enabled, setEnabled }: { enabled: boolean; setEnabled: React.Dispatch<React.SetStateAction<boolean>> }) {
87
+ const [frames, setFrames] = useState<Frame[] | null>(null)
88
+
89
+ useEffect(() => {
90
+ if (enabled && !frames && typeof window !== 'undefined') {
91
+ import('./animation-frames.js')
92
+ .then(mod => setFrames(mod.frames))
93
+ .catch(() => setEnabled(false))
94
+ }
95
+ }, [enabled, frames, setEnabled])
96
+
97
+ if (!frames) return <Skeleton />
98
+ return <Canvas frames={frames} />
99
+ }
100
+ ```
101
+
102
+ The `typeof window !== 'undefined'` check prevents bundling this module for SSR, optimizing server bundle size and build speed.
103
+
104
+ ---
105
+
106
+ ## Rule 2.3: Defer Non-Critical Third-Party Libraries
107
+
108
+ **Impact:** MEDIUM
109
+ **Tags:** bundle, third-party, analytics, defer
110
+
111
+ ## Defer Non-Critical Third-Party Libraries
112
+
113
+ Analytics, logging, and error tracking don't block user interaction. Load them after hydration.
114
+
115
+ **Incorrect (blocks initial bundle):**
116
+
117
+ ```tsx
118
+ import { Analytics } from '@vercel/analytics/react'
119
+
120
+ export default function RootLayout({ children }) {
121
+ return (
122
+ <html>
123
+ <body>
124
+ {children}
125
+ <Analytics />
126
+ </body>
127
+ </html>
128
+ )
129
+ }
130
+ ```
131
+
132
+ **Correct (loads after hydration):**
133
+
134
+ ```tsx
135
+ import dynamic from 'next/dynamic'
136
+
137
+ const Analytics = dynamic(
138
+ () => import('@vercel/analytics/react').then(m => m.Analytics),
139
+ { ssr: false }
140
+ )
141
+
142
+ export default function RootLayout({ children }) {
143
+ return (
144
+ <html>
145
+ <body>
146
+ {children}
147
+ <Analytics />
148
+ </body>
149
+ </html>
150
+ )
151
+ }
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Rule 2.4: Dynamic Imports for Heavy Components
157
+
158
+ **Impact:** CRITICAL
159
+ **Tags:** bundle, dynamic-import, code-splitting, next-dynamic
160
+
161
+ ## Dynamic Imports for Heavy Components
162
+
163
+ Use `next/dynamic` to lazy-load large components not needed on initial render.
164
+
165
+ **Incorrect (Monaco bundles with main chunk ~300KB):**
166
+
167
+ ```tsx
168
+ import { MonacoEditor } from './monaco-editor'
169
+
170
+ function CodePanel({ code }: { code: string }) {
171
+ return <MonacoEditor value={code} />
172
+ }
173
+ ```
174
+
175
+ **Correct (Monaco loads on demand):**
176
+
177
+ ```tsx
178
+ import dynamic from 'next/dynamic'
179
+
180
+ const MonacoEditor = dynamic(
181
+ () => import('./monaco-editor').then(m => m.MonacoEditor),
182
+ { ssr: false }
183
+ )
184
+
185
+ function CodePanel({ code }: { code: string }) {
186
+ return <MonacoEditor value={code} />
187
+ }
188
+ ```
189
+
190
+ ---
191
+
192
+ ## Rule 2.5: Preload Based on User Intent
193
+
194
+ **Impact:** MEDIUM
195
+ **Tags:** bundle, preload, user-intent, hover
196
+
197
+ ## Preload Based on User Intent
198
+
199
+ Preload heavy bundles before they're needed to reduce perceived latency.
200
+
201
+ **Example (preload on hover/focus):**
202
+
203
+ ```tsx
204
+ function EditorButton({ onClick }: { onClick: () => void }) {
205
+ const preload = () => {
206
+ if (typeof window !== 'undefined') {
207
+ void import('./monaco-editor')
208
+ }
209
+ }
210
+
211
+ return (
212
+ <button
213
+ onMouseEnter={preload}
214
+ onFocus={preload}
215
+ onClick={onClick}
216
+ >
217
+ Open Editor
218
+ </button>
219
+ )
220
+ }
221
+ ```
222
+
223
+ **Example (preload when feature flag is enabled):**
224
+
225
+ ```tsx
226
+ function FlagsProvider({ children, flags }: Props) {
227
+ useEffect(() => {
228
+ if (flags.editorEnabled && typeof window !== 'undefined') {
229
+ void import('./monaco-editor').then(mod => mod.init())
230
+ }
231
+ }, [flags.editorEnabled])
232
+
233
+ return <FlagsContext.Provider value={flags}>
234
+ {children}
235
+ </FlagsContext.Provider>
236
+ }
237
+ ```
238
+
239
+ The `typeof window !== 'undefined'` check prevents bundling preloaded modules for SSR, optimizing server bundle size and build speed.
240
+