ai-flow-dev 2.1.2 → 2.1.4
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.
- package/README.md +28 -40
- package/dist/cli.js +69 -47
- package/dist/cli.js.map +1 -1
- package/package.json +5 -5
- package/prompts/backend/flow-build-phase-0.md +96 -84
- package/prompts/backend/flow-build-phase-1.md +10 -18
- package/prompts/backend/flow-build-phase-10.md +199 -583
- package/prompts/backend/flow-build-phase-2.md +152 -86
- package/prompts/backend/flow-build-phase-3.md +108 -68
- package/prompts/backend/flow-build-phase-4.md +5 -8
- package/prompts/backend/flow-build-phase-5.md +39 -12
- package/prompts/backend/flow-build-phase-6.md +29 -8
- package/prompts/backend/flow-build-phase-7.md +121 -41
- package/prompts/backend/flow-build-phase-8.md +28 -65
- package/prompts/backend/flow-build-phase-9.md +267 -1298
- package/prompts/backend/flow-build.md +881 -957
- package/prompts/backend/flow-dev-commit.md +27 -50
- package/prompts/backend/flow-dev-feature.md +1929 -2017
- package/prompts/backend/flow-dev-fix.md +936 -964
- package/prompts/backend/flow-dev-refactor.md +672 -701
- package/prompts/backend/flow-dev-review.md +356 -389
- package/prompts/backend/flow-dev-work.md +1066 -1118
- package/prompts/backend/flow-docs-sync.md +31 -210
- package/prompts/frontend/flow-build-phase-0.md +503 -484
- package/prompts/frontend/flow-build-phase-1.md +445 -433
- package/prompts/frontend/flow-build-phase-2.md +910 -957
- package/prompts/frontend/flow-build-phase-3.md +692 -664
- package/prompts/frontend/flow-build-phase-4.md +478 -463
- package/prompts/frontend/flow-build-phase-5.md +488 -467
- package/prompts/frontend/flow-build-phase-6.md +571 -550
- package/prompts/frontend/flow-build-phase-7.md +560 -592
- package/prompts/frontend/flow-build-phase-8.md +17 -42
- package/prompts/frontend/flow-build.md +457 -503
- package/prompts/frontend/flow-docs-sync.md +24 -45
- package/prompts/mobile/flow-build-phase-0.md +104 -97
- package/prompts/mobile/flow-build-phase-1.md +137 -122
- package/prompts/mobile/flow-build-phase-2.md +123 -130
- package/prompts/mobile/flow-build-phase-3.md +144 -149
- package/prompts/mobile/flow-build-phase-4.md +140 -132
- package/prompts/mobile/flow-build-phase-5.md +70 -70
- package/prompts/mobile/flow-build-phase-6.md +136 -134
- package/prompts/mobile/flow-build-phase-7.md +24 -58
- package/prompts/mobile/flow-build-phase-8.md +17 -42
- package/prompts/mobile/flow-build.md +47 -97
- package/prompts/mobile/flow-docs-sync.md +23 -42
- package/prompts/shared/mermaid-guidelines.md +106 -0
- package/prompts/shared/scope-levels.md +126 -0
- package/prompts/shared/story-points.md +65 -0
- package/prompts/shared/task-format.md +86 -0
- package/templates/AGENT.template.md +194 -15
- package/templates/backend/README.template.md +2 -32
- package/templates/backend/ai-instructions.template.md +2 -32
- package/templates/backend/copilot-instructions.template.md +2 -22
- package/templates/backend/docs/api.template.md +89 -20
- package/templates/backend/docs/architecture.template.md +165 -53
- package/templates/backend/docs/business-flows.template.md +7 -14
- package/templates/backend/docs/code-standards.template.md +2 -38
- package/templates/backend/docs/contributing.template.md +2 -16
- package/templates/backend/docs/data-model.template.md +125 -21
- package/templates/backend/docs/operations.template.md +179 -50
- package/templates/backend/docs/testing.template.md +2 -42
- package/templates/backend/project-brief.template.md +2 -28
- package/templates/backend/specs/configuration.template.md +2 -14
- package/templates/backend/specs/security.template.md +2 -32
- package/templates/frontend/README.template.md +2 -18
- package/templates/frontend/ai-instructions.template.md +2 -20
- package/templates/frontend/docs/api-integration.template.md +12 -30
- package/templates/frontend/docs/components.template.md +2 -28
- package/templates/frontend/docs/error-handling.template.md +11 -27
- package/templates/frontend/docs/operations.template.md +8 -18
- package/templates/frontend/docs/performance.template.md +8 -18
- package/templates/frontend/docs/pwa.template.md +8 -18
- package/templates/frontend/docs/state-management.template.md +2 -28
- package/templates/frontend/docs/styling.template.md +2 -26
- package/templates/frontend/docs/testing.template.md +2 -28
- package/templates/frontend/project-brief.template.md +2 -16
- package/templates/frontend/specs/accessibility.template.md +8 -18
- package/templates/frontend/specs/configuration.template.md +2 -24
- package/templates/frontend/specs/security.template.md +10 -24
- package/templates/fullstack/README.template.md +17 -47
- package/templates/fullstack/ai-instructions.template.md +17 -45
- package/templates/fullstack/project-brief.template.md +16 -42
- package/templates/fullstack/specs/configuration.template.md +16 -42
- package/templates/mobile/README.template.md +11 -29
- package/templates/mobile/ai-instructions.template.md +11 -27
- package/templates/mobile/docs/app-store.template.md +11 -29
- package/templates/mobile/docs/architecture.template.md +14 -38
- package/templates/mobile/docs/native-features.template.md +16 -44
- package/templates/mobile/docs/navigation.template.md +9 -23
- package/templates/mobile/docs/offline-strategy.template.md +10 -26
- package/templates/mobile/docs/permissions.template.md +9 -23
- package/templates/mobile/docs/state-management.template.md +12 -32
- package/templates/mobile/docs/testing.template.md +14 -38
- package/templates/mobile/project-brief.template.md +12 -30
- package/templates/mobile/specs/build-configuration.template.md +10 -26
- package/templates/mobile/specs/deployment.template.md +9 -23
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
# Component Architecture
|
|
2
2
|
|
|
3
3
|
> Component organization, patterns, and best practices for {{PROJECT_NAME}}
|
|
4
|
-
|
|
5
4
|
---
|
|
6
|
-
|
|
7
5
|
## 📐 Component Pattern
|
|
8
6
|
|
|
9
7
|
**Pattern:** {{COMPONENT_PATTERN}}
|
|
10
8
|
|
|
11
9
|
{{COMPONENT_PATTERN_DESCRIPTION}}
|
|
12
|
-
|
|
13
10
|
---
|
|
14
|
-
|
|
15
11
|
## 🏗️ Component Hierarchy
|
|
16
12
|
|
|
17
13
|
### Atomic Design (if using)
|
|
@@ -41,9 +37,7 @@ features/
|
|
|
41
37
|
hooks/
|
|
42
38
|
services/
|
|
43
39
|
```
|
|
44
|
-
|
|
45
40
|
---
|
|
46
|
-
|
|
47
41
|
## 📁 File Structure
|
|
48
42
|
|
|
49
43
|
### Component File Organization
|
|
@@ -86,9 +80,7 @@ src/
|
|
|
86
80
|
├── utils/ # Utility functions
|
|
87
81
|
└── types/ # TypeScript types
|
|
88
82
|
```
|
|
89
|
-
|
|
90
83
|
---
|
|
91
|
-
|
|
92
84
|
## 🧩 Component Types
|
|
93
85
|
|
|
94
86
|
### 1. Presentational Components (Atoms/Molecules)
|
|
@@ -196,9 +188,7 @@ export const MainLayout: React.FC<MainLayoutProps> = ({
|
|
|
196
188
|
);
|
|
197
189
|
};
|
|
198
190
|
```
|
|
199
|
-
|
|
200
191
|
---
|
|
201
|
-
|
|
202
192
|
## 🎯 Component Design Principles
|
|
203
193
|
|
|
204
194
|
### 1. Single Responsibility
|
|
@@ -252,9 +242,7 @@ const auth = useAuth();
|
|
|
252
242
|
### 4. Keep It Simple
|
|
253
243
|
|
|
254
244
|
Avoid premature abstraction. Extract only when pattern emerges 3+ times.
|
|
255
|
-
|
|
256
245
|
---
|
|
257
|
-
|
|
258
246
|
## 🔧 Component Patterns
|
|
259
247
|
|
|
260
248
|
### Pattern: Compound Components
|
|
@@ -358,9 +346,7 @@ const SearchInput = () => {
|
|
|
358
346
|
return <input value={query} onChange={e => setQuery(e.target.value)} />;
|
|
359
347
|
};
|
|
360
348
|
```
|
|
361
|
-
|
|
362
349
|
---
|
|
363
|
-
|
|
364
350
|
## 🎨 Styling Strategy
|
|
365
351
|
|
|
366
352
|
**Approach:** {{STYLING_APPROACH}}
|
|
@@ -373,9 +359,7 @@ const SearchInput = () => {
|
|
|
373
359
|
// Using {{STYLING_APPROACH}}
|
|
374
360
|
{{STYLING_EXAMPLE}}
|
|
375
361
|
```
|
|
376
|
-
|
|
377
362
|
---
|
|
378
|
-
|
|
379
363
|
## 🧪 Component Testing
|
|
380
364
|
|
|
381
365
|
### What to Test
|
|
@@ -417,9 +401,7 @@ describe('Button', () => {
|
|
|
417
401
|
});
|
|
418
402
|
});
|
|
419
403
|
```
|
|
420
|
-
|
|
421
404
|
---
|
|
422
|
-
|
|
423
405
|
## 📦 Component Library
|
|
424
406
|
|
|
425
407
|
{{#IF_COMPONENT_LIBRARY}}
|
|
@@ -437,9 +419,7 @@ describe('Button', () => {
|
|
|
437
419
|
- ✅ Simple components (Button, Input)
|
|
438
420
|
- ✅ Performance-critical components
|
|
439
421
|
{{/IF_COMPONENT_LIBRARY}}
|
|
440
|
-
|
|
441
422
|
---
|
|
442
|
-
|
|
443
423
|
## 🚀 Performance Optimization
|
|
444
424
|
|
|
445
425
|
### Code Splitting
|
|
@@ -481,9 +461,7 @@ import { FixedSizeList } from 'react-window';
|
|
|
481
461
|
)}
|
|
482
462
|
</FixedSizeList>
|
|
483
463
|
```
|
|
484
|
-
|
|
485
464
|
---
|
|
486
|
-
|
|
487
465
|
## ♿ Accessibility Guidelines
|
|
488
466
|
|
|
489
467
|
### Semantic HTML
|
|
@@ -520,9 +498,7 @@ const handleKeyDown = (e: KeyboardEvent) => {
|
|
|
520
498
|
}
|
|
521
499
|
};
|
|
522
500
|
```
|
|
523
|
-
|
|
524
501
|
---
|
|
525
|
-
|
|
526
502
|
## 📚 Component Documentation
|
|
527
503
|
|
|
528
504
|
### JSDoc Comments
|
|
@@ -547,9 +523,7 @@ Each feature directory should have a README explaining:
|
|
|
547
523
|
- Key components
|
|
548
524
|
- Data flow
|
|
549
525
|
- API dependencies
|
|
550
|
-
|
|
551
526
|
---
|
|
552
|
-
|
|
553
527
|
## 🔗 Related Documents
|
|
554
528
|
|
|
555
529
|
- [AI Instructions](../ai-instructions.md) - Development guidelines
|
|
@@ -557,11 +531,11 @@ Each feature directory should have a README explaining:
|
|
|
557
531
|
- [Styling Guide](styling.md) - Styling conventions
|
|
558
532
|
- [Testing Strategy](testing.md) - Testing approach
|
|
559
533
|
- [Performance](performance.md) - Optimization techniques
|
|
560
|
-
|
|
561
534
|
---
|
|
562
|
-
|
|
563
535
|
**Last Updated:** {{GENERATION_DATE}}
|
|
564
536
|
|
|
565
537
|
**Pattern:** {{COMPONENT_PATTERN}}
|
|
566
538
|
|
|
567
539
|
**Framework:** {{UI_FRAMEWORK}} {{UI_FRAMEWORK_VERSION}}
|
|
540
|
+
|
|
541
|
+
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
# Error Handling
|
|
2
2
|
|
|
3
3
|
> Error handling strategies and best practices for {{PROJECT_NAME}}
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
4
|
+
---
|
|
7
5
|
## 🎯 Error Handling Strategy
|
|
8
6
|
|
|
9
7
|
**Approach:** {{ERROR_HANDLING_STRATEGY}}
|
|
10
8
|
**Error Logging:** {{ERROR_LOGGING_TOOL}}
|
|
11
9
|
**Recovery Strategy:** {{ERROR_RECOVERY_STRATEGY}}
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
10
|
+
---
|
|
15
11
|
## 🛡️ Error Boundaries (React)
|
|
16
12
|
|
|
17
13
|
### Basic Error Boundary
|
|
@@ -75,9 +71,7 @@ export class ErrorBoundary extends Component<Props, State> {
|
|
|
75
71
|
<App />
|
|
76
72
|
</ErrorBoundary>
|
|
77
73
|
```
|
|
78
|
-
|
|
79
|
-
---
|
|
80
|
-
|
|
74
|
+
---
|
|
81
75
|
## 🔄 Global Error Handlers
|
|
82
76
|
|
|
83
77
|
### React Global Error Handler
|
|
@@ -123,9 +117,7 @@ export class GlobalErrorHandler implements ErrorHandler {
|
|
|
123
117
|
}
|
|
124
118
|
}
|
|
125
119
|
```
|
|
126
|
-
|
|
127
|
-
---
|
|
128
|
-
|
|
120
|
+
---
|
|
129
121
|
## 📡 API Error Handling
|
|
130
122
|
|
|
131
123
|
### Error Types
|
|
@@ -230,9 +222,7 @@ export function handleApiError(error: unknown): {
|
|
|
230
222
|
};
|
|
231
223
|
}
|
|
232
224
|
```
|
|
233
|
-
|
|
234
|
-
---
|
|
235
|
-
|
|
225
|
+
---
|
|
236
226
|
## 🔁 Retry Logic
|
|
237
227
|
|
|
238
228
|
### Exponential Backoff Retry
|
|
@@ -282,9 +272,7 @@ const { data } = useQuery({
|
|
|
282
272
|
retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 30000),
|
|
283
273
|
});
|
|
284
274
|
```
|
|
285
|
-
|
|
286
|
-
---
|
|
287
|
-
|
|
275
|
+
---
|
|
288
276
|
## 📝 Error Logging
|
|
289
277
|
|
|
290
278
|
### Error Logging Service
|
|
@@ -322,9 +310,7 @@ Sentry.setUser({
|
|
|
322
310
|
username: user.username,
|
|
323
311
|
});
|
|
324
312
|
```
|
|
325
|
-
|
|
326
|
-
---
|
|
327
|
-
|
|
313
|
+
---
|
|
328
314
|
## 🎨 Error UI Components
|
|
329
315
|
|
|
330
316
|
### Error Display Component
|
|
@@ -368,18 +354,16 @@ export const ErrorFallback: React.FC<{ error: Error; resetError: () => void }> =
|
|
|
368
354
|
);
|
|
369
355
|
};
|
|
370
356
|
```
|
|
371
|
-
|
|
372
|
-
---
|
|
373
|
-
|
|
357
|
+
---
|
|
374
358
|
## 🔗 Related Documents
|
|
375
359
|
|
|
376
360
|
- [API Integration](api-integration.md) - API error handling
|
|
377
361
|
- [State Management](state-management.md) - Error state management
|
|
378
362
|
- [Security](security.md) - Security error handling
|
|
379
|
-
|
|
380
|
-
---
|
|
381
|
-
|
|
363
|
+
---
|
|
382
364
|
**Last Updated:** {{GENERATION_DATE}}
|
|
383
365
|
|
|
384
366
|
**Error Handling Strategy:** {{ERROR_HANDLING_STRATEGY}}
|
|
385
367
|
|
|
368
|
+
|
|
369
|
+
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
# Operations & Deployment
|
|
2
2
|
|
|
3
3
|
> Deployment procedures and operational guidelines for {{PROJECT_NAME}}
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
4
|
+
---
|
|
7
5
|
## 🚀 Deployment Platform
|
|
8
6
|
|
|
9
7
|
**Platform:** {{DEPLOYMENT_PLATFORM}}
|
|
10
8
|
**CI/CD:** {{CI_CD_PLATFORM}}
|
|
11
9
|
**Environments:** {{ENVIRONMENTS}}
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
10
|
+
---
|
|
15
11
|
## 📦 Build Process
|
|
16
12
|
|
|
17
13
|
### Production Build
|
|
@@ -36,9 +32,7 @@ dist/
|
|
|
36
32
|
VITE_API_BASE_URL=https://api.example.com
|
|
37
33
|
VITE_APP_ENV=production
|
|
38
34
|
```
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
35
|
+
---
|
|
42
36
|
## 🔄 CI/CD Pipeline
|
|
43
37
|
|
|
44
38
|
### GitHub Actions Example
|
|
@@ -67,9 +61,7 @@ jobs:
|
|
|
67
61
|
with:
|
|
68
62
|
vercel-token: ${{ secrets.VERCEL_TOKEN }}
|
|
69
63
|
```
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
64
|
+
---
|
|
73
65
|
## 📊 Monitoring
|
|
74
66
|
|
|
75
67
|
### Error Tracking
|
|
@@ -107,17 +99,15 @@ onCLS(console.log);
|
|
|
107
99
|
onFID(console.log);
|
|
108
100
|
onLCP(console.log);
|
|
109
101
|
```
|
|
110
|
-
|
|
111
|
-
---
|
|
112
|
-
|
|
102
|
+
---
|
|
113
103
|
## 🔗 Related Documents
|
|
114
104
|
|
|
115
105
|
- [Performance](performance.md) - Performance optimization
|
|
116
106
|
- [Configuration](../specs/configuration.md) - Environment configuration
|
|
117
|
-
|
|
118
|
-
---
|
|
119
|
-
|
|
107
|
+
---
|
|
120
108
|
**Last Updated:** {{GENERATION_DATE}}
|
|
121
109
|
|
|
122
110
|
**Deployment Platform:** {{DEPLOYMENT_PLATFORM}}
|
|
123
111
|
|
|
112
|
+
|
|
113
|
+
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
# Performance Optimization
|
|
2
2
|
|
|
3
3
|
> Performance optimization strategies and best practices for {{PROJECT_NAME}}
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
4
|
+
---
|
|
7
5
|
## 🎯 Performance Targets
|
|
8
6
|
|
|
9
7
|
**Core Web Vitals:**
|
|
@@ -12,9 +10,7 @@
|
|
|
12
10
|
- **CLS:** < {{CLS_TARGET}}
|
|
13
11
|
|
|
14
12
|
**Bundle Size:** < {{BUNDLE_SIZE_TARGET}}KB (gzipped)
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
13
|
+
---
|
|
18
14
|
## 📦 Bundle Optimization
|
|
19
15
|
|
|
20
16
|
### Code Splitting
|
|
@@ -47,9 +43,7 @@ npm run build -- --analyze
|
|
|
47
43
|
# Check bundle size in CI
|
|
48
44
|
npm run build && du -sh dist/*
|
|
49
45
|
```
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
46
|
+
---
|
|
53
47
|
## 🖼️ Image Optimization
|
|
54
48
|
|
|
55
49
|
### Next-gen Formats
|
|
@@ -79,9 +73,7 @@ const observer = new IntersectionObserver((entries) => {
|
|
|
79
73
|
});
|
|
80
74
|
});
|
|
81
75
|
```
|
|
82
|
-
|
|
83
|
-
---
|
|
84
|
-
|
|
76
|
+
---
|
|
85
77
|
## ⚡ Performance Monitoring
|
|
86
78
|
|
|
87
79
|
### Core Web Vitals Tracking
|
|
@@ -124,17 +116,15 @@ module.exports = {
|
|
|
124
116
|
},
|
|
125
117
|
};
|
|
126
118
|
```
|
|
127
|
-
|
|
128
|
-
---
|
|
129
|
-
|
|
119
|
+
---
|
|
130
120
|
## 🔗 Related Documents
|
|
131
121
|
|
|
132
122
|
- [Operations](operations.md) - Performance monitoring setup
|
|
133
123
|
- [Build Configuration](../specs/configuration.md) - Build optimization
|
|
134
|
-
|
|
135
|
-
---
|
|
136
|
-
|
|
124
|
+
---
|
|
137
125
|
**Last Updated:** {{GENERATION_DATE}}
|
|
138
126
|
|
|
139
127
|
**Performance Targets:** LCP < {{LCP_TARGET}}s, FID < {{FID_TARGET}}ms, CLS < {{CLS_TARGET}}
|
|
140
128
|
|
|
129
|
+
|
|
130
|
+
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
# Progressive Web App (PWA)
|
|
2
2
|
|
|
3
3
|
> PWA features and offline capabilities for {{PROJECT_NAME}}
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
4
|
+
---
|
|
7
5
|
## 🎯 PWA Strategy
|
|
8
6
|
|
|
9
7
|
**Service Worker:** {{SERVICE_WORKER_ENABLED}}
|
|
10
8
|
**Caching Strategy:** {{CACHING_STRATEGY}}
|
|
11
9
|
**Install Prompt:** {{INSTALL_PROMPT}}
|
|
12
10
|
**Offline Support:** {{OFFLINE_SUPPORT}}
|
|
13
|
-
|
|
14
|
-
---
|
|
15
|
-
|
|
11
|
+
---
|
|
16
12
|
## 🔧 Service Worker
|
|
17
13
|
|
|
18
14
|
### Registration
|
|
@@ -63,9 +59,7 @@ self.addEventListener('fetch', (event) => {
|
|
|
63
59
|
);
|
|
64
60
|
});
|
|
65
61
|
```
|
|
66
|
-
|
|
67
|
-
---
|
|
68
|
-
|
|
62
|
+
---
|
|
69
63
|
## 📱 Web App Manifest
|
|
70
64
|
|
|
71
65
|
```json
|
|
@@ -92,9 +86,7 @@ self.addEventListener('fetch', (event) => {
|
|
|
92
86
|
]
|
|
93
87
|
}
|
|
94
88
|
```
|
|
95
|
-
|
|
96
|
-
---
|
|
97
|
-
|
|
89
|
+
---
|
|
98
90
|
## 📲 Install Prompt
|
|
99
91
|
|
|
100
92
|
```typescript
|
|
@@ -119,17 +111,15 @@ export function showInstallPrompt() {
|
|
|
119
111
|
}
|
|
120
112
|
}
|
|
121
113
|
```
|
|
122
|
-
|
|
123
|
-
---
|
|
124
|
-
|
|
114
|
+
---
|
|
125
115
|
## 🔗 Related Documents
|
|
126
116
|
|
|
127
117
|
- [Performance](performance.md) - PWA performance
|
|
128
118
|
- [Operations](operations.md) - PWA deployment
|
|
129
|
-
|
|
130
|
-
---
|
|
131
|
-
|
|
119
|
+
---
|
|
132
120
|
**Last Updated:** {{GENERATION_DATE}}
|
|
133
121
|
|
|
134
122
|
**PWA Features:** {{PWA_FEATURES}}
|
|
135
123
|
|
|
124
|
+
|
|
125
|
+
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
# State Management
|
|
2
2
|
|
|
3
3
|
> State management patterns and best practices for {{PROJECT_NAME}}
|
|
4
|
-
|
|
5
4
|
---
|
|
6
|
-
|
|
7
5
|
## 🎯 State Management Solution
|
|
8
6
|
|
|
9
7
|
**Solution:** {{STATE_MANAGEMENT}}
|
|
10
8
|
|
|
11
9
|
{{STATE_MANAGEMENT_DESCRIPTION}}
|
|
12
|
-
|
|
13
10
|
---
|
|
14
|
-
|
|
15
11
|
## 📊 State Categories
|
|
16
12
|
|
|
17
13
|
### 1. Server State (Remote Data)
|
|
@@ -42,9 +38,7 @@ if (error) return <Error message={error.message} />;
|
|
|
42
38
|
|
|
43
39
|
return <UserProfile user={data} />;
|
|
44
40
|
```
|
|
45
|
-
|
|
46
41
|
---
|
|
47
|
-
|
|
48
42
|
### 2. Client State (Local UI State)
|
|
49
43
|
|
|
50
44
|
**Managed by:** {{STATE_MANAGEMENT}}
|
|
@@ -65,9 +59,7 @@ return <UserProfile user={data} />;
|
|
|
65
59
|
// Using {{STATE_MANAGEMENT}}
|
|
66
60
|
{{CLIENT_STATE_EXAMPLE}}
|
|
67
61
|
```
|
|
68
|
-
|
|
69
62
|
---
|
|
70
|
-
|
|
71
63
|
### 3. URL State (Query Params & Routes)
|
|
72
64
|
|
|
73
65
|
**Managed by:** Router + URL
|
|
@@ -93,9 +85,7 @@ const query = searchParams.get('q') || '';
|
|
|
93
85
|
const route = useRoute();
|
|
94
86
|
const query = route.query.q || '';
|
|
95
87
|
```
|
|
96
|
-
|
|
97
88
|
---
|
|
98
|
-
|
|
99
89
|
### 4. Form State
|
|
100
90
|
|
|
101
91
|
**Managed by:** {{FORM_LIBRARY}}
|
|
@@ -110,9 +100,7 @@ const query = route.query.q || '';
|
|
|
110
100
|
// Using {{FORM_LIBRARY}}
|
|
111
101
|
{{FORM_STATE_EXAMPLE}}
|
|
112
102
|
```
|
|
113
|
-
|
|
114
103
|
---
|
|
115
|
-
|
|
116
104
|
## 🏗️ State Architecture
|
|
117
105
|
|
|
118
106
|
### State Location Decision Tree
|
|
@@ -126,9 +114,7 @@ Is data from server?
|
|
|
126
114
|
├─ YES → Use router/query params (URL state)
|
|
127
115
|
└─ NO → Use local component state
|
|
128
116
|
```
|
|
129
|
-
|
|
130
117
|
---
|
|
131
|
-
|
|
132
118
|
## 🎨 {{STATE_MANAGEMENT}} Patterns
|
|
133
119
|
|
|
134
120
|
### Store Structure
|
|
@@ -148,9 +134,7 @@ Is data from server?
|
|
|
148
134
|
```typescript
|
|
149
135
|
{{UPDATE_STATE_EXAMPLE}}
|
|
150
136
|
```
|
|
151
|
-
|
|
152
137
|
---
|
|
153
|
-
|
|
154
138
|
## 🔄 Data Flow
|
|
155
139
|
|
|
156
140
|
### Unidirectional Data Flow
|
|
@@ -191,9 +175,7 @@ const addTodo = (text: string) => {
|
|
|
191
175
|
|
|
192
176
|
// 3. State updated → Component re-renders
|
|
193
177
|
```
|
|
194
|
-
|
|
195
178
|
---
|
|
196
|
-
|
|
197
179
|
## 🚀 Performance Optimization
|
|
198
180
|
|
|
199
181
|
### 1. Avoid Over-Rendering
|
|
@@ -259,9 +241,7 @@ const state = {
|
|
|
259
241
|
}
|
|
260
242
|
};
|
|
261
243
|
```
|
|
262
|
-
|
|
263
244
|
---
|
|
264
|
-
|
|
265
245
|
## 🔐 State Persistence
|
|
266
246
|
|
|
267
247
|
### Local Storage
|
|
@@ -289,9 +269,7 @@ const useThemeStore = create(
|
|
|
289
269
|
)
|
|
290
270
|
);
|
|
291
271
|
```
|
|
292
|
-
|
|
293
272
|
---
|
|
294
|
-
|
|
295
273
|
## 🧪 Testing State
|
|
296
274
|
|
|
297
275
|
### Unit Testing Store Logic
|
|
@@ -329,9 +307,7 @@ test('displays todos from store', () => {
|
|
|
329
307
|
expect(screen.getByText('Todo 2')).toBeInTheDocument();
|
|
330
308
|
});
|
|
331
309
|
```
|
|
332
|
-
|
|
333
310
|
---
|
|
334
|
-
|
|
335
311
|
## ⚠️ Common Pitfalls
|
|
336
312
|
|
|
337
313
|
### 1. Storing Derived Data
|
|
@@ -377,18 +353,16 @@ const globalState = {
|
|
|
377
353
|
notifications: [...]
|
|
378
354
|
};
|
|
379
355
|
```
|
|
380
|
-
|
|
381
356
|
---
|
|
382
|
-
|
|
383
357
|
## 🔗 Related Documents
|
|
384
358
|
|
|
385
359
|
- [AI Instructions](../ai-instructions.md) - State management rules
|
|
386
360
|
- [Component Architecture](components.md) - Component/state interaction
|
|
387
361
|
- [API Integration](api-integration.md) - Server state patterns
|
|
388
362
|
- [Testing Strategy](testing.md) - Testing state logic
|
|
389
|
-
|
|
390
363
|
---
|
|
391
|
-
|
|
392
364
|
**Last Updated:** {{GENERATION_DATE}}
|
|
393
365
|
|
|
394
366
|
**Solution:** {{STATE_MANAGEMENT}}
|
|
367
|
+
|
|
368
|
+
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
# Styling & Design System
|
|
2
2
|
|
|
3
3
|
> CSS architecture, theming, and design patterns for {{PROJECT_NAME}}
|
|
4
|
-
|
|
5
4
|
---
|
|
6
|
-
|
|
7
5
|
## 🎨 Styling Approach
|
|
8
6
|
|
|
9
7
|
**Solution:** {{STYLING_APPROACH}}
|
|
@@ -14,9 +12,7 @@
|
|
|
14
12
|
- **Design Tokens:** {{DESIGN_TOKENS}}
|
|
15
13
|
- **Theme Support:** {{THEME_SUPPORT}}
|
|
16
14
|
- **Responsive Strategy:** {{RESPONSIVE_STRATEGY}}
|
|
17
|
-
|
|
18
15
|
---
|
|
19
|
-
|
|
20
16
|
## 📐 CSS Architecture
|
|
21
17
|
|
|
22
18
|
### Styling Solutions Comparison
|
|
@@ -37,9 +33,7 @@
|
|
|
37
33
|
|
|
38
34
|
**Why this approach:**
|
|
39
35
|
{{STYLING_RATIONALE}}
|
|
40
|
-
|
|
41
36
|
---
|
|
42
|
-
|
|
43
37
|
## 🎨 Design Tokens
|
|
44
38
|
|
|
45
39
|
{{#IF_DESIGN_TOKENS}}
|
|
@@ -159,9 +153,7 @@ const Button = styled.button`
|
|
|
159
153
|
```
|
|
160
154
|
|
|
161
155
|
{{/IF_DESIGN_TOKENS}}
|
|
162
|
-
|
|
163
156
|
---
|
|
164
|
-
|
|
165
157
|
## 🌗 Theming
|
|
166
158
|
|
|
167
159
|
### Theme Implementation: {{THEME_SUPPORT}}
|
|
@@ -260,9 +252,7 @@ useEffect(() => {
|
|
|
260
252
|
```
|
|
261
253
|
|
|
262
254
|
{{/IF_DARK_MODE}}
|
|
263
|
-
|
|
264
255
|
---
|
|
265
|
-
|
|
266
256
|
## 📱 Responsive Design
|
|
267
257
|
|
|
268
258
|
### Breakpoint Strategy
|
|
@@ -339,9 +329,7 @@ export const breakpoints = {
|
|
|
339
329
|
}
|
|
340
330
|
}
|
|
341
331
|
```
|
|
342
|
-
|
|
343
332
|
---
|
|
344
|
-
|
|
345
333
|
## 🧩 Component Styling Patterns
|
|
346
334
|
|
|
347
335
|
### Pattern 1: Compound Variants (Recommended)
|
|
@@ -449,9 +437,7 @@ const Button = styled.button<{ $variant?: 'primary' | 'secondary'; $size?: 'sm'
|
|
|
449
437
|
}
|
|
450
438
|
`;
|
|
451
439
|
```
|
|
452
|
-
|
|
453
440
|
---
|
|
454
|
-
|
|
455
441
|
## ⚡ Performance Optimization
|
|
456
442
|
|
|
457
443
|
### 1. Critical CSS
|
|
@@ -520,9 +506,7 @@ elements.forEach((el, i) => {
|
|
|
520
506
|
el.style.height = heights[i] + 10 + 'px'; // Write all
|
|
521
507
|
});
|
|
522
508
|
```
|
|
523
|
-
|
|
524
509
|
---
|
|
525
|
-
|
|
526
510
|
## ♿ Accessibility in Styling
|
|
527
511
|
|
|
528
512
|
### 1. Focus Indicators
|
|
@@ -569,9 +553,7 @@ const ratio = contrast(textColor, bgColor);
|
|
|
569
553
|
}
|
|
570
554
|
}
|
|
571
555
|
```
|
|
572
|
-
|
|
573
556
|
---
|
|
574
|
-
|
|
575
557
|
## 🎯 Common Patterns
|
|
576
558
|
|
|
577
559
|
### Layout Patterns
|
|
@@ -665,9 +647,7 @@ const ratio = contrast(textColor, bgColor);
|
|
|
665
647
|
animation: spin 1s linear infinite;
|
|
666
648
|
}
|
|
667
649
|
```
|
|
668
|
-
|
|
669
650
|
---
|
|
670
|
-
|
|
671
651
|
## ⚠️ Common Pitfalls
|
|
672
652
|
|
|
673
653
|
### 1. Over-Specificity
|
|
@@ -731,9 +711,7 @@ div.container > ul.list > li.item > a.link {
|
|
|
731
711
|
Content
|
|
732
712
|
</div>
|
|
733
713
|
```
|
|
734
|
-
|
|
735
714
|
---
|
|
736
|
-
|
|
737
715
|
## 🧪 Testing Styles
|
|
738
716
|
|
|
739
717
|
### Visual Regression Testing
|
|
@@ -762,18 +740,16 @@ test('button has no a11y violations', async () => {
|
|
|
762
740
|
expect(results).toHaveNoViolations();
|
|
763
741
|
});
|
|
764
742
|
```
|
|
765
|
-
|
|
766
743
|
---
|
|
767
|
-
|
|
768
744
|
## 🔗 Related Documents
|
|
769
745
|
|
|
770
746
|
- [Component Architecture](components.md) - Component structure
|
|
771
747
|
- [AI Instructions](../ai-instructions.md) - Styling rules
|
|
772
748
|
- [Accessibility Spec](../specs/accessibility.md) - A11y requirements
|
|
773
749
|
- [Testing Strategy](testing.md) - Visual regression tests
|
|
774
|
-
|
|
775
750
|
---
|
|
776
|
-
|
|
777
751
|
**Last Updated:** {{GENERATION_DATE}}
|
|
778
752
|
|
|
779
753
|
**Styling Approach:** {{STYLING_APPROACH}}
|
|
754
|
+
|
|
755
|
+
|