ai-flow-dev 2.7.0 → 2.8.1

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 (171) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +573 -570
  3. package/package.json +74 -74
  4. package/prompts/backend/flow-build-phase-0.md +535 -535
  5. package/prompts/backend/flow-build-phase-1.md +626 -626
  6. package/prompts/backend/flow-build-phase-10.md +340 -340
  7. package/prompts/backend/flow-build-phase-2.md +573 -573
  8. package/prompts/backend/flow-build-phase-3.md +834 -834
  9. package/prompts/backend/flow-build-phase-4.md +554 -554
  10. package/prompts/backend/flow-build-phase-5.md +703 -703
  11. package/prompts/backend/flow-build-phase-6.md +524 -524
  12. package/prompts/backend/flow-build-phase-7.md +1001 -1001
  13. package/prompts/backend/flow-build-phase-8.md +1407 -1407
  14. package/prompts/backend/flow-build-phase-9.md +477 -477
  15. package/prompts/backend/flow-build.md +137 -137
  16. package/prompts/backend/flow-check-review.md +656 -20
  17. package/prompts/backend/flow-check-test.md +526 -14
  18. package/prompts/backend/flow-check.md +717 -67
  19. package/prompts/backend/flow-commit.md +88 -119
  20. package/prompts/backend/flow-docs-sync.md +354 -354
  21. package/prompts/backend/flow-finish.md +919 -0
  22. package/prompts/backend/flow-release.md +949 -0
  23. package/prompts/backend/flow-work-feature.md +61 -61
  24. package/prompts/backend/flow-work-fix.md +46 -46
  25. package/prompts/backend/flow-work-refactor.md +48 -48
  26. package/prompts/backend/flow-work-resume.md +34 -34
  27. package/prompts/backend/flow-work.md +1098 -1286
  28. package/prompts/desktop/flow-build-phase-0.md +359 -359
  29. package/prompts/desktop/flow-build-phase-1.md +295 -295
  30. package/prompts/desktop/flow-build-phase-10.md +357 -357
  31. package/prompts/desktop/flow-build-phase-2.md +282 -282
  32. package/prompts/desktop/flow-build-phase-3.md +291 -291
  33. package/prompts/desktop/flow-build-phase-4.md +308 -308
  34. package/prompts/desktop/flow-build-phase-5.md +269 -269
  35. package/prompts/desktop/flow-build-phase-6.md +350 -350
  36. package/prompts/desktop/flow-build-phase-7.md +297 -297
  37. package/prompts/desktop/flow-build-phase-8.md +541 -541
  38. package/prompts/desktop/flow-build-phase-9.md +439 -439
  39. package/prompts/desktop/flow-build.md +156 -156
  40. package/prompts/desktop/flow-check-review.md +656 -20
  41. package/prompts/desktop/flow-check-test.md +526 -14
  42. package/prompts/desktop/flow-check.md +717 -67
  43. package/prompts/desktop/flow-commit.md +88 -119
  44. package/prompts/desktop/flow-docs-sync.md +354 -354
  45. package/prompts/desktop/flow-finish.md +919 -0
  46. package/prompts/desktop/flow-release.md +662 -0
  47. package/prompts/desktop/flow-work-feature.md +61 -61
  48. package/prompts/desktop/flow-work-fix.md +46 -46
  49. package/prompts/desktop/flow-work-refactor.md +48 -48
  50. package/prompts/desktop/flow-work-resume.md +34 -34
  51. package/prompts/desktop/flow-work.md +1202 -1390
  52. package/prompts/frontend/flow-build-phase-0.md +425 -425
  53. package/prompts/frontend/flow-build-phase-1.md +626 -626
  54. package/prompts/frontend/flow-build-phase-10.md +33 -33
  55. package/prompts/frontend/flow-build-phase-2.md +573 -573
  56. package/prompts/frontend/flow-build-phase-3.md +782 -782
  57. package/prompts/frontend/flow-build-phase-4.md +554 -554
  58. package/prompts/frontend/flow-build-phase-5.md +703 -703
  59. package/prompts/frontend/flow-build-phase-6.md +524 -524
  60. package/prompts/frontend/flow-build-phase-7.md +1001 -1001
  61. package/prompts/frontend/flow-build-phase-8.md +872 -872
  62. package/prompts/frontend/flow-build-phase-9.md +94 -94
  63. package/prompts/frontend/flow-build.md +137 -137
  64. package/prompts/frontend/flow-check-review.md +656 -20
  65. package/prompts/frontend/flow-check-test.md +526 -14
  66. package/prompts/frontend/flow-check.md +717 -67
  67. package/prompts/frontend/flow-commit.md +88 -119
  68. package/prompts/frontend/flow-docs-sync.md +550 -550
  69. package/prompts/frontend/flow-finish.md +919 -0
  70. package/prompts/frontend/flow-release.md +519 -0
  71. package/prompts/frontend/flow-work-api.md +1547 -0
  72. package/prompts/frontend/flow-work-feature.md +61 -61
  73. package/prompts/frontend/flow-work-fix.md +38 -38
  74. package/prompts/frontend/flow-work-refactor.md +48 -48
  75. package/prompts/frontend/flow-work-resume.md +34 -34
  76. package/prompts/frontend/flow-work.md +1595 -1320
  77. package/prompts/mobile/flow-build-phase-0.md +425 -425
  78. package/prompts/mobile/flow-build-phase-1.md +626 -626
  79. package/prompts/mobile/flow-build-phase-10.md +32 -32
  80. package/prompts/mobile/flow-build-phase-2.md +573 -573
  81. package/prompts/mobile/flow-build-phase-3.md +782 -782
  82. package/prompts/mobile/flow-build-phase-4.md +554 -554
  83. package/prompts/mobile/flow-build-phase-5.md +703 -703
  84. package/prompts/mobile/flow-build-phase-6.md +524 -524
  85. package/prompts/mobile/flow-build-phase-7.md +1001 -1001
  86. package/prompts/mobile/flow-build-phase-8.md +888 -888
  87. package/prompts/mobile/flow-build-phase-9.md +90 -90
  88. package/prompts/mobile/flow-build.md +135 -135
  89. package/prompts/mobile/flow-check-review.md +656 -20
  90. package/prompts/mobile/flow-check-test.md +526 -14
  91. package/prompts/mobile/flow-check.md +717 -67
  92. package/prompts/mobile/flow-commit.md +88 -119
  93. package/prompts/mobile/flow-docs-sync.md +620 -620
  94. package/prompts/mobile/flow-finish.md +919 -0
  95. package/prompts/mobile/flow-release.md +751 -0
  96. package/prompts/mobile/flow-work-api.md +1500 -0
  97. package/prompts/mobile/flow-work-feature.md +61 -61
  98. package/prompts/mobile/flow-work-fix.md +46 -46
  99. package/prompts/mobile/flow-work-refactor.md +48 -48
  100. package/prompts/mobile/flow-work-resume.md +34 -34
  101. package/prompts/mobile/flow-work.md +1605 -1329
  102. package/prompts/shared/mermaid-guidelines.md +102 -102
  103. package/prompts/shared/scope-levels.md +114 -114
  104. package/prompts/shared/smart-skip-preflight.md +214 -214
  105. package/prompts/shared/story-points.md +55 -55
  106. package/prompts/shared/task-format.md +74 -74
  107. package/prompts/shared/task-summary-template.md +277 -277
  108. package/templates/AGENT.template.md +443 -443
  109. package/templates/backend/.clauderules.template +112 -112
  110. package/templates/backend/.cursorrules.template +102 -102
  111. package/templates/backend/README.template.md +2 -2
  112. package/templates/backend/ai-instructions.template.md +2 -2
  113. package/templates/backend/copilot-instructions.template.md +2 -2
  114. package/templates/backend/docs/api.template.md +320 -320
  115. package/templates/backend/docs/business-flows.template.md +97 -97
  116. package/templates/backend/docs/code-standards.template.md +2 -2
  117. package/templates/backend/docs/contributing.template.md +3 -3
  118. package/templates/backend/docs/data-model.template.md +520 -520
  119. package/templates/backend/docs/testing.template.md +2 -2
  120. package/templates/backend/project-brief.template.md +2 -2
  121. package/templates/backend/specs/configuration.template.md +2 -2
  122. package/templates/backend/specs/security.template.md +2 -2
  123. package/templates/desktop/.clauderules.template +112 -112
  124. package/templates/desktop/.cursorrules.template +102 -102
  125. package/templates/desktop/README.template.md +170 -170
  126. package/templates/desktop/ai-instructions.template.md +366 -366
  127. package/templates/desktop/copilot-instructions.template.md +140 -140
  128. package/templates/desktop/docs/docs/api.template.md +320 -320
  129. package/templates/desktop/docs/docs/architecture.template.md +724 -724
  130. package/templates/desktop/docs/docs/business-flows.template.md +102 -102
  131. package/templates/desktop/docs/docs/code-standards.template.md +792 -792
  132. package/templates/desktop/docs/docs/contributing.template.md +149 -149
  133. package/templates/desktop/docs/docs/data-model.template.md +520 -520
  134. package/templates/desktop/docs/docs/operations.template.md +720 -720
  135. package/templates/desktop/docs/docs/testing.template.md +722 -722
  136. package/templates/desktop/project-brief.template.md +150 -150
  137. package/templates/desktop/specs/specs/configuration.template.md +121 -121
  138. package/templates/desktop/specs/specs/security.template.md +392 -392
  139. package/templates/frontend/README.template.md +2 -2
  140. package/templates/frontend/ai-instructions.template.md +2 -2
  141. package/templates/frontend/docs/api-integration.template.md +362 -362
  142. package/templates/frontend/docs/components.template.md +2 -2
  143. package/templates/frontend/docs/error-handling.template.md +360 -360
  144. package/templates/frontend/docs/operations.template.md +107 -107
  145. package/templates/frontend/docs/performance.template.md +124 -124
  146. package/templates/frontend/docs/pwa.template.md +119 -119
  147. package/templates/frontend/docs/state-management.template.md +2 -2
  148. package/templates/frontend/docs/styling.template.md +2 -2
  149. package/templates/frontend/docs/testing.template.md +2 -2
  150. package/templates/frontend/project-brief.template.md +2 -2
  151. package/templates/frontend/specs/accessibility.template.md +95 -95
  152. package/templates/frontend/specs/configuration.template.md +2 -2
  153. package/templates/frontend/specs/security.template.md +175 -175
  154. package/templates/fullstack/README.template.md +252 -252
  155. package/templates/fullstack/ai-instructions.template.md +444 -444
  156. package/templates/fullstack/project-brief.template.md +157 -157
  157. package/templates/fullstack/specs/configuration.template.md +340 -340
  158. package/templates/mobile/README.template.md +167 -167
  159. package/templates/mobile/ai-instructions.template.md +196 -196
  160. package/templates/mobile/docs/app-store.template.md +135 -135
  161. package/templates/mobile/docs/architecture.template.md +63 -63
  162. package/templates/mobile/docs/native-features.template.md +94 -94
  163. package/templates/mobile/docs/navigation.template.md +59 -59
  164. package/templates/mobile/docs/offline-strategy.template.md +65 -65
  165. package/templates/mobile/docs/permissions.template.md +56 -56
  166. package/templates/mobile/docs/state-management.template.md +85 -85
  167. package/templates/mobile/docs/testing.template.md +109 -109
  168. package/templates/mobile/project-brief.template.md +69 -69
  169. package/templates/mobile/specs/build-configuration.template.md +91 -91
  170. package/templates/mobile/specs/deployment.template.md +92 -92
  171. package/templates/work.template.md +61 -47
