ai-flow-dev 2.2.0 → 2.2.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.
Files changed (74) hide show
  1. package/README.md +28 -24
  2. package/dist/cli.js +228 -418
  3. package/dist/cli.js.map +1 -1
  4. package/package.json +1 -1
  5. package/prompts/backend/flow-build-phase-0.md +286 -4
  6. package/prompts/backend/flow-build-phase-1.md +19 -0
  7. package/prompts/backend/flow-build-phase-2.md +19 -0
  8. package/prompts/backend/flow-build-phase-3.md +19 -0
  9. package/prompts/backend/flow-build-phase-4.md +19 -0
  10. package/prompts/backend/flow-build-phase-5.md +19 -0
  11. package/prompts/backend/flow-build-phase-6.md +19 -0
  12. package/prompts/backend/flow-build-phase-7.md +19 -0
  13. package/prompts/backend/flow-build-phase-9.md +14 -0
  14. package/prompts/backend/flow-build.md +2 -0
  15. package/prompts/backend/flow-check-review.md +20 -0
  16. package/prompts/backend/flow-check-test.md +14 -0
  17. package/prompts/backend/flow-check.md +67 -0
  18. package/prompts/backend/flow-commit.md +53 -0
  19. package/prompts/backend/flow-docs-sync.md +55 -53
  20. package/prompts/backend/flow-work-feature.md +42 -0
  21. package/prompts/backend/flow-work-fix.md +33 -0
  22. package/prompts/backend/flow-work-refactor.md +32 -0
  23. package/prompts/backend/flow-work-resume.md +32 -0
  24. package/prompts/backend/flow-work.md +129 -0
  25. package/prompts/frontend/flow-build-phase-0.md +363 -35
  26. package/prompts/frontend/flow-build-phase-1.md +433 -404
  27. package/prompts/frontend/flow-build-phase-2.md +508 -872
  28. package/prompts/frontend/flow-build-phase-3.md +629 -562
  29. package/prompts/frontend/flow-build-phase-4.md +438 -382
  30. package/prompts/frontend/flow-build-phase-5.md +559 -362
  31. package/prompts/frontend/flow-build-phase-6.md +383 -452
  32. package/prompts/frontend/flow-build-phase-7.md +818 -392
  33. package/prompts/frontend/flow-build-phase-9.md +14 -0
  34. package/prompts/frontend/flow-build.md +2 -0
  35. package/prompts/frontend/flow-check-review.md +20 -0
  36. package/prompts/frontend/flow-check-test.md +14 -0
  37. package/prompts/frontend/flow-check.md +67 -0
  38. package/prompts/frontend/flow-commit.md +53 -0
  39. package/prompts/frontend/flow-docs-sync.md +39 -35
  40. package/prompts/frontend/flow-work-feature.md +42 -0
  41. package/prompts/frontend/flow-work-fix.md +33 -0
  42. package/prompts/frontend/flow-work-refactor.md +32 -0
  43. package/prompts/frontend/flow-work-resume.md +32 -0
  44. package/prompts/frontend/flow-work.md +129 -0
  45. package/prompts/mobile/flow-build-phase-0.md +366 -37
  46. package/prompts/mobile/flow-build-phase-1.md +438 -493
  47. package/prompts/mobile/flow-build-phase-2.md +458 -464
  48. package/prompts/mobile/flow-build-phase-3.md +613 -487
  49. package/prompts/mobile/flow-build-phase-4.md +439 -258
  50. package/prompts/mobile/flow-build-phase-5.md +582 -250
  51. package/prompts/mobile/flow-build-phase-6.md +389 -359
  52. package/prompts/mobile/flow-build-phase-7.md +871 -285
  53. package/prompts/mobile/flow-build-phase-9.md +14 -0
  54. package/prompts/mobile/flow-build.md +2 -0
  55. package/prompts/mobile/flow-check-review.md +20 -0
  56. package/prompts/mobile/flow-check-test.md +14 -0
  57. package/prompts/mobile/flow-check.md +67 -0
  58. package/prompts/mobile/flow-commit.md +53 -0
  59. package/prompts/mobile/flow-docs-sync.md +39 -40
  60. package/prompts/mobile/flow-work-feature.md +42 -0
  61. package/prompts/mobile/flow-work-fix.md +33 -0
  62. package/prompts/mobile/flow-work-refactor.md +32 -0
  63. package/prompts/mobile/flow-work-resume.md +32 -0
  64. package/prompts/mobile/flow-work.md +129 -0
  65. package/prompts/shared/smart-skip-preflight.md +214 -0
  66. package/templates/AGENT.template.md +13 -3
  67. package/templates/backend/.clauderules.template +5 -4
  68. package/templates/backend/.cursorrules.template +1 -1
  69. package/prompts/backend/flow-dev-commit.md +0 -829
  70. package/prompts/backend/flow-dev-feature.md +0 -1948
  71. package/prompts/backend/flow-dev-fix.md +0 -952
  72. package/prompts/backend/flow-dev-refactor.md +0 -690
  73. package/prompts/backend/flow-dev-review.md +0 -372
  74. package/prompts/backend/flow-dev-work.md +0 -1081
@@ -1,497 +1,553 @@
1
- # Phase 4: Styling & Design System
1
+ ## PHASE 4: Security & Authentication (15-20 min)
2
2
 
3
- **Duration:** 15-20 minutes
4
- **Questions:** ~11 questions
5
- **Output:** docs/styling.md, parts of ai-instructions.md
6
- ---
7
- ## 🎯 Objective
3
+ > **Order for this phase:** 4.1 → 4.2 → 4.3 → 4.4 → 4.5 → 4.6 → 4.7 → 4.8 → 4.9 → 4.10 → 4.11
8
4
 
9
- Define your styling architecture and design system:
5
+ > **📌 Scope-based behavior:**
6
+ >
7
+ > - **MVP:** Ask 4.1-4.5 only (auth basics + CORS), skip 4.6-4.11 (advanced security), mark as "TBD"
8
+ > - **Production-Ready:** Ask 4.1-4.8 and 4.11, skip or simplify 4.9 (compliance) and 4.10 (audit logging)
9
+ > - **Enterprise:** Ask all questions 4.1-4.11 with emphasis on compliance and audit trails
10
10
 
11
- 1. What CSS approach will you use?
12
- 2. Do you need design tokens?
13
- 3. Will you support theming?
14
- 4. What's your responsive strategy?
15
- 5. How will you organize styles?
16
- ---
17
- ## 📋 Questions
11
+ ### Objective
18
12
 
19
- ### Question 4.1: Styling Approach
13
+ Define security policies, authentication, authorization, and compliance requirements.
20
14
 
21
- **What CSS architecture will you use?**
15
+ ---
22
16
 
23
- A) **Tailwind CSS** (Recommended for most)
17
+ ## 🔍 Pre-Flight Check (Smart Skip Logic)
24
18
 
25
- - Features: Utility-first, rapid development, small production bundle
26
- - Pros: Fast prototyping, consistent design, great DX
27
- - Cons: Verbose HTML, learning curve
28
- - Best for: Most modern apps
29
- - Bundle: ~10KB (purged)
19
+ > 📎 **Reference:** See [prompts/shared/smart-skip-preflight.md](../shared/smart-skip-preflight.md) for the complete smart skip logic.
30
20
 
31
- B) 🔥 **CSS Modules**
21
+ **Execute Pre-Flight Check for Phase 4:**
32
22
 
33
- - Features: Scoped CSS, traditional CSS syntax
34
- - Pros: Familiar, type-safe (TypeScript), no runtime
35
- - Cons: More manual work, no design system out of box
36
- - Best for: Teams preferring traditional CSS
37
- - Bundle: Variable (your CSS only)
23
+ - **Target File**: `specs/security.md`
24
+ - **Phase Name**: "SECURITY & AUTHENTICATION"
25
+ - **Key Items**: Auth strategy, encryption, security patterns, compliance
26
+ - **Typical Gaps**: Compliance requirements, audit logging, security policies
38
27
 
39
- C) **Styled Components**
28
+ **Proceed with appropriate scenario based on audit data from `.ai-flow/cache/audit-data.json`**
40
29
 
41
- - Features: CSS-in-JS, component-scoped styles
42
- - Pros: Dynamic styling, props-based theming, scoped by default
43
- - Cons: Runtime cost, larger bundle
44
- - Best for: Component libraries, dynamic themes
45
- - Bundle: ~16KB
30
+ ---
46
31
 
47
- D) **Emotion**
32
+ ## Phase 4 Questions (Full Mode)
48
33
 
49
- - Features: CSS-in-JS, faster than Styled Components
50
- - Pros: Better performance than SC, both runtime and compile-time
51
- - Cons: Still has runtime overhead
52
- - Best for: Performance-critical CSS-in-JS
53
- - Bundle: ~11KB
34
+ **4.1 Authentication Method**
54
35
 
55
- E) **Sass/SCSS**
56
-
57
- - Features: CSS preprocessor, variables, mixins
58
- - Pros: Mature, powerful, compile-time
59
- - Cons: Global scope (without modules), manual optimization
60
- - Best for: Legacy projects, traditional workflows
61
- - Bundle: Variable
62
-
63
- F) **Vanilla Extract**
64
-
65
- - Features: Zero-runtime CSS-in-TS
66
- - Pros: Type-safe, no runtime, great DX
67
- - Cons: Newer, smaller ecosystem
68
- - Best for: Type safety + performance
69
- - Bundle: 0KB runtime
70
-
71
- G) **UnoCSS**
72
-
73
- - Features: Atomic CSS engine, faster than Tailwind
74
- - Pros: Extremely fast, flexible, smaller bundle
75
- - Cons: Newer, smaller community
76
- - Best for: Performance-critical apps
77
- - Bundle: ~5KB
78
-
79
- **Your answer:**
80
- ---
81
- ### Question 4.2: Component Library / UI Kit
82
-
83
- **Will you use a pre-built component library?**
84
-
85
- #### React Options
86
-
87
- A) ⭐ **None (Custom Components)**
88
-
89
- - Build everything from scratch
90
- - Best for: Full design control, unique designs
91
-
92
- B) 🔥 **shadcn/ui** (Unstyled, customizable)
93
-
94
- - Features: Copy-paste components, Radix UI primitives
95
- - Best for: Tailwind users, full customization
96
-
97
- C) **Material UI (MUI)**
98
-
99
- - Features: Material Design, comprehensive, mature
100
- - Best for: Google Material Design aesthetic
101
- - Bundle: ~90KB
102
-
103
- D) **Chakra UI**
104
-
105
- - Features: Accessible, composable, themeable
106
- - Best for: Rapid development, accessibility
107
- - Bundle: ~50KB
108
-
109
- E) **Ant Design**
110
-
111
- - Features: Enterprise-focused, comprehensive
112
- - Best for: Admin panels, dashboards, Chinese market
113
- - Bundle: ~120KB
114
-
115
- F) **Mantine**
116
-
117
- - Features: Modern, hooks-based, feature-rich
118
- - Best for: Developer experience, rapid prototyping
119
- - Bundle: ~40KB
120
-
121
- #### Vue Options
122
-
123
- A) **None (Custom Components)**
124
- B) 🔥 **Vuetify** - Material Design for Vue
125
- C) **Quasar** - Full framework with components
126
- D) **PrimeVue** - Rich component library
127
- E) **Element Plus** - Enterprise UI library
128
-
129
- #### Angular Options
130
-
131
- A) **None (Custom Components)**
132
- B) ⭐ **Angular Material** - Official Material Design
133
- C) **PrimeNG** - Rich component library
134
- D) **NG-ZORRO** - Ant Design for Angular
135
-
136
- **Your answer:**
137
- ---
138
- ### Question 4.3: Design Tokens
139
-
140
- **Will you use design tokens?**
141
-
142
- Design tokens = Single source of truth for colors, spacing, typography, etc.
143
-
144
- A) ⭐ **Yes, comprehensive design tokens** (Recommended)
145
-
146
- - Define colors, spacing, typography, shadows, etc.
147
- - Best for: Design consistency, theming support
148
- - Example: Tailwind config, CSS variables, TypeScript constants
149
-
150
- B) **Yes, basic tokens only**
151
-
152
- - Just colors and spacing
153
- - Best for: Simple apps
154
-
155
- C) **No tokens**
156
-
157
- - Hardcoded values
158
- - Best for: Prototypes, MVPs
159
-
160
- **Your answer:**
161
-
162
- **If yes, what will be tokenized?** (Select all that apply)
163
-
164
- - Colors
165
- - Spacing (padding, margin, gaps)
166
- - Typography (fonts, sizes, weights)
167
- - Shadows
168
- - Border radius
169
- - Transitions/animations
170
- - Breakpoints
171
- ---
172
- ### Question 4.4: Color System
173
-
174
- **How will you define your color palette?**
36
+ ```
37
+ How will users authenticate?
175
38
 
176
- A) ⭐ **Tailwind-style scales** (50-900)
39
+ A) ⭐ JWT (JSON Web Tokens) - Recommended for APIs
177
40
 
178
- - Example: `gray-50`, `gray-100`, ..., `gray-900`
179
- - Example: `blue-500`, `blue-600`, etc.
180
- - Best for: Tailwind CSS, comprehensive palettes
181
- - Generates: 10 shades per color
41
+ - Stateless, scalable
42
+ - Access + Refresh token pattern
182
43
 
183
- B) **Semantic colors**
44
+ B) 🔥 Session-based - Traditional web apps
184
45
 
185
- - Example: `primary`, `secondary`, `success`, `error`, `warning`
186
- - Best for: Simple apps, component libraries
187
- - Generates: 5-7 colors
46
+ - Server-side sessions
47
+ - Cookie-based
188
48
 
189
- C) **Custom color system**
49
+ C) OAuth 2.0 / OpenID Connect - External providers
190
50
 
191
- - Your own naming and structure
192
- - Best for: Unique design systems
51
+ - "Sign in with Google/GitHub/etc."
52
+ - Delegated authentication
193
53
 
194
- **Your answer:**
54
+ D) 🏆 Multi-factor (MFA) - Enterprise security
195
55
 
196
- **Primary brand colors (hex codes):**
56
+ - OTP, SMS, authenticator app
57
+ - Required or optional?
197
58
 
198
- - Primary: #**\_\_**
199
- - Secondary (optional): #**\_\_**
200
- - Accent (optional): #**\_\_**
201
- ---
202
- ### Question 4.5: Typography System
59
+ E) API Keys - Service-to-service
203
60
 
204
- **How will you handle typography?**
61
+ - Simple, stateless
62
+ - Limited use cases
205
63
 
206
- A) **Type scale (Tailwind-style)**
64
+ Your choice: __
65
+ Why?
66
+ ```
207
67
 
208
- - Sizes: xs, sm, base, lg, xl, 2xl, 3xl, 4xl, 5xl, 6xl, 7xl, 8xl, 9xl
209
- - Best for: Responsive, scalable typography
210
- - Example: `text-sm`, `text-lg`
68
+ **4.2 JWT Configuration (if using JWT)**
211
69
 
212
- B) **Semantic headings**
70
+ ```
71
+ JWT token configuration:
72
+
73
+ Access Token:
74
+ - Lifetime: __ (recommended: 15min - 1hour)
75
+ - Algorithm: __ (recommended: RS256 or HS256)
76
+
77
+ Refresh Token:
78
+ - Lifetime: __ (recommended: 7-30 days)
79
+ - Storage: [httpOnly cookie / localStorage / database]
80
+ - Rotation strategy: [rotate on use / rotate periodically / no rotation]
81
+
82
+ Token claims to include:
83
+ - userId ✅
84
+ - email ✅
85
+ - roles ✅
86
+ - Custom: __
87
+ ```
213
88
 
214
- - Sizes: h1, h2, h3, h4, h5, h6, body, caption
215
- - Best for: Content-heavy sites, traditional hierarchy
89
+ **4.3 Authorization Model**
216
90
 
217
- C) **Custom scale**
91
+ ```
92
+ How will you manage permissions?
218
93
 
219
- - Your own naming and sizes
94
+ A) Role-Based Access Control (RBAC)
95
+ - Users have roles (admin, user, moderator, etc.)
96
+ - Roles have permissions
97
+ - Simple and common
220
98
 
221
- **Your answer:**
99
+ B) 🏆 Attribute-Based Access Control (ABAC)
100
+ - Fine-grained based on attributes
101
+ - Complex rules
102
+ - Enterprise use cases
222
103
 
223
- **Font families:**
104
+ C) 🔒 Resource-based (Ownership)
105
+ - Users can only access their own resources
106
+ - Simple projects
224
107
 
225
- - Heading font: ******\_\_\_****** (e.g., Inter, Poppins)
226
- - Body font: ********\_******** (e.g., Inter, Roboto)
227
- - Mono font (optional): **\_\_\_** (e.g., Fira Code)
108
+ D) 🌐 Multi-tenant with role hierarchy
109
+ - Organization Teams Users
110
+ - Complex enterprise systems
228
111
 
229
- **Font loading strategy:**
230
- A) Google Fonts CDN
231
- B) Self-hosted fonts (better performance)
232
- C) System fonts only (fastest)
233
- ---
234
- ### Question 4.6: Theming Support
112
+ Your choice: __
235
113
 
236
- **Do you need theme support (dark mode, multiple themes)?**
114
+ List the roles you'll need:
115
+ -
116
+ -
237
117
 
238
- A) **Dark mode only**
118
+ List key permissions:
119
+ -
120
+ -
121
+ ```
239
122
 
240
- - Light + Dark themes
241
- - Best for: Modern apps, user preference
242
- - Implementation: CSS variables, class toggle
123
+ **4.4 Password Policy**
243
124
 
244
- B) **Multiple themes**
125
+ ```
126
+ Password requirements:
127
+
128
+ A) ⭐ Recommended Policy
129
+ - Minimum 8 characters
130
+ - At least 1 uppercase, 1 lowercase, 1 number
131
+ - Special characters encouraged but not required
132
+ - No maximum length limit
133
+ - Hash with bcrypt (12 rounds) or argon2
134
+
135
+ B) 🏆 Strong Policy (Enterprise)
136
+ - Minimum 12 characters
137
+ - Uppercase, lowercase, number, special char required
138
+ - Password expiration every 90 days
139
+ - Password history (can't reuse last 5)
140
+
141
+ C) 🔓 Simple Policy
142
+ - Minimum 6 characters
143
+ - No complexity requirements
144
+ - Good for low-risk apps
145
+
146
+ Your choice: __
147
+
148
+ Hashing algorithm:
149
+ A) ⭐ bcrypt (rounds: 10-12) - Recommended
150
+ B) argon2 - More secure, newer
151
+ C) scrypt - Good alternative
152
+ ```
245
153
 
246
- - Example: Default, Dark, High Contrast, Brand A, Brand B
247
- - Best for: White-label apps, multi-tenant
154
+ **4.5 Rate Limiting**
248
155
 
249
- C) **No theming**
156
+ ```
157
+ Will you implement rate limiting?
250
158
 
251
- - Single theme only
252
- - Best for: MVPs, simpler implementation
159
+ A) ⭐ Yes - Recommended for all public APIs
253
160
 
254
- **Your answer:**
161
+ Rate limits by endpoint type:
162
+ - Authentication endpoints: ** requests per ** (e.g., 5 per 15 min)
163
+ - Public read endpoints: ** requests per ** (e.g., 100 per minute)
164
+ - Write endpoints: ** requests per ** (e.g., 30 per minute)
165
+ - Admin endpoints: ** requests per ** (e.g., 1000 per minute)
255
166
 
256
- **If theming selected:**
167
+ Rate limiting strategy:
168
+ A) IP-based
169
+ B) User/API key-based
170
+ C) Both
257
171
 
258
- **Theme switching method:**
259
- A) User preference (toggle button)
260
- B) System preference only (prefers-color-scheme)
261
- C) Both (respect system, allow override)
172
+ Tool:
173
+ A) express-rate-limit / @nestjs/throttler
174
+ B) Redis-based rate limiting
175
+ C) API Gateway (AWS, Kong, etc.)
176
+ ```
262
177
 
263
- **Theme persistence:**
264
- A) localStorage
265
- B) User account setting (backend)
266
- C) No persistence (reset on reload)
267
- ---
268
- ### Question 4.7: Responsive Breakpoints
178
+ **4.6 CORS Policy**
269
179
 
270
- **What breakpoint strategy will you use?**
180
+ ```
181
+ CORS (Cross-Origin Resource Sharing) configuration:
271
182
 
272
- A) ⭐ **Tailwind defaults** (Recommended)
183
+ Allowed origins:
184
+ A) ⭐ Specific domains - https://myapp.com, https://admin.myapp.com
185
+ B) 🔧 Development only - localhost:3000, localhost:5173
186
+ C) ⚠️ Wildcard (*) - Allow all (NOT recommended for production)
273
187
 
274
- - sm: 640px
275
- - md: 768px
276
- - lg: 1024px
277
- - xl: 1280px
278
- - 2xl: 1536px
188
+ Your allowed origins:
189
+ -
279
190
 
280
- B) **build-style**
191
+ Allowed methods: [GET, POST, PUT, PATCH, DELETE, OPTIONS]
192
+ Credentials: [true/false] - Allow cookies/auth headers
193
+ Max age: __ seconds (cache preflight)
194
+ ```
281
195
 
282
- - xs: 0px
283
- - sm: 576px
284
- - md: 768px
285
- - lg: 992px
286
- - xl: 1200px
196
+ **4.7 Data Encryption**
287
197
 
288
- C) **Custom breakpoints**
198
+ ```
199
+ Encryption requirements:
200
+
201
+ In Transit (HTTPS/TLS):
202
+ A) ✅ Yes, always - TLS 1.2+ required ⭐
203
+ B) Development only HTTP, production HTTPS
204
+ C) Optional
205
+
206
+ At Rest (Database/Files):
207
+ A) ⭐ Yes, encrypt sensitive fields - PII, payment info, secrets
208
+ B) 🏆 Yes, full database encryption - Enterprise requirement
209
+ C) No encryption - Low-risk data only
210
+
211
+ Fields to encrypt:
212
+ -
213
+ -
214
+
215
+ Encryption method:
216
+ A) AES-256-GCM (symmetric)
217
+ B) Database-level encryption
218
+ C) Application-level encryption
219
+ ```
289
220
 
290
- - Define your own
221
+ **4.8 Security Headers**
291
222
 
292
- D) **No breakpoints (fluid)**
223
+ ```
224
+ Which security headers will you implement?
293
225
 
294
- - Use relative units only (%, vw, etc.)
226
+ A) All recommended headers (use helmet.js or equivalent)
227
+ - Content-Security-Policy
228
+ - X-Frame-Options: DENY
229
+ - X-Content-Type-Options: nosniff
230
+ - Strict-Transport-Security (HSTS)
231
+ - X-XSS-Protection
295
232
 
296
- **Your answer:**
297
- ---
298
- ### Question 4.8: Spacing System
233
+ B) Basic headers only
234
+ C) None (not recommended)
235
+ ```
299
236
 
300
- **What spacing scale will you use?**
237
+ **4.9 Compliance Requirements**
301
238
 
302
- A) ⭐ **4px grid (Tailwind-style)**
239
+ ```
240
+ Does your project need to comply with specific regulations or standards?
241
+
242
+ Some projects must follow legal requirements or industry standards. If you're not sure, you can select "None" and add compliance requirements later.
243
+
244
+ Select all that apply:
245
+
246
+ A) 🌍 GDPR (General Data Protection Regulation)
247
+ What it is: EU data privacy regulation
248
+ When it applies: If you process personal data of users in the European Union
249
+ What it means: Users have rights to access, delete, and export their data
250
+ Key requirements:
251
+ - Right to access data (users can request their data)
252
+ - Right to deletion (users can request data removal)
253
+ - Data portability (users can export their data)
254
+ - Consent management (explicit consent for data processing)
255
+ Example: "We serve users in Germany, so we need GDPR compliance"
256
+
257
+ B) 🏥 HIPAA (Health Insurance Portability and Accountability Act)
258
+ What it is: US healthcare data protection law
259
+ When it applies: If you handle Protected Health Information (PHI) - medical records, health data
260
+ What it means: Strict rules for protecting patient health information
261
+ Key requirements:
262
+ - PHI protection (encryption, access controls)
263
+ - Audit logs (track who accessed what health data)
264
+ - Encryption requirements (data must be encrypted)
265
+ Example: "We're building a telemedicine platform that stores patient records"
266
+
267
+ C) 💳 PCI-DSS (Payment Card Industry Data Security Standard)
268
+ What it is: Security standard for credit card processing
269
+ When it applies: If you process, store, or transmit credit card information
270
+ What it means: Strict security rules to protect cardholder data
271
+ Key requirements:
272
+ - Never store CVV (security code on card)
273
+ - Tokenize card numbers (use tokens instead of real numbers)
274
+ - Secure transmission (encrypted connections required)
275
+ Example: "We process credit card payments directly (not using Stripe/PayPal)"
276
+
277
+ D) 🏢 SOC 2 (System and Organization Controls 2)
278
+ What it is: Security and compliance standard for SaaS companies
279
+ When it applies: If you're selling B2B SaaS and need to prove security to enterprise customers
280
+ What it means: Documented security controls and processes
281
+ Key requirements:
282
+ - Security controls (documented security measures)
283
+ - Audit trails (logs of all security-relevant actions)
284
+ - Access controls (who can access what)
285
+ Example: "We're selling to Fortune 500 companies who require SOC 2 certification"
286
+
287
+ E) 🇺🇸 CCPA (California Consumer Privacy Act)
288
+ What it is: California state privacy law
289
+ When it applies: If you have California users and meet certain thresholds (revenue/users)
290
+ What it means: California users have privacy rights
291
+ Key requirements:
292
+ - Right to know what data is collected
293
+ - Right to delete data
294
+ - Right to opt-out of data sales
295
+ Example: "We have users in California and meet the revenue threshold"
296
+
297
+ F) None - No specific compliance requirements
298
+ Select this if you're not sure or don't need compliance yet
299
+
300
+ Selected: __
301
+
302
+ For each selected, list specific requirements that apply to your project:
303
+
304
+ Example for GDPR:
305
+ - Must allow users to download all their data in JSON format
306
+ - Must completely delete user data when requested (not just soft delete)
307
+ - Need cookie consent banner for EU users
308
+ - Privacy policy must be accessible and up-to-date
309
+
310
+ Example for SOC 2:
311
+ - Need 90-day audit log retention
312
+ - Quarterly access control reviews required
313
+ - Security incident response procedures documented
314
+ - Continuous monitoring of administrative actions
315
+ ```
303
316
 
304
- - 0, 1 (4px), 2 (8px), 3 (12px), 4 (16px), 5 (20px), 6 (24px), 8 (32px), etc.
305
- - Best for: Most apps, consistent spacing
317
+ **4.10 Logging & Audit Trail**
306
318
 
307
- B) **8px grid**
319
+ ```
320
+ What security events will you log?
308
321
 
309
- - 0, 8, 16, 24, 32, 40, 48, 56, 64...
310
- - Best for: Simpler scale, larger spacing
322
+ A) Authentication events
323
+ - Login success/failure
324
+ - Password changes
325
+ - Account creation
311
326
 
312
- C) **Custom scale**
327
+ B) Authorization events
328
+ - Permission denied
329
+ - Role changes
313
330
 
314
- - Your own spacing values
331
+ C) Data access
332
+ - Sensitive data views
333
+ - Exports/downloads
315
334
 
316
- **Your answer:**
317
- ---
318
- ### Question 4.9: Animation & Transitions
335
+ D) ✅ Data modifications
336
+ - Create/Update/Delete operations
337
+ - Who, what, when
319
338
 
320
- **How will you handle animations?**
339
+ Log retention: __ days (recommended: 90+ days)
340
+ Log storage: [Database / File system / External service (CloudWatch, Datadog)]
341
+ ```
321
342
 
322
- A) **CSS transitions only**
343
+ **4.11 API Keys Management**
323
344
 
324
- - Simple hover effects, state changes
325
- - Best for: Most apps, good performance
326
- - Example: `transition-colors`, `transition-all`
345
+ ```
346
+ Will you use API keys for service-to-service authentication?
347
+
348
+ A) ⭐ Yes - API keys for programmatic access
349
+ B) No - JWT/Sessions only
350
+
351
+ If yes:
352
+ - Key format: [Prefix + random string, UUID, etc.]
353
+ - Key length: __ characters
354
+ - Storage: [Hashed in database, Plain text (not recommended)]
355
+ - Hashing algorithm: [bcrypt, SHA-256, etc.]
356
+
357
+ Key rotation:
358
+ A) ⭐ Manual rotation - Rotate on demand
359
+ B) Automatic rotation - Rotate every __ days
360
+ C) No rotation
361
+
362
+ Key revocation:
363
+ - Process: __
364
+ - Reasons: [Compromised, Expired, User request, Security incident]
365
+
366
+ Rate limiting by API key tier:
367
+ - Free tier: __ requests per __
368
+ - Paid tier: __ requests per __
369
+ - Enterprise: __ requests per __
370
+ ```
327
371
 
328
- B) **CSS transitions + keyframe animations**
372
+ **4.12 Dependency Security**
329
373
 
330
- - Add loading spinners, fade-ins, etc.
331
- - Best for: Modern UX
374
+ ```
375
+ How will you manage dependency security?
376
+
377
+ A) ⭐ Automated scanning - Regular security audits (npm audit, Snyk, Dependabot)
378
+ B) Manual scanning - Check vulnerabilities manually
379
+ C) No scanning - Not recommended
380
+
381
+ Scanning frequency:
382
+ A) ⭐ On every install/update
383
+ B) Daily automated scans
384
+ C) Weekly scans
385
+ D) Monthly scans
386
+
387
+ Vulnerability response:
388
+ - Critical: Fix within __ hours
389
+ - High: Fix within __ days
390
+ - Medium: Fix within __ days
391
+ - Low: Fix in next release
392
+
393
+ Tools:
394
+ - Dependency scanner: __
395
+ - Security alerts: [GitHub Dependabot, Snyk, npm audit, etc.]
396
+ ```
332
397
 
333
- C) **Animation library** (Framer Motion, GSAP, etc.)
398
+ **4.13 Input Validation & Sanitization**
334
399
 
335
- - Complex animations, gestures, page transitions
336
- - Best for: Animation-heavy apps, marketing sites
337
- - Example: Framer Motion for React
400
+ ```
401
+ Input validation strategy:
338
402
 
339
- D) **Minimal animations**
403
+ A) Strict validation with DTOs/Schemas (Recommended)
404
+ - Use validation library: [class-validator/Zod/Pydantic/Joi from Phase 3.6]
405
+ - Reject unknown fields: [yes/no]
406
+ - Type coercion: [strict/lenient]
340
407
 
341
- - Accessibility-first, respect prefers-reduced-motion
342
- - Best for: Accessibility-critical apps
408
+ B) Manual validation in services
409
+ - Custom validation logic
410
+ - More flexible but error-prone
343
411
 
344
- **Your answer:**
412
+ Sanitization rules:
345
413
 
346
- **If animations used:**
414
+ A) Sanitize all string inputs (XSS prevention)
415
+ - Strip HTML tags: [yes/no]
416
+ - Escape special characters: [yes/no]
417
+ - Library: [DOMPurify/validator.js/bleach]
347
418
 
348
- **Respect prefers-reduced-motion?**
349
- A) Yes (disable/reduce animations for users who prefer it)
350
- B) No
351
- ---
352
- ### Question 4.10: CSS Organization
419
+ B) ✅ SQL Injection prevention
420
+ - Use parameterized queries (ORM handles this automatically)
421
+ - Never concatenate user input in queries
353
422
 
354
- **How will you organize your stylesheets?**
423
+ Request size limits:
355
424
 
356
- A) **Component-scoped styles**
425
+ - Max JSON body size: __ MB (recommended: 1-10 MB)
426
+ - Max file upload size: __ MB (recommended: 10-50 MB)
427
+ - Max URL length: __ characters (recommended: 2048)
357
428
 
358
- - Each component has its own style file
359
- - Example: `Button.tsx` + `Button.module.css`
360
- - Best for: Component libraries, modularity
429
+ File upload validation (if applicable from Phase 3.9):
361
430
 
362
- B) **Utility-first (Tailwind)**
431
+ - Allowed file types: [jpg, png, pdf, etc.]
432
+ - MIME type validation: [yes/no - verify actual content matches extension]
433
+ - File content validation: [yes/no - check file headers]
434
+ - Virus scanning: [yes/no - ClamAV, VirusTotal API]
435
+ - Filename sanitization: [yes/no - remove special characters, limit length]
363
436
 
364
- - No separate stylesheets, classes in JSX
365
- - Best for: Tailwind CSS users
437
+ Content-Type enforcement:
366
438
 
367
- C) **Global + Component**
439
+ A) Strict - Reject if Content-Type doesn't match body (recommended)
440
+ B) Lenient - Accept common mismatches (application/json vs text/plain)
441
+ C) No validation
368
442
 
369
- - Global base styles + component styles
370
- - Best for: Hybrid approach
443
+ Validation approach:
371
444
 
372
- D) **Feature-based**
445
+ A) ⭐ Whitelist - Only allow known good inputs (recommended)
446
+ - Define allowed values explicitly
447
+ - Reject everything else
373
448
 
374
- - Styles organized by feature/page
375
- - Example: `features/auth/styles.css`
376
- - Best for: Larger apps
449
+ B) Blacklist - Block known bad inputs (not recommended)
450
+ - Easy to bypass
451
+ - Incomplete protection
377
452
 
378
- **Your answer:**
379
- ---
380
- ### Question 4.11: Accessibility (A11y) Styling
453
+ Special character handling:
381
454
 
382
- **What accessibility level will you target?**
455
+ - Allow special characters in: [names, descriptions, etc.]
456
+ - Escape/encode for: [HTML output, SQL queries, shell commands]
457
+ - Reject in: [IDs, slugs, filenames]
458
+ ```
383
459
 
384
- A) **WCAG 2.1 Level AA** (Recommended)
460
+ ### Phase 4 Output
385
461
 
386
- - Color contrast ratio: 4.5:1 (normal text), 3:1 (large text)
387
- - Focus indicators visible
388
- - Best for: Most apps, legal compliance
462
+ ```
463
+ 📋 PHASE 4 SUMMARY:
464
+
465
+ Authentication: [method]
466
+ JWT Config: [if applicable - access/refresh token lifetimes, algorithm, storage]
467
+ Authorization: [RBAC/ABAC/etc.]
468
+ Roles: [list]
469
+ Permissions: [key permissions defined]
470
+ Password Policy: [requirements and hashing algorithm]
471
+ Rate Limiting: [yes/no + limits by endpoint type]
472
+ CORS: [origins, methods, credentials, max-age]
473
+ Encryption: [in-transit + at-rest + fields to encrypt]
474
+ Security Headers: [list]
475
+ Compliance: [requirements with specific controls]
476
+ Audit Logging: [events logged + retention + storage]
477
+ API Keys Management: [yes/no + format + rotation + revocation + rate limiting]
478
+ Dependency Security: [scanning tool + frequency + vulnerability response]
479
+ Input Validation: [strategy + sanitization rules + size limits + file upload validation + whitelist/blacklist approach]
480
+
481
+ Is this correct? (Yes/No)
482
+ ```
483
+ ---
484
+ ### 📄 Generate Phase 4 Documents
389
485
 
390
- B) **WCAG 2.1 Level AAA**
486
+ **Before starting generation:**
391
487
 
392
- - Color contrast ratio: 7:1 (normal text), 4.5:1 (large text)
393
- - More stringent requirements
394
- - Best for: Government, healthcare, education
488
+ ```
489
+ 📖 Loading context from previous phases...
490
+ ✅ Re-reading project-brief.md
491
+ ✅ Re-reading docs/data-model.md
492
+ ✅ Re-reading docs/architecture.md
493
+ ✅ Re-reading ai-instructions.md
494
+ ```
395
495
 
396
- C) **Basic accessibility**
496
+ **Generate documents automatically:**
397
497
 
398
- - Semantic HTML, keyboard navigation
399
- - Best for: MVPs, internal tools
498
+ **1. `specs/security.md`**
400
499
 
401
- D) **No specific target**
500
+ - Use template: `.ai-flow/templates/specs/security.template.md`
501
+ - Fill with all security policies, authentication, authorization
502
+ - Write to: `specs/security.md`
402
503
 
403
- - Best effort only
504
+ **2. Update `ai-instructions.md`**
404
505
 
405
- **Your answer:**
506
+ - Add security rules to NEVER/ALWAYS sections
507
+ - Add authentication/authorization patterns
406
508
 
407
- **A11y features to include:**
509
+ ```
510
+ ✅ Generated: specs/security.md
511
+ ✅ Updated: ai-instructions.md (security rules added)
408
512
 
409
- - [ ] Focus indicators (outline on keyboard focus)
410
- - [ ] High contrast mode support
411
- - [ ] Text resizing support (up to 200%)
412
- - [ ] Screen reader optimizations
413
- - [ ] Reduced motion support
414
- ---
415
- ## 📊 Phase 4 Summary
513
+ Documents have been created with all Phase 4 information.
416
514
 
417
- ```
418
- ---
419
- 📋 PHASE 4 SUMMARY: STYLING & DESIGN
420
- ---
421
- Styling Approach: [Answer from 4.1]
422
- Component Library: [Answer from 4.2]
423
- Design Tokens: [Answer from 4.3]
424
- Color System: [Answer from 4.4]
425
- Typography: [Answer from 4.5]
426
- Theming: [Answer from 4.6]
427
- Breakpoints: [Answer from 4.7]
428
- Spacing System: [Answer from 4.8]
429
- Animations: [Answer from 4.9]
430
- CSS Organization: [Answer from 4.10]
431
- Accessibility: [Answer from 4.11]
515
+ 📝 Would you like to make any corrections before continuing?
432
516
 
433
- Is this correct? (Y/n)
517
+ If yes: Edit the files and type "ready" when done. I'll re-read them.
518
+ → If no: Type "continue" to proceed to Phase 5.
434
519
  ```
435
- ---
436
- ## 📝 Document Generation
437
520
 
438
- Generate `docs/styling.md` using the template with these placeholders:
521
+ **If user edits files:**
522
+ Re-read files to refresh context before continuing.
523
+ ---
524
+ **Proceed to Phase 5 only after documents are validated.**
439
525
 
440
- - `{{STYLING_APPROACH}}` Styling solution (e.g., "Tailwind CSS")
441
- - `{{COMPONENT_LIBRARY}}` → UI kit (e.g., "shadcn/ui" or "None")
442
- - `{{DESIGN_TOKENS}}` → Yes/No
443
- - `{{THEME_SUPPORT}}` → Dark mode / Multiple themes / None
444
- - `{{COLOR_SYSTEM}}` → Color palette approach
445
- - `{{TYPOGRAPHY_SYSTEM}}` → Type scale approach
446
- - `{{BREAKPOINTS}}` → Responsive breakpoints
447
- - `{{SPACING_SCALE}}` → Spacing system
448
- - `{{ANIMATION_STRATEGY}}` → Animation approach
449
- - `{{A11Y_COMPLIANCE}}` → WCAG level
526
+ > ⚠️ **CRITICAL:** DO NOT generate README.md in this phase. README.md is ONLY generated in Phase 8 (step 8.5) after framework initialization.
527
+ ---
528
+ ---
450
529
 
451
- Update `ai-instructions.md`:
530
+ ---
452
531
 
453
- ```markdown
454
- ## Styling
532
+ ## 📝 Generated Documents
455
533
 
456
- - **Approach:** {{STYLING_APPROACH}}
457
- - **Component Library:** {{COMPONENT_LIBRARY}}
458
- - **Design Tokens:** {{DESIGN_TOKENS}}
459
- - **Theming:** {{THEME_SUPPORT}}
460
- - **Accessibility:** {{A11Y_COMPLIANCE}}
534
+ After Phase 4, generate/update:
535
+ - `specs/security.md` - Security policies and authentication details
461
536
 
462
- ### Rules
537
+ ---
463
538
 
464
- - ALWAYS use design tokens for colors and spacing
465
- - ✅ ALWAYS ensure WCAG {{A11Y_COMPLIANCE}} color contrast
466
- - ✅ ALWAYS include focus indicators for keyboard navigation
467
- - ❌ NEVER hardcode colors or spacing values
468
- - ❌ NEVER ignore prefers-reduced-motion
469
- {{#IF_TAILWIND}}
470
- - ✅ ALWAYS use Tailwind utility classes, avoid custom CSS
471
- - ❌ NEVER use arbitrary values excessively (e.g., `w-[127px]`)
472
- {{/IF_TAILWIND}}
473
- {{#IF_DARK_MODE}}
474
- - ✅ ALWAYS test components in both light and dark modes
475
- {{/IF_DARK_MODE}}
476
- ```
477
- ---
478
- ## 🚀 Next Steps
539
+ **Next Phase:** Phase 5 - Development Standards (15-20 min)
479
540
 
480
- ```
481
- ✅ Phase 4 Complete!
541
+ Read: `.ai-flow/prompts/backend/flow-build-phase-5.md`
482
542
 
483
- Documents Generated:
484
- - docs/styling.md
485
- - ai-instructions.md (updated)
543
+ ---
486
544
 
487
- Next: Phase 5 - Code Standards
545
+ **Last Updated:** 2025-12-20
546
+ **Version:** 2.1.8
488
547
 
489
- Read: .ai-flow/prompts/frontend/flow-build-phase-5-standards.md
490
- ```
491
- ---
492
- **Last Updated:** 2025-01-XX
548
+ ---
493
549
 
494
- **Version:** 1.2.0
550
+ ## PHASE 5: Development Standards (15-20 min)
495
551
 
496
552
 
497
553