@namch/agent-assistant 1.0.0 → 1.0.2

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 (168) hide show
  1. package/README.md +114 -522
  2. package/agents/backend-engineer.md +0 -8
  3. package/agents/brainstormer.md +0 -6
  4. package/agents/business-analyst.md +0 -5
  5. package/agents/database-architect.md +0 -6
  6. package/agents/debugger.md +0 -6
  7. package/agents/designer.md +0 -5
  8. package/agents/devops-engineer.md +0 -7
  9. package/agents/docs-manager.md +0 -6
  10. package/agents/frontend-engineer.md +0 -7
  11. package/agents/game-engineer.md +0 -7
  12. package/agents/mobile-engineer.md +0 -7
  13. package/agents/performance-engineer.md +0 -7
  14. package/agents/planner.md +0 -6
  15. package/agents/project-manager.md +0 -6
  16. package/agents/researcher.md +0 -5
  17. package/agents/reviewer.md +0 -6
  18. package/agents/scouter.md +0 -6
  19. package/agents/security-engineer.md +0 -7
  20. package/agents/tech-lead.md +0 -7
  21. package/agents/tester.md +0 -5
  22. package/cli/README.md +19 -10
  23. package/documents/business/business-features.md +1 -1
  24. package/documents/business/business-prd.md +4 -4
  25. package/documents/knowledge-architecture.md +1 -1
  26. package/documents/knowledge-domain.md +1 -1
  27. package/documents/knowledge-overview.md +14 -29
  28. package/documents/knowledge-source-base.md +14 -14
  29. package/package.json +1 -1
  30. package/rules/QUICK-REFERENCE.md +4 -1
  31. package/rules/SKILL-DISCOVERY.md +37 -14
  32. package/skills/active-directory-attacks/SKILL.md +383 -0
  33. package/skills/active-directory-attacks/references/advanced-attacks.md +382 -0
  34. package/skills/agent-evaluation/SKILL.md +64 -0
  35. package/skills/agent-memory-mcp/SKILL.md +82 -0
  36. package/skills/agent-memory-systems/SKILL.md +67 -0
  37. package/skills/agent-tool-builder/SKILL.md +53 -0
  38. package/skills/ai-agents-architect/SKILL.md +90 -0
  39. package/skills/ai-product/SKILL.md +54 -0
  40. package/skills/ai-wrapper-product/SKILL.md +273 -0
  41. package/skills/api-documentation-generator/SKILL.md +484 -0
  42. package/skills/api-fuzzing-bug-bounty/SKILL.md +433 -0
  43. package/skills/api-security-best-practices/SKILL.md +907 -0
  44. package/skills/autonomous-agent-patterns/SKILL.md +761 -0
  45. package/skills/autonomous-agents/SKILL.md +68 -0
  46. package/skills/aws-penetration-testing/SKILL.md +405 -0
  47. package/skills/aws-penetration-testing/references/advanced-aws-pentesting.md +469 -0
  48. package/skills/azure-functions/SKILL.md +42 -0
  49. package/skills/backend-dev-guidelines/SKILL.md +342 -0
  50. package/skills/backend-dev-guidelines/resources/architecture-overview.md +451 -0
  51. package/skills/backend-dev-guidelines/resources/async-and-errors.md +307 -0
  52. package/skills/backend-dev-guidelines/resources/complete-examples.md +638 -0
  53. package/skills/backend-dev-guidelines/resources/configuration.md +275 -0
  54. package/skills/backend-dev-guidelines/resources/database-patterns.md +224 -0
  55. package/skills/backend-dev-guidelines/resources/middleware-guide.md +213 -0
  56. package/skills/backend-dev-guidelines/resources/routing-and-controllers.md +756 -0
  57. package/skills/backend-dev-guidelines/resources/sentry-and-monitoring.md +336 -0
  58. package/skills/backend-dev-guidelines/resources/services-and-repositories.md +789 -0
  59. package/skills/backend-dev-guidelines/resources/testing-guide.md +235 -0
  60. package/skills/backend-dev-guidelines/resources/validation-patterns.md +754 -0
  61. package/skills/broken-authentication/SKILL.md +476 -0
  62. package/skills/bullmq-specialist/SKILL.md +57 -0
  63. package/skills/bun-development/SKILL.md +691 -0
  64. package/skills/burp-suite-testing/SKILL.md +380 -0
  65. package/skills/cloud-penetration-testing/SKILL.md +501 -0
  66. package/skills/cloud-penetration-testing/references/advanced-cloud-scripts.md +318 -0
  67. package/skills/computer-use-agents/SKILL.md +315 -0
  68. package/skills/content-creator/SKILL.md +248 -0
  69. package/skills/content-creator/assets/content_calendar_template.md +99 -0
  70. package/skills/content-creator/references/brand_guidelines.md +199 -0
  71. package/skills/content-creator/references/content_frameworks.md +534 -0
  72. package/skills/content-creator/references/social_media_optimization.md +317 -0
  73. package/skills/content-creator/scripts/brand_voice_analyzer.py +185 -0
  74. package/skills/content-creator/scripts/seo_optimizer.py +419 -0
  75. package/skills/context-window-management/SKILL.md +53 -0
  76. package/skills/conversation-memory/SKILL.md +61 -0
  77. package/skills/copy-editing/SKILL.md +439 -0
  78. package/skills/copywriting/SKILL.md +225 -0
  79. package/skills/crewai/SKILL.md +243 -0
  80. package/skills/discord-bot-architect/SKILL.md +277 -0
  81. package/skills/dispatching-parallel-agents/SKILL.md +180 -0
  82. package/skills/email-sequence/SKILL.md +925 -0
  83. package/skills/email-systems/SKILL.md +54 -0
  84. package/skills/ethical-hacking-methodology/SKILL.md +466 -0
  85. package/skills/executing-plans/SKILL.md +76 -0
  86. package/skills/file-path-traversal/SKILL.md +486 -0
  87. package/skills/finishing-a-development-branch/SKILL.md +200 -0
  88. package/skills/frontend-dev-guidelines/SKILL.md +359 -0
  89. package/skills/frontend-dev-guidelines/resources/common-patterns.md +331 -0
  90. package/skills/frontend-dev-guidelines/resources/complete-examples.md +872 -0
  91. package/skills/frontend-dev-guidelines/resources/component-patterns.md +502 -0
  92. package/skills/frontend-dev-guidelines/resources/data-fetching.md +767 -0
  93. package/skills/frontend-dev-guidelines/resources/file-organization.md +502 -0
  94. package/skills/frontend-dev-guidelines/resources/loading-and-error-states.md +501 -0
  95. package/skills/frontend-dev-guidelines/resources/performance.md +406 -0
  96. package/skills/frontend-dev-guidelines/resources/routing-guide.md +364 -0
  97. package/skills/frontend-dev-guidelines/resources/styling-guide.md +428 -0
  98. package/skills/frontend-dev-guidelines/resources/typescript-standards.md +418 -0
  99. package/skills/gcp-cloud-run/SKILL.md +288 -0
  100. package/skills/git-pushing/SKILL.md +33 -0
  101. package/skills/git-pushing/scripts/smart_commit.sh +19 -0
  102. package/skills/github-workflow-automation/SKILL.md +846 -0
  103. package/skills/html-injection-testing/SKILL.md +498 -0
  104. package/skills/idor-testing/SKILL.md +442 -0
  105. package/skills/inngest/SKILL.md +55 -0
  106. package/skills/javascript-mastery/SKILL.md +645 -0
  107. package/skills/kaizen/SKILL.md +730 -0
  108. package/skills/langfuse/SKILL.md +238 -0
  109. package/skills/langgraph/SKILL.md +287 -0
  110. package/skills/linux-privilege-escalation/SKILL.md +504 -0
  111. package/skills/llm-app-patterns/SKILL.md +760 -0
  112. package/skills/metasploit-framework/SKILL.md +478 -0
  113. package/skills/multi-agent-brainstorming/SKILL.md +256 -0
  114. package/skills/neon-postgres/SKILL.md +56 -0
  115. package/skills/nextjs-supabase-auth/SKILL.md +56 -0
  116. package/skills/nosql-expert/SKILL.md +111 -0
  117. package/skills/pentest-checklist/SKILL.md +334 -0
  118. package/skills/pentest-commands/SKILL.md +438 -0
  119. package/skills/plaid-fintech/SKILL.md +50 -0
  120. package/skills/planning-with-files/SKILL.md +211 -0
  121. package/skills/planning-with-files/examples.md +202 -0
  122. package/skills/planning-with-files/reference.md +218 -0
  123. package/skills/planning-with-files/scripts/check-complete.sh +44 -0
  124. package/skills/planning-with-files/scripts/init-session.sh +120 -0
  125. package/skills/planning-with-files/templates/findings.md +95 -0
  126. package/skills/planning-with-files/templates/progress.md +114 -0
  127. package/skills/planning-with-files/templates/task_plan.md +132 -0
  128. package/skills/privilege-escalation-methods/SKILL.md +333 -0
  129. package/skills/production-code-audit/SKILL.md +540 -0
  130. package/skills/prompt-caching/SKILL.md +61 -0
  131. package/skills/prompt-engineering/SKILL.md +171 -0
  132. package/skills/prompt-library/SKILL.md +322 -0
  133. package/skills/rag-engineer/SKILL.md +90 -0
  134. package/skills/rag-implementation/SKILL.md +63 -0
  135. package/skills/react-ui-patterns/SKILL.md +289 -0
  136. package/skills/red-team-tools/SKILL.md +310 -0
  137. package/skills/scanning-tools/SKILL.md +589 -0
  138. package/skills/shodan-reconnaissance/SKILL.md +503 -0
  139. package/skills/slack-bot-builder/SKILL.md +264 -0
  140. package/skills/smtp-penetration-testing/SKILL.md +500 -0
  141. package/skills/social-content/SKILL.md +807 -0
  142. package/skills/software-architecture/SKILL.md +75 -0
  143. package/skills/sql-injection-testing/SKILL.md +448 -0
  144. package/skills/sqlmap-database-pentesting/SKILL.md +400 -0
  145. package/skills/ssh-penetration-testing/SKILL.md +488 -0
  146. package/skills/stripe-integration/SKILL.md +69 -0
  147. package/skills/subagent-driven-development/SKILL.md +240 -0
  148. package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +20 -0
  149. package/skills/subagent-driven-development/implementer-prompt.md +78 -0
  150. package/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
  151. package/skills/tavily-web/SKILL.md +36 -0
  152. package/skills/telegram-bot-builder/SKILL.md +254 -0
  153. package/skills/test-driven-development/SKILL.md +371 -0
  154. package/skills/test-driven-development/testing-anti-patterns.md +299 -0
  155. package/skills/test-fixing/SKILL.md +119 -0
  156. package/skills/top-web-vulnerabilities/SKILL.md +543 -0
  157. package/skills/trigger-dev/SKILL.md +67 -0
  158. package/skills/twilio-communications/SKILL.md +295 -0
  159. package/skills/upstash-qstash/SKILL.md +68 -0
  160. package/skills/verification-before-completion/SKILL.md +139 -0
  161. package/skills/voice-agents/SKILL.md +68 -0
  162. package/skills/voice-ai-development/SKILL.md +302 -0
  163. package/skills/windows-privilege-escalation/SKILL.md +496 -0
  164. package/skills/wireshark-analysis/SKILL.md +497 -0
  165. package/skills/wordpress-penetration-testing/SKILL.md +485 -0
  166. package/skills/workflow-automation/SKILL.md +68 -0
  167. package/skills/xss-html-injection/SKILL.md +499 -0
  168. package/skills/zapier-make-patterns/SKILL.md +67 -0
@@ -0,0 +1,359 @@
1
+ ---
2
+ name: frontend-dev-guidelines
3
+ description: Opinionated frontend development standards for modern React + TypeScript applications. Covers Suspense-first data fetching, lazy loading, feature-based architecture, MUI v7 styling, TanStack Router, performance optimization, and strict TypeScript practices.
4
+ ---
5
+
6
+
7
+ # Frontend Development Guidelines
8
+
9
+ **(React · TypeScript · Suspense-First · Production-Grade)**
10
+
11
+ You are a **senior frontend engineer** operating under strict architectural and performance standards.
12
+
13
+ Your goal is to build **scalable, predictable, and maintainable React applications** using:
14
+
15
+ * Suspense-first data fetching
16
+ * Feature-based code organization
17
+ * Strict TypeScript discipline
18
+ * Performance-safe defaults
19
+
20
+ This skill defines **how frontend code must be written**, not merely how it *can* be written.
21
+
22
+ ---
23
+
24
+ ## 1. Frontend Feasibility & Complexity Index (FFCI)
25
+
26
+ Before implementing a component, page, or feature, assess feasibility.
27
+
28
+ ### FFCI Dimensions (1–5)
29
+
30
+ | Dimension | Question |
31
+ | --------------------- | ---------------------------------------------------------------- |
32
+ | **Architectural Fit** | Does this align with feature-based structure and Suspense model? |
33
+ | **Complexity Load** | How complex is state, data, and interaction logic? |
34
+ | **Performance Risk** | Does it introduce rendering, bundle, or CLS risk? |
35
+ | **Reusability** | Can this be reused without modification? |
36
+ | **Maintenance Cost** | How hard will this be to reason about in 6 months? |
37
+
38
+ ### Score Formula
39
+
40
+ ```
41
+ FFCI = (Architectural Fit + Reusability + Performance) − (Complexity + Maintenance Cost)
42
+ ```
43
+
44
+ **Range:** `-5 → +15`
45
+
46
+ ### Interpretation
47
+
48
+ | FFCI | Meaning | Action |
49
+ | --------- | ---------- | ----------------- |
50
+ | **10–15** | Excellent | Proceed |
51
+ | **6–9** | Acceptable | Proceed with care |
52
+ | **3–5** | Risky | Simplify or split |
53
+ | **≤ 2** | Poor | Redesign |
54
+
55
+ ---
56
+
57
+ ## 2. Core Architectural Doctrine (Non-Negotiable)
58
+
59
+ ### 1. Suspense Is the Default
60
+
61
+ * `useSuspenseQuery` is the **primary** data-fetching hook
62
+ * No `isLoading` conditionals
63
+ * No early-return spinners
64
+
65
+ ### 2. Lazy Load Anything Heavy
66
+
67
+ * Routes
68
+ * Feature entry components
69
+ * Data grids, charts, editors
70
+ * Large dialogs or modals
71
+
72
+ ### 3. Feature-Based Organization
73
+
74
+ * Domain logic lives in `features/`
75
+ * Reusable primitives live in `components/`
76
+ * Cross-feature coupling is forbidden
77
+
78
+ ### 4. TypeScript Is Strict
79
+
80
+ * No `any`
81
+ * Explicit return types
82
+ * `import type` always
83
+ * Types are first-class design artifacts
84
+
85
+ ---
86
+
87
+ ## 3. When to Use This Skill
88
+
89
+ Use **frontend-dev-guidelines** when:
90
+
91
+ * Creating components or pages
92
+ * Adding new features
93
+ * Fetching or mutating data
94
+ * Setting up routing
95
+ * Styling with MUI
96
+ * Addressing performance issues
97
+ * Reviewing or refactoring frontend code
98
+
99
+ ---
100
+
101
+ ## 4. Quick Start Checklists
102
+
103
+ ### New Component Checklist
104
+
105
+ * [ ] `React.FC<Props>` with explicit props interface
106
+ * [ ] Lazy loaded if non-trivial
107
+ * [ ] Wrapped in `<SuspenseLoader>`
108
+ * [ ] Uses `useSuspenseQuery` for data
109
+ * [ ] No early returns
110
+ * [ ] Handlers wrapped in `useCallback`
111
+ * [ ] Styles inline if <100 lines
112
+ * [ ] Default export at bottom
113
+ * [ ] Uses `useMuiSnackbar` for feedback
114
+
115
+ ---
116
+
117
+ ### New Feature Checklist
118
+
119
+ * [ ] Create `features/{feature-name}/`
120
+ * [ ] Subdirs: `api/`, `components/`, `hooks/`, `helpers/`, `types/`
121
+ * [ ] API layer isolated in `api/`
122
+ * [ ] Public exports via `index.ts`
123
+ * [ ] Feature entry lazy loaded
124
+ * [ ] Suspense boundary at feature level
125
+ * [ ] Route defined under `routes/`
126
+
127
+ ---
128
+
129
+ ## 5. Import Aliases (Required)
130
+
131
+ | Alias | Path |
132
+ | ------------- | ---------------- |
133
+ | `@/` | `src/` |
134
+ | `~types` | `src/types` |
135
+ | `~components` | `src/components` |
136
+ | `~features` | `src/features` |
137
+
138
+ Aliases must be used consistently. Relative imports beyond one level are discouraged.
139
+
140
+ ---
141
+
142
+ ## 6. Component Standards
143
+
144
+ ### Required Structure Order
145
+
146
+ 1. Types / Props
147
+ 2. Hooks
148
+ 3. Derived values (`useMemo`)
149
+ 4. Handlers (`useCallback`)
150
+ 5. Render
151
+ 6. Default export
152
+
153
+ ### Lazy Loading Pattern
154
+
155
+ ```ts
156
+ const HeavyComponent = React.lazy(() => import('./HeavyComponent'));
157
+ ```
158
+
159
+ Always wrapped in `<SuspenseLoader>`.
160
+
161
+ ---
162
+
163
+ ## 7. Data Fetching Doctrine
164
+
165
+ ### Primary Pattern
166
+
167
+ * `useSuspenseQuery`
168
+ * Cache-first
169
+ * Typed responses
170
+
171
+ ### Forbidden Patterns
172
+
173
+ ❌ `isLoading`
174
+ ❌ manual spinners
175
+ ❌ fetch logic inside components
176
+ ❌ API calls without feature API layer
177
+
178
+ ### API Layer Rules
179
+
180
+ * One API file per feature
181
+ * No inline axios calls
182
+ * No `/api/` prefix in routes
183
+
184
+ ---
185
+
186
+ ## 8. Routing Standards (TanStack Router)
187
+
188
+ * Folder-based routing only
189
+ * Lazy load route components
190
+ * Breadcrumb metadata via loaders
191
+
192
+ ```ts
193
+ export const Route = createFileRoute('/my-route/')({
194
+ component: MyPage,
195
+ loader: () => ({ crumb: 'My Route' }),
196
+ });
197
+ ```
198
+
199
+ ---
200
+
201
+ ## 9. Styling Standards (MUI v7)
202
+
203
+ ### Inline vs Separate
204
+
205
+ * `<100 lines`: inline `sx`
206
+ * `>100 lines`: `{Component}.styles.ts`
207
+
208
+ ### Grid Syntax (v7 Only)
209
+
210
+ ```tsx
211
+ <Grid size={{ xs: 12, md: 6 }} /> // ✅
212
+ <Grid xs={12} md={6} /> // ❌
213
+ ```
214
+
215
+ Theme access must always be type-safe.
216
+
217
+ ---
218
+
219
+ ## 10. Loading & Error Handling
220
+
221
+ ### Absolute Rule
222
+
223
+ ❌ Never return early loaders
224
+ ✅ Always rely on Suspense boundaries
225
+
226
+ ### User Feedback
227
+
228
+ * `useMuiSnackbar` only
229
+ * No third-party toast libraries
230
+
231
+ ---
232
+
233
+ ## 11. Performance Defaults
234
+
235
+ * `useMemo` for expensive derivations
236
+ * `useCallback` for passed handlers
237
+ * `React.memo` for heavy pure components
238
+ * Debounce search (300–500ms)
239
+ * Cleanup effects to avoid leaks
240
+
241
+ Performance regressions are bugs.
242
+
243
+ ---
244
+
245
+ ## 12. TypeScript Standards
246
+
247
+ * Strict mode enabled
248
+ * No implicit `any`
249
+ * Explicit return types
250
+ * JSDoc on public interfaces
251
+ * Types colocated with feature
252
+
253
+ ---
254
+
255
+ ## 13. Canonical File Structure
256
+
257
+ ```
258
+ src/
259
+ features/
260
+ my-feature/
261
+ api/
262
+ components/
263
+ hooks/
264
+ helpers/
265
+ types/
266
+ index.ts
267
+
268
+ components/
269
+ SuspenseLoader/
270
+ CustomAppBar/
271
+
272
+ routes/
273
+ my-route/
274
+ index.tsx
275
+ ```
276
+
277
+ ---
278
+
279
+ ## 14. Canonical Component Template
280
+
281
+ ```ts
282
+ import React, { useState, useCallback } from 'react';
283
+ import { Box, Paper } from '@mui/material';
284
+ import { useSuspenseQuery } from '@tanstack/react-query';
285
+ import { featureApi } from '../api/featureApi';
286
+ import type { FeatureData } from '~types/feature';
287
+
288
+ interface MyComponentProps {
289
+ id: number;
290
+ onAction?: () => void;
291
+ }
292
+
293
+ export const MyComponent: React.FC<MyComponentProps> = ({ id, onAction }) => {
294
+ const [state, setState] = useState('');
295
+
296
+ const { data } = useSuspenseQuery<FeatureData>({
297
+ queryKey: ['feature', id],
298
+ queryFn: () => featureApi.getFeature(id),
299
+ });
300
+
301
+ const handleAction = useCallback(() => {
302
+ setState('updated');
303
+ onAction?.();
304
+ }, [onAction]);
305
+
306
+ return (
307
+ <Box sx={{ p: 2 }}>
308
+ <Paper sx={{ p: 3 }}>
309
+ {/* Content */}
310
+ </Paper>
311
+ </Box>
312
+ );
313
+ };
314
+
315
+ export default MyComponent;
316
+ ```
317
+
318
+ ---
319
+
320
+ ## 15. Anti-Patterns (Immediate Rejection)
321
+
322
+ ❌ Early loading returns
323
+ ❌ Feature logic in `components/`
324
+ ❌ Shared state via prop drilling instead of hooks
325
+ ❌ Inline API calls
326
+ ❌ Untyped responses
327
+ ❌ Multiple responsibilities in one component
328
+
329
+ ---
330
+
331
+ ## 16. Integration With Other Skills
332
+
333
+ * **frontend-design** → Visual systems & aesthetics
334
+ * **page-cro** → Layout hierarchy & conversion logic
335
+ * **analytics-tracking** → Event instrumentation
336
+ * **backend-dev-guidelines** → API contract alignment
337
+ * **error-tracking** → Runtime observability
338
+
339
+ ---
340
+
341
+ ## 17. Operator Validation Checklist
342
+
343
+ Before finalizing code:
344
+
345
+ * [ ] FFCI ≥ 6
346
+ * [ ] Suspense used correctly
347
+ * [ ] Feature boundaries respected
348
+ * [ ] No early returns
349
+ * [ ] Types explicit and correct
350
+ * [ ] Lazy loading applied
351
+ * [ ] Performance safe
352
+
353
+ ---
354
+
355
+ ## 18. Skill Status
356
+
357
+ **Status:** Stable, opinionated, and enforceable
358
+ **Intended Use:** Production React codebases with long-term maintenance horizons
359
+
@@ -0,0 +1,331 @@
1
+ # Common Patterns
2
+
3
+ Frequently used patterns for forms, authentication, DataGrid, dialogs, and other common UI elements.
4
+
5
+ ---
6
+
7
+ ## Authentication with useAuth
8
+
9
+ ### Getting Current User
10
+
11
+ ```typescript
12
+ import { useAuth } from '@/hooks/useAuth';
13
+
14
+ export const MyComponent: React.FC = () => {
15
+ const { user } = useAuth();
16
+
17
+ // Available properties:
18
+ // - user.id: string
19
+ // - user.email: string
20
+ // - user.username: string
21
+ // - user.roles: string[]
22
+
23
+ return (
24
+ <div>
25
+ <p>Logged in as: {user.email}</p>
26
+ <p>Username: {user.username}</p>
27
+ <p>Roles: {user.roles.join(', ')}</p>
28
+ </div>
29
+ );
30
+ };
31
+ ```
32
+
33
+ **NEVER make direct API calls for auth** - always use `useAuth` hook.
34
+
35
+ ---
36
+
37
+ ## Forms with React Hook Form
38
+
39
+ ### Basic Form
40
+
41
+ ```typescript
42
+ import { useForm } from 'react-hook-form';
43
+ import { zodResolver } from '@hookform/resolvers/zod';
44
+ import { z } from 'zod';
45
+ import { TextField, Button } from '@mui/material';
46
+ import { useMuiSnackbar } from '@/hooks/useMuiSnackbar';
47
+
48
+ // Zod schema for validation
49
+ const formSchema = z.object({
50
+ username: z.string().min(3, 'Username must be at least 3 characters'),
51
+ email: z.string().email('Invalid email address'),
52
+ age: z.number().min(18, 'Must be 18 or older'),
53
+ });
54
+
55
+ type FormData = z.infer<typeof formSchema>;
56
+
57
+ export const MyForm: React.FC = () => {
58
+ const { showSuccess, showError } = useMuiSnackbar();
59
+
60
+ const { register, handleSubmit, formState: { errors } } = useForm<FormData>({
61
+ resolver: zodResolver(formSchema),
62
+ defaultValues: {
63
+ username: '',
64
+ email: '',
65
+ age: 18,
66
+ },
67
+ });
68
+
69
+ const onSubmit = async (data: FormData) => {
70
+ try {
71
+ await api.submitForm(data);
72
+ showSuccess('Form submitted successfully');
73
+ } catch (error) {
74
+ showError('Failed to submit form');
75
+ }
76
+ };
77
+
78
+ return (
79
+ <form onSubmit={handleSubmit(onSubmit)}>
80
+ <TextField
81
+ {...register('username')}
82
+ label='Username'
83
+ error={!!errors.username}
84
+ helperText={errors.username?.message}
85
+ />
86
+
87
+ <TextField
88
+ {...register('email')}
89
+ label='Email'
90
+ error={!!errors.email}
91
+ helperText={errors.email?.message}
92
+ type='email'
93
+ />
94
+
95
+ <TextField
96
+ {...register('age', { valueAsNumber: true })}
97
+ label='Age'
98
+ error={!!errors.age}
99
+ helperText={errors.age?.message}
100
+ type='number'
101
+ />
102
+
103
+ <Button type='submit' variant='contained'>
104
+ Submit
105
+ </Button>
106
+ </form>
107
+ );
108
+ };
109
+ ```
110
+
111
+ ---
112
+
113
+ ## Dialog Component Pattern
114
+
115
+ ### Standard Dialog Structure
116
+
117
+ From BEST_PRACTICES.md - All dialogs should have:
118
+ - Icon in title
119
+ - Close button (X)
120
+ - Action buttons at bottom
121
+
122
+ ```typescript
123
+ import { Dialog, DialogTitle, DialogContent, DialogActions, Button, IconButton } from '@mui/material';
124
+ import { Close, Info } from '@mui/icons-material';
125
+
126
+ interface MyDialogProps {
127
+ open: boolean;
128
+ onClose: () => void;
129
+ onConfirm: () => void;
130
+ }
131
+
132
+ export const MyDialog: React.FC<MyDialogProps> = ({ open, onClose, onConfirm }) => {
133
+ return (
134
+ <Dialog open={open} onClose={onClose} maxWidth='sm' fullWidth>
135
+ <DialogTitle>
136
+ <Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
137
+ <Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
138
+ <Info color='primary' />
139
+ Dialog Title
140
+ </Box>
141
+ <IconButton onClick={onClose} size='small'>
142
+ <Close />
143
+ </IconButton>
144
+ </Box>
145
+ </DialogTitle>
146
+
147
+ <DialogContent>
148
+ {/* Content here */}
149
+ </DialogContent>
150
+
151
+ <DialogActions>
152
+ <Button onClick={onClose}>Cancel</Button>
153
+ <Button onClick={onConfirm} variant='contained'>
154
+ Confirm
155
+ </Button>
156
+ </DialogActions>
157
+ </Dialog>
158
+ );
159
+ };
160
+ ```
161
+
162
+ ---
163
+
164
+ ## DataGrid Wrapper Pattern
165
+
166
+ ### Wrapper Component Contract
167
+
168
+ From BEST_PRACTICES.md - DataGrid wrappers should accept:
169
+
170
+ **Required Props:**
171
+ - `rows`: Data array
172
+ - `columns`: Column definitions
173
+ - Loading/error states
174
+
175
+ **Optional Props:**
176
+ - Toolbar components
177
+ - Custom actions
178
+ - Initial state
179
+
180
+ ```typescript
181
+ import { DataGridPro } from '@mui/x-data-grid-pro';
182
+ import type { GridColDef } from '@mui/x-data-grid-pro';
183
+
184
+ interface DataGridWrapperProps {
185
+ rows: any[];
186
+ columns: GridColDef[];
187
+ loading?: boolean;
188
+ toolbar?: React.ReactNode;
189
+ onRowClick?: (row: any) => void;
190
+ }
191
+
192
+ export const DataGridWrapper: React.FC<DataGridWrapperProps> = ({
193
+ rows,
194
+ columns,
195
+ loading = false,
196
+ toolbar,
197
+ onRowClick,
198
+ }) => {
199
+ return (
200
+ <DataGridPro
201
+ rows={rows}
202
+ columns={columns}
203
+ loading={loading}
204
+ slots={{ toolbar: toolbar ? () => toolbar : undefined }}
205
+ onRowClick={(params) => onRowClick?.(params.row)}
206
+ // Standard configuration
207
+ pagination
208
+ pageSizeOptions={[25, 50, 100]}
209
+ initialState={{
210
+ pagination: { paginationModel: { pageSize: 25 } },
211
+ }}
212
+ />
213
+ );
214
+ };
215
+ ```
216
+
217
+ ---
218
+
219
+ ## Mutation Patterns
220
+
221
+ ### Update with Cache Invalidation
222
+
223
+ ```typescript
224
+ import { useMutation, useQueryClient } from '@tanstack/react-query';
225
+ import { useMuiSnackbar } from '@/hooks/useMuiSnackbar';
226
+
227
+ export const useUpdateEntity = () => {
228
+ const queryClient = useQueryClient();
229
+ const { showSuccess, showError } = useMuiSnackbar();
230
+
231
+ return useMutation({
232
+ mutationFn: ({ id, data }: { id: number; data: any }) =>
233
+ api.updateEntity(id, data),
234
+
235
+ onSuccess: (result, variables) => {
236
+ // Invalidate affected queries
237
+ queryClient.invalidateQueries({ queryKey: ['entity', variables.id] });
238
+ queryClient.invalidateQueries({ queryKey: ['entities'] });
239
+
240
+ showSuccess('Entity updated');
241
+ },
242
+
243
+ onError: () => {
244
+ showError('Failed to update entity');
245
+ },
246
+ });
247
+ };
248
+
249
+ // Usage
250
+ const updateEntity = useUpdateEntity();
251
+
252
+ const handleSave = () => {
253
+ updateEntity.mutate({ id: 123, data: { name: 'New Name' } });
254
+ };
255
+ ```
256
+
257
+ ---
258
+
259
+ ## State Management Patterns
260
+
261
+ ### TanStack Query for Server State (PRIMARY)
262
+
263
+ Use TanStack Query for **all server data**:
264
+ - Fetching: useSuspenseQuery
265
+ - Mutations: useMutation
266
+ - Caching: Automatic
267
+ - Synchronization: Built-in
268
+
269
+ ```typescript
270
+ // ✅ CORRECT - TanStack Query for server data
271
+ const { data: users } = useSuspenseQuery({
272
+ queryKey: ['users'],
273
+ queryFn: () => userApi.getUsers(),
274
+ });
275
+ ```
276
+
277
+ ### useState for UI State
278
+
279
+ Use `useState` for **local UI state only**:
280
+ - Form inputs (uncontrolled)
281
+ - Modal open/closed
282
+ - Selected tab
283
+ - Temporary UI flags
284
+
285
+ ```typescript
286
+ // ✅ CORRECT - useState for UI state
287
+ const [modalOpen, setModalOpen] = useState(false);
288
+ const [selectedTab, setSelectedTab] = useState(0);
289
+ ```
290
+
291
+ ### Zustand for Global Client State (Minimal)
292
+
293
+ Use Zustand only for **global client state**:
294
+ - Theme preference
295
+ - Sidebar collapsed state
296
+ - User preferences (not from server)
297
+
298
+ ```typescript
299
+ import { create } from 'zustand';
300
+
301
+ interface AppState {
302
+ sidebarOpen: boolean;
303
+ toggleSidebar: () => void;
304
+ }
305
+
306
+ export const useAppState = create<AppState>((set) => ({
307
+ sidebarOpen: true,
308
+ toggleSidebar: () => set((state) => ({ sidebarOpen: !state.sidebarOpen })),
309
+ }));
310
+ ```
311
+
312
+ **Avoid prop drilling** - use context or Zustand instead.
313
+
314
+ ---
315
+
316
+ ## Summary
317
+
318
+ **Common Patterns:**
319
+ - ✅ useAuth hook for current user (id, email, roles, username)
320
+ - ✅ React Hook Form + Zod for forms
321
+ - ✅ Dialog with icon + close button
322
+ - ✅ DataGrid wrapper contracts
323
+ - ✅ Mutations with cache invalidation
324
+ - ✅ TanStack Query for server state
325
+ - ✅ useState for UI state
326
+ - ✅ Zustand for global client state (minimal)
327
+
328
+ **See Also:**
329
+ - [data-fetching.md](data-fetching.md) - TanStack Query patterns
330
+ - [component-patterns.md](component-patterns.md) - Component structure
331
+ - [loading-and-error-states.md](loading-and-error-states.md) - Error handling