@@ -1,554 +1,554 @@
1
- ## PHASE 4: Security & Authentication (15-20 min)
2
-
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
4
-
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
-
11
- ### Objective
12
-
13
- Define security policies, authentication, authorization, and compliance requirements.
14
-
15
- ---
16
-
17
- ## 🔍 Pre-Flight Check (Smart Skip Logic)
18
-
19
- > 📎 **Reference:** See [prompts/shared/smart-skip-preflight.md](../../.ai-flow/prompts/shared/smart-skip-preflight.md) for the complete smart skip logic.
20
-
21
- **Execute Pre-Flight Check for Phase 4:**
22
-
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
27
-
28
- **Proceed with appropriate scenario based on audit data from `.ai-flow/cache/audit-data.json`**
29
-
30
- ---
31
-
32
- ## Phase 4 Questions (Full Mode)
33
-
34
- **4.1 Authentication Method**
35
-
36
- ```
37
- How will users authenticate?
38
-
39
- A) ⭐ JWT (JSON Web Tokens) - Recommended for APIs
40
-
41
- - Stateless, scalable
42
- - Access + Refresh token pattern
43
-
44
- B) 🔥 Session-based - Traditional web apps
45
-
46
- - Server-side sessions
47
- - Cookie-based
48
-
49
- C) ⚡ OAuth 2.0 / OpenID Connect - External providers
50
-
51
- - "Sign in with Google/GitHub/etc."
52
- - Delegated authentication
53
-
54
- D) 🏆 Multi-factor (MFA) - Enterprise security
55
-
56
- - OTP, SMS, authenticator app
57
- - Required or optional?
58
-
59
- E) API Keys - Service-to-service
60
-
61
- - Simple, stateless
62
- - Limited use cases
63
-
64
- Your choice: __
65
- Why?
66
- ```
67
-
68
- **4.2 JWT Configuration (if using JWT)**
69
-
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
- ```
88
-
89
- **4.3 Authorization Model**
90
-
91
- ```
92
- How will you manage permissions?
93
-
94
- A) ⭐ Role-Based Access Control (RBAC)
95
- - Users have roles (admin, user, moderator, etc.)
96
- - Roles have permissions
97
- - Simple and common
98
-
99
- B) 🏆 Attribute-Based Access Control (ABAC)
100
- - Fine-grained based on attributes
101
- - Complex rules
102
- - Enterprise use cases
103
-
104
- C) 🔒 Resource-based (Ownership)
105
- - Users can only access their own resources
106
- - Simple projects
107
-
108
- D) 🌐 Multi-tenant with role hierarchy
109
- - Organization → Teams → Users
110
- - Complex enterprise systems
111
-
112
- Your choice: __
113
-
114
- List the roles you'll need:
115
- -
116
- -
117
-
118
- List key permissions:
119
- -
120
- -
121
- ```
122
-
123
- **4.4 Password Policy**
124
-
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
- ```
153
-
154
- **4.5 Rate Limiting**
155
-
156
- ```
157
- Will you implement rate limiting?
158
-
159
- A) ⭐ Yes - Recommended for all public APIs
160
-
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)
166
-
167
- Rate limiting strategy:
168
- A) IP-based
169
- B) User/API key-based
170
- C) Both
171
-
172
- Tool:
173
- A) express-rate-limit / @nestjs/throttler
174
- B) Redis-based rate limiting
175
- C) API Gateway (AWS, Kong, etc.)
176
- ```
177
-
178
- **4.6 CORS Policy**
179
-
180
- ```
181
- CORS (Cross-Origin Resource Sharing) configuration:
182
-
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)
187
-
188
- Your allowed origins:
189
- -
190
-
191
- Allowed methods: [GET, POST, PUT, PATCH, DELETE, OPTIONS]
192
- Credentials: [true/false] - Allow cookies/auth headers
193
- Max age: __ seconds (cache preflight)
194
- ```
195
-
196
- **4.7 Data Encryption**
197
-
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
- ```
220
-
221
- **4.8 Security Headers**
222
-
223
- ```
224
- Which security headers will you implement?
225
-
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
232
-
233
- B) Basic headers only
234
- C) None (not recommended)
235
- ```
236
-
237
- **4.9 Compliance Requirements**
238
-
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
- ```
316
-
317
- **4.10 Logging & Audit Trail**
318
-
319
- ```
320
- What security events will you log?
321
-
322
- A) ✅ Authentication events
323
- - Login success/failure
324
- - Password changes
325
- - Account creation
326
-
327
- B) ✅ Authorization events
328
- - Permission denied
329
- - Role changes
330
-
331
- C) ✅ Data access
332
- - Sensitive data views
333
- - Exports/downloads
334
-
335
- D) ✅ Data modifications
336
- - Create/Update/Delete operations
337
- - Who, what, when
338
-
339
- Log retention: __ days (recommended: 90+ days)
340
- Log storage: [Database / File system / External service (CloudWatch, Datadog)]
341
- ```
342
-
343
- **4.11 API Keys Management**
344
-
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
- ```
371
-
372
- **4.12 Dependency Security**
373
-
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
- ```
397
-
398
- **4.13 Input Validation & Sanitization**
399
-
400
- ```
401
- Input validation strategy:
402
-
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]
407
-
408
- B) Manual validation in services
409
- - Custom validation logic
410
- - More flexible but error-prone
411
-
412
- Sanitization rules:
413
-
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]
418
-
419
- B) ✅ SQL Injection prevention
420
- - Use parameterized queries (ORM handles this automatically)
421
- - Never concatenate user input in queries
422
-
423
- Request size limits:
424
-
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)
428
-
429
- File upload validation (if applicable from Phase 3.9):
430
-
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]
436
-
437
- Content-Type enforcement:
438
-
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
442
-
443
- Validation approach:
444
-
445
- A) ⭐ Whitelist - Only allow known good inputs (recommended)
446
- - Define allowed values explicitly
447
- - Reject everything else
448
-
449
- B) Blacklist - Block known bad inputs (not recommended)
450
- - Easy to bypass
451
- - Incomplete protection
452
-
453
- Special character handling:
454
-
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
- ```
459
-
460
- ### Phase 4 Output
461
-
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
485
-
486
- **Before starting generation:**
487
-
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
- ```
495
-
496
- **Generate documents automatically:**
497
-
498
- **1. `specs/security.md`**
499
-
500
- - Use template: `.ai-flow/templates/specs/security.template.md`
501
- - Fill with all security policies, authentication, authorization
502
- - Write to: `specs/security.md`
503
-
504
- **2. Update `ai-instructions.md`**
505
-
506
- - Add security rules to NEVER/ALWAYS sections
507
- - Add authentication/authorization patterns
508
-
509
- ```
510
- ✅ Generated: specs/security.md
511
- ✅ Updated: ai-instructions.md (security rules added)
512
-
513
- Documents have been created with all Phase 4 information.
514
-
515
- 📝 Would you like to make any corrections before continuing?
516
-
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.
519
- ```
520
-
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.**
525
-
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
- ---
529
-
530
- ---
531
-
532
- ## 📝 Generated Documents
533
-
534
- After Phase 4, generate/update:
535
- - `specs/security.md` - Security policies and authentication details
536
-
537
- ---
538
-
539
- **Next Phase:** Phase 5 - Development Standards (15-20 min)
540
-
541
- Read: `.ai-flow/prompts/backend/flow-build-phase-5.md`
542
-
543
- ---
544
-
545
- **Last Updated:** 2025-12-20
546
- **Version:** 2.1.8
547
-
548
- ---
549
-
550
- ## PHASE 5: Development Standards (15-20 min)
551
-
552
-
553
-
554
-
1
+ ## PHASE 4: Security & Authentication (15-20 min)
2
+
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
4
+
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
+
11
+ ### Objective
12
+
13
+ Define security policies, authentication, authorization, and compliance requirements.
14
+
15
+ ---
16
+
17
+ ## 🔍 Pre-Flight Check (Smart Skip Logic)
18
+
19
+ > 📎 **Reference:** See [prompts/shared/smart-skip-preflight.md](../../.ai-flow/prompts/shared/smart-skip-preflight.md) for the complete smart skip logic.
20
+
21
+ **Execute Pre-Flight Check for Phase 4:**
22
+
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
27
+
28
+ **Proceed with appropriate scenario based on audit data from `.ai-flow/cache/audit-data.json`**
29
+
30
+ ---
31
+
32
+ ## Phase 4 Questions (Full Mode)
33
+
34
+ **4.1 Authentication Method**
35
+
36
+ ```
37
+ How will users authenticate?
38
+
39
+ A) ⭐ JWT (JSON Web Tokens) - Recommended for APIs
40
+
41
+ - Stateless, scalable
42
+ - Access + Refresh token pattern
43
+
44
+ B) 🔥 Session-based - Traditional web apps
45
+
46
+ - Server-side sessions
47
+ - Cookie-based
48
+
49
+ C) ⚡ OAuth 2.0 / OpenID Connect - External providers
50
+
51
+ - "Sign in with Google/GitHub/etc."
52
+ - Delegated authentication
53
+
54
+ D) 🏆 Multi-factor (MFA) - Enterprise security
55
+
56
+ - OTP, SMS, authenticator app
57
+ - Required or optional?
58
+
59
+ E) API Keys - Service-to-service
60
+
61
+ - Simple, stateless
62
+ - Limited use cases
63
+
64
+ Your choice: __
65
+ Why?
66
+ ```
67
+
68
+ **4.2 JWT Configuration (if using JWT)**
69
+
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
+ ```
88
+
89
+ **4.3 Authorization Model**
90
+
91
+ ```
92
+ How will you manage permissions?
93
+
94
+ A) ⭐ Role-Based Access Control (RBAC)
95
+ - Users have roles (admin, user, moderator, etc.)
96
+ - Roles have permissions
97
+ - Simple and common
98
+
99
+ B) 🏆 Attribute-Based Access Control (ABAC)
100
+ - Fine-grained based on attributes
101
+ - Complex rules
102
+ - Enterprise use cases
103
+
104
+ C) 🔒 Resource-based (Ownership)
105
+ - Users can only access their own resources
106
+ - Simple projects
107
+
108
+ D) 🌐 Multi-tenant with role hierarchy
109
+ - Organization → Teams → Users
110
+ - Complex enterprise systems
111
+
112
+ Your choice: __
113
+
114
+ List the roles you'll need:
115
+ -
116
+ -
117
+
118
+ List key permissions:
119
+ -
120
+ -
121
+ ```
122
+
123
+ **4.4 Password Policy**
124
+
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
+ ```
153
+
154
+ **4.5 Rate Limiting**
155
+
156
+ ```
157
+ Will you implement rate limiting?
158
+
159
+ A) ⭐ Yes - Recommended for all public APIs
160
+
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)
166
+
167
+ Rate limiting strategy:
168
+ A) IP-based
169
+ B) User/API key-based
170
+ C) Both
171
+
172
+ Tool:
173
+ A) express-rate-limit / @nestjs/throttler
174
+ B) Redis-based rate limiting
175
+ C) API Gateway (AWS, Kong, etc.)
176
+ ```
177
+
178
+ **4.6 CORS Policy**
179
+
180
+ ```
181
+ CORS (Cross-Origin Resource Sharing) configuration:
182
+
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)
187
+
188
+ Your allowed origins:
189
+ -
190
+
191
+ Allowed methods: [GET, POST, PUT, PATCH, DELETE, OPTIONS]
192
+ Credentials: [true/false] - Allow cookies/auth headers
193
+ Max age: __ seconds (cache preflight)
194
+ ```
195
+
196
+ **4.7 Data Encryption**
197
+
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
+ ```
220
+
221
+ **4.8 Security Headers**
222
+
223
+ ```
224
+ Which security headers will you implement?
225
+
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
232
+
233
+ B) Basic headers only
234
+ C) None (not recommended)
235
+ ```
236
+
237
+ **4.9 Compliance Requirements**
238
+
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
+ ```
316
+
317
+ **4.10 Logging & Audit Trail**
318
+
319
+ ```
320
+ What security events will you log?
321
+
322
+ A) ✅ Authentication events
323
+ - Login success/failure
324
+ - Password changes
325
+ - Account creation
326
+
327
+ B) ✅ Authorization events
328
+ - Permission denied
329
+ - Role changes
330
+
331
+ C) ✅ Data access
332
+ - Sensitive data views
333
+ - Exports/downloads
334
+
335
+ D) ✅ Data modifications
336
+ - Create/Update/Delete operations
337
+ - Who, what, when
338
+
339
+ Log retention: __ days (recommended: 90+ days)
340
+ Log storage: [Database / File system / External service (CloudWatch, Datadog)]
341
+ ```
342
+
343
+ **4.11 API Keys Management**
344
+
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
+ ```
371
+
372
+ **4.12 Dependency Security**
373
+
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
+ ```
397
+
398
+ **4.13 Input Validation & Sanitization**
399
+
400
+ ```
401
+ Input validation strategy:
402
+
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]
407
+
408
+ B) Manual validation in services
409
+ - Custom validation logic
410
+ - More flexible but error-prone
411
+
412
+ Sanitization rules:
413
+
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]
418
+
419
+ B) ✅ SQL Injection prevention
420
+ - Use parameterized queries (ORM handles this automatically)
421
+ - Never concatenate user input in queries
422
+
423
+ Request size limits:
424
+
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)
428
+
429
+ File upload validation (if applicable from Phase 3.9):
430
+
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]
436
+
437
+ Content-Type enforcement:
438
+
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
442
+
443
+ Validation approach:
444
+
445
+ A) ⭐ Whitelist - Only allow known good inputs (recommended)
446
+ - Define allowed values explicitly
447
+ - Reject everything else
448
+
449
+ B) Blacklist - Block known bad inputs (not recommended)
450
+ - Easy to bypass
451
+ - Incomplete protection
452
+
453
+ Special character handling:
454
+
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
+ ```
459
+
460
+ ### Phase 4 Output
461
+
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
485
+
486
+ **Before starting generation:**
487
+
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
+ ```
495
+
496
+ **Generate documents automatically:**
497
+
498
+ **1. `specs/security.md`**
499
+
500
+ - Use template: `.ai-flow/templates/specs/security.template.md`
501
+ - Fill with all security policies, authentication, authorization
502
+ - Write to: `specs/security.md`
503
+
504
+ **2. Update `ai-instructions.md`**
505
+
506
+ - Add security rules to NEVER/ALWAYS sections
507
+ - Add authentication/authorization patterns
508
+
509
+ ```
510
+ ✅ Generated: specs/security.md
511
+ ✅ Updated: ai-instructions.md (security rules added)
512
+
513
+ Documents have been created with all Phase 4 information.
514
+
515
+ 📝 Would you like to make any corrections before continuing?
516
+
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.
519
+ ```
520
+
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.**
525
+
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
+ ---
529
+
530
+ ---
531
+
532
+ ## 📝 Generated Documents
533
+
534
+ After Phase 4, generate/update:
535
+ - `specs/security.md` - Security policies and authentication details
536
+
537
+ ---
538
+
539
+ **Next Phase:** Phase 5 - Development Standards (15-20 min)
540
+
541
+ Read: `.ai-flow/prompts/backend/flow-build-phase-5.md`
542
+
543
+ ---
544
+
545
+ **Last Updated:** 2025-12-20
546
+ **Version:** 2.1.8
547
+
548
+ ---
549
+
550
+ ## PHASE 5: Development Standards (15-20 min)
551
+
552
+
553
+
554
+