ai-flow-dev 2.1.9 → 2.2.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 (77) hide show
  1. package/README.md +26 -29
  2. package/dist/cli.js +10 -4
  3. package/dist/cli.js.map +1 -1
  4. package/package.json +1 -1
  5. package/prompts/backend/flow-build-phase-0.md +278 -1738
  6. package/prompts/backend/flow-build-phase-1.md +19 -0
  7. package/prompts/backend/flow-build-phase-10.md +1 -0
  8. package/prompts/backend/flow-build-phase-2.md +19 -0
  9. package/prompts/backend/flow-build-phase-3.md +19 -0
  10. package/prompts/backend/flow-build-phase-4.md +19 -0
  11. package/prompts/backend/flow-build-phase-5.md +19 -0
  12. package/prompts/backend/flow-build-phase-6.md +19 -0
  13. package/prompts/backend/flow-build-phase-7.md +19 -0
  14. package/prompts/backend/flow-build-phase-8.md +6 -7
  15. package/prompts/backend/flow-build-phase-9.md +15 -0
  16. package/prompts/backend/flow-build.md +59 -836
  17. package/prompts/backend/flow-check-review.md +20 -0
  18. package/prompts/backend/flow-check-test.md +14 -0
  19. package/prompts/backend/flow-check.md +65 -0
  20. package/prompts/backend/flow-commit.md +51 -0
  21. package/prompts/backend/flow-docs-sync.md +53 -53
  22. package/prompts/backend/flow-work-feature.md +42 -0
  23. package/prompts/backend/flow-work-fix.md +33 -0
  24. package/prompts/backend/flow-work-refactor.md +32 -0
  25. package/prompts/backend/flow-work-resume.md +32 -0
  26. package/prompts/backend/flow-work.md +127 -0
  27. package/prompts/frontend/flow-build-phase-0.md +323 -426
  28. package/prompts/frontend/flow-build-phase-1.md +433 -404
  29. package/prompts/frontend/flow-build-phase-10.md +33 -0
  30. package/prompts/frontend/flow-build-phase-2.md +508 -872
  31. package/prompts/frontend/flow-build-phase-3.md +629 -562
  32. package/prompts/frontend/flow-build-phase-4.md +438 -382
  33. package/prompts/frontend/flow-build-phase-5.md +559 -362
  34. package/prompts/frontend/flow-build-phase-6.md +383 -452
  35. package/prompts/frontend/flow-build-phase-7.md +818 -392
  36. package/prompts/frontend/flow-build-phase-8.md +27 -16
  37. package/prompts/frontend/flow-build-phase-9.md +94 -0
  38. package/prompts/frontend/flow-build.md +68 -414
  39. package/prompts/frontend/flow-check-review.md +20 -0
  40. package/prompts/frontend/flow-check-test.md +14 -0
  41. package/prompts/frontend/flow-check.md +65 -0
  42. package/prompts/frontend/flow-commit.md +51 -0
  43. package/prompts/frontend/flow-docs-sync.md +36 -34
  44. package/prompts/frontend/flow-work-feature.md +42 -0
  45. package/prompts/frontend/flow-work-fix.md +33 -0
  46. package/prompts/frontend/flow-work-refactor.md +32 -0
  47. package/prompts/frontend/flow-work-resume.md +32 -0
  48. package/prompts/frontend/flow-work.md +127 -0
  49. package/prompts/mobile/flow-build-phase-0.md +335 -319
  50. package/prompts/mobile/flow-build-phase-1.md +438 -493
  51. package/prompts/mobile/flow-build-phase-10.md +32 -0
  52. package/prompts/mobile/flow-build-phase-2.md +458 -464
  53. package/prompts/mobile/flow-build-phase-3.md +613 -487
  54. package/prompts/mobile/flow-build-phase-4.md +439 -258
  55. package/prompts/mobile/flow-build-phase-5.md +582 -250
  56. package/prompts/mobile/flow-build-phase-6.md +389 -359
  57. package/prompts/mobile/flow-build-phase-7.md +871 -285
  58. package/prompts/mobile/flow-build-phase-8.md +27 -16
  59. package/prompts/mobile/flow-build-phase-9.md +90 -0
  60. package/prompts/mobile/flow-build.md +67 -426
  61. package/prompts/mobile/flow-check-review.md +20 -0
  62. package/prompts/mobile/flow-check-test.md +14 -0
  63. package/prompts/mobile/flow-check.md +65 -0
  64. package/prompts/mobile/flow-commit.md +51 -0
  65. package/prompts/mobile/flow-docs-sync.md +37 -40
  66. package/prompts/mobile/flow-work-feature.md +42 -0
  67. package/prompts/mobile/flow-work-fix.md +33 -0
  68. package/prompts/mobile/flow-work-refactor.md +32 -0
  69. package/prompts/mobile/flow-work-resume.md +32 -0
  70. package/prompts/mobile/flow-work.md +127 -0
  71. package/prompts/shared/smart-skip-preflight.md +214 -0
  72. package/prompts/backend/flow-dev-commit.md +0 -829
  73. package/prompts/backend/flow-dev-feature.md +0 -1948
  74. package/prompts/backend/flow-dev-fix.md +0 -952
  75. package/prompts/backend/flow-dev-refactor.md +0 -690
  76. package/prompts/backend/flow-dev-review.md +0 -372
  77. package/prompts/backend/flow-dev-work.md +0 -1081
@@ -1,372 +1,553 @@
1
- # Phase 4: Permissions & Native Features
1
+ ## PHASE 4: Security & Authentication (15-20 min)
2
2
 
3
- **Duration:** 15-20 minutes
4
- **Questions:** ~10 questions
5
- **Output:** docs/permissions.md, docs/native-features.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 what **native features and permissions** your app will use:
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 permissions will you request?
12
- 2. What native features will you integrate?
13
- 3. How will you handle permission requests?
14
- 4. What third-party SDKs will you use?
15
- ---
16
- ## 📋 Questions
11
+ ### Objective
17
12
 
18
- ### Question 4.1: Camera Permission
13
+ Define security policies, authentication, authorization, and compliance requirements.
19
14
 
20
- **Will your app use the camera?**
15
+ ---
21
16
 
22
- A) **Yes - Photo Capture**
17
+ ## 🔍 Pre-Flight Check (Smart Skip Logic)
23
18
 
24
- - Take photos within app
25
- - Requires: Camera permission
26
- - Best for: Social apps, productivity apps
19
+ > 📎 **Reference:** See [prompts/shared/smart-skip-preflight.md](../shared/smart-skip-preflight.md) for the complete smart skip logic.
27
20
 
28
- B) **Yes - Video Recording**
21
+ **Execute Pre-Flight Check for Phase 4:**
29
22
 
30
- - Record videos
31
- - Requires: Camera + Microphone permissions
32
- - Best for: Video apps, social media
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
33
27
 
34
- C) **Yes - QR Code Scanning**
28
+ **Proceed with appropriate scenario based on audit data from `.ai-flow/cache/audit-data.json`**
35
29
 
36
- - Scan QR codes
37
- - Requires: Camera permission
38
- - Best for: Payment apps, utilities
30
+ ---
39
31
 
40
- D) **No Camera Access**
32
+ ## Phase 4 Questions (Full Mode)
41
33
 
42
- - No camera features
43
- - Best for: Most apps
34
+ **4.1 Authentication Method**
44
35
 
45
- **Your answer:**
46
-
47
- **If camera selected, ask:**
48
-
49
- - What library will you use?
50
- - React Native: react-native-camera, react-native-vision-camera
51
- - Flutter: camera, image_picker
52
- - Native: AVFoundation (iOS), Camera2 (Android)
53
- ---
54
- ### Question 4.2: Location Permission
55
-
56
- **Will your app use location services?**
57
-
58
- A) ⭐ **Yes - When In Use** (Recommended)
59
-
60
- - Location only when app is active
61
- - Requires: Location When In Use permission
62
- - Best for: Most location-based apps
63
-
64
- B) **Yes - Always**
36
+ ```
37
+ How will users authenticate?
65
38
 
66
- - Location even when app is backgrounded
67
- - Requires: Always permission (harder to get approved)
68
- - Best for: Navigation, fitness tracking
39
+ A) JWT (JSON Web Tokens) - Recommended for APIs
69
40
 
70
- C) **Yes - Approximate Location**
41
+ - Stateless, scalable
42
+ - Access + Refresh token pattern
71
43
 
72
- - Approximate location only (less privacy-invasive)
73
- - Best for: Location-based content
44
+ B) 🔥 Session-based - Traditional web apps
74
45
 
75
- D) **No Location Access**
46
+ - Server-side sessions
47
+ - Cookie-based
76
48
 
77
- - No location features
78
- - Best for: Most apps
49
+ C) ⚡ OAuth 2.0 / OpenID Connect - External providers
79
50
 
80
- **Your answer:**
51
+ - "Sign in with Google/GitHub/etc."
52
+ - Delegated authentication
81
53
 
82
- **If location selected, ask:**
54
+ D) 🏆 Multi-factor (MFA) - Enterprise security
83
55
 
84
- - What library will you use?
85
- - React Native: @react-native-community/geolocation, react-native-maps
86
- - Flutter: geolocator, google_maps_flutter
87
- - Native: CoreLocation (iOS), Location Services (Android)
88
- ---
89
- ### Question 4.3: Push Notifications
56
+ - OTP, SMS, authenticator app
57
+ - Required or optional?
90
58
 
91
- **Will your app send push notifications?**
59
+ E) API Keys - Service-to-service
92
60
 
93
- A) ⭐ **Yes - User Notifications** (Recommended)
61
+ - Simple, stateless
62
+ - Limited use cases
94
63
 
95
- - Notify users of important events
96
- - Requires: Notification permission
97
- - Best for: Most apps
64
+ Your choice: __
65
+ Why?
66
+ ```
98
67
 
99
- B) **Yes - Background Notifications**
68
+ **4.2 JWT Configuration (if using JWT)**
100
69
 
101
- - Notify even when app is closed
102
- - Requires: Background modes
103
- - Best for: Real-time apps
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
+ ```
104
88
 
105
- C) **No Push Notifications**
89
+ **4.3 Authorization Model**
106
90
 
107
- - No notifications
108
- - Best for: Simple apps, privacy-focused apps
91
+ ```
92
+ How will you manage permissions?
109
93
 
110
- **Your answer:**
94
+ A) ⭐ Role-Based Access Control (RBAC)
95
+ - Users have roles (admin, user, moderator, etc.)
96
+ - Roles have permissions
97
+ - Simple and common
111
98
 
112
- **If notifications selected, ask:**
99
+ B) 🏆 Attribute-Based Access Control (ABAC)
100
+ - Fine-grained based on attributes
101
+ - Complex rules
102
+ - Enterprise use cases
113
103
 
114
- - What service will you use?
115
- - Firebase Cloud Messaging (FCM)
116
- - OneSignal
117
- - Pusher
118
- - Custom backend
119
- ---
120
- ### Question 4.4: Photo Library Access
104
+ C) 🔒 Resource-based (Ownership)
105
+ - Users can only access their own resources
106
+ - Simple projects
121
107
 
122
- **Will your app access the photo library?**
108
+ D) 🌐 Multi-tenant with role hierarchy
109
+ - Organization → Teams → Users
110
+ - Complex enterprise systems
123
111
 
124
- A) **Yes - Read Only**
112
+ Your choice: __
125
113
 
126
- - Select photos from library
127
- - Requires: Photo Library Read permission
128
- - Best for: Most apps that need photos
114
+ List the roles you'll need:
115
+ -
116
+ -
129
117
 
130
- B) **Yes - Read & Write**
118
+ List key permissions:
119
+ -
120
+ -
121
+ ```
131
122
 
132
- - Save photos to library
133
- - Requires: Photo Library Write permission
134
- - Best for: Photo editing apps
123
+ **4.4 Password Policy**
135
124
 
136
- C) **No Photo Library Access**
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
+ ```
137
153
 
138
- - No photo library features
139
- - Best for: Apps that don't need photos
154
+ **4.5 Rate Limiting**
140
155
 
141
- **Your answer:**
142
- ---
143
- ### Question 4.5: Contacts Access
156
+ ```
157
+ Will you implement rate limiting?
144
158
 
145
- **Will your app access contacts?**
159
+ A) Yes - Recommended for all public APIs
146
160
 
147
- A) **Yes - Read Contacts**
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)
148
166
 
149
- - Import contacts
150
- - Requires: Contacts Read permission
151
- - Best for: Social apps, messaging apps
167
+ Rate limiting strategy:
168
+ A) IP-based
169
+ B) User/API key-based
170
+ C) Both
152
171
 
153
- B) **Yes - Read & Write**
172
+ Tool:
173
+ A) express-rate-limit / @nestjs/throttler
174
+ B) Redis-based rate limiting
175
+ C) API Gateway (AWS, Kong, etc.)
176
+ ```
154
177
 
155
- - Add contacts
156
- - Requires: Contacts Write permission
157
- - Best for: Contact management apps
178
+ **4.6 CORS Policy**
158
179
 
159
- C) **No Contacts Access**
180
+ ```
181
+ CORS (Cross-Origin Resource Sharing) configuration:
160
182
 
161
- - No contact features
162
- - Best for: Most apps
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)
163
187
 
164
- **Your answer:**
165
- ---
166
- ### Question 4.6: Biometric Authentication
188
+ Your allowed origins:
189
+ -
167
190
 
168
- **Will your app use biometric authentication?**
191
+ Allowed methods: [GET, POST, PUT, PATCH, DELETE, OPTIONS]
192
+ Credentials: [true/false] - Allow cookies/auth headers
193
+ Max age: __ seconds (cache preflight)
194
+ ```
169
195
 
170
- A) ⭐ **Yes - Face ID / Touch ID / Fingerprint** (Recommended)
196
+ **4.7 Data Encryption**
171
197
 
172
- - Secure authentication
173
- - Requires: Face ID / Touch ID permission
174
- - Best for: Secure apps, banking apps
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
+ ```
175
220
 
176
- B) **No Biometric Auth**
221
+ **4.8 Security Headers**
177
222
 
178
- - Traditional password/PIN only
179
- - Best for: Simple apps
223
+ ```
224
+ Which security headers will you implement?
180
225
 
181
- **Your answer:**
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
182
232
 
183
- **If biometric selected, ask:**
233
+ B) Basic headers only
234
+ C) None (not recommended)
235
+ ```
184
236
 
185
- - What library will you use?
186
- - React Native: react-native-biometrics, react-native-touch-id
187
- - Flutter: local_auth
188
- - Native: LocalAuthentication (iOS), BiometricPrompt (Android)
189
- ---
190
- ### Question 4.7: File System Access
237
+ **4.9 Compliance Requirements**
191
238
 
192
- **Will your app access the file system?**
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
+ ```
193
316
 
194
- A) **Yes - Document Picker**
317
+ **4.10 Logging & Audit Trail**
195
318
 
196
- - Let users select files
197
- - Requires: File access permission
198
- - Best for: Document apps, file managers
319
+ ```
320
+ What security events will you log?
199
321
 
200
- B) **Yes - File Storage**
322
+ A) Authentication events
323
+ - Login success/failure
324
+ - Password changes
325
+ - Account creation
201
326
 
202
- - Save files to device
203
- - Requires: Storage permission
204
- - Best for: File management apps
327
+ B) Authorization events
328
+ - Permission denied
329
+ - Role changes
205
330
 
206
- C) **No File System Access**
331
+ C) Data access
332
+ - Sensitive data views
333
+ - Exports/downloads
207
334
 
208
- - No file features
209
- - Best for: Most apps
335
+ D) Data modifications
336
+ - Create/Update/Delete operations
337
+ - Who, what, when
210
338
 
211
- **Your answer:**
212
- ---
213
- ### Question 4.8: Microphone Access
339
+ Log retention: __ days (recommended: 90+ days)
340
+ Log storage: [Database / File system / External service (CloudWatch, Datadog)]
341
+ ```
214
342
 
215
- **Will your app use the microphone?**
343
+ **4.11 API Keys Management**
216
344
 
217
- A) ⭐ **Yes - Audio Recording**
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
+ ```
218
371
 
219
- - Record audio
220
- - Requires: Microphone permission
221
- - Best for: Voice notes, recording apps
372
+ **4.12 Dependency Security**
222
373
 
223
- B) **Yes - Voice Calls**
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
+ ```
224
397
 
225
- - Make voice/video calls
226
- - Requires: Microphone permission
227
- - Best for: Communication apps
398
+ **4.13 Input Validation & Sanitization**
228
399
 
229
- C) **No Microphone Access**
400
+ ```
401
+ Input validation strategy:
230
402
 
231
- - No audio recording
232
- - Best for: Most apps
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]
233
407
 
234
- **Your answer:**
235
- ---
236
- ### Question 4.9: Third-Party SDKs
408
+ B) Manual validation in services
409
+ - Custom validation logic
410
+ - More flexible but error-prone
237
411
 
238
- **What third-party SDKs will you integrate?**
412
+ Sanitization rules:
239
413
 
240
- **Analytics:**
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]
241
418
 
242
- - A) Firebase Analytics
243
- - B) Mixpanel
244
- - C) Amplitude
245
- - D) None
419
+ B) SQL Injection prevention
420
+ - Use parameterized queries (ORM handles this automatically)
421
+ - Never concatenate user input in queries
246
422
 
247
- **Crash Reporting:**
423
+ Request size limits:
248
424
 
249
- - A) Firebase Crashlytics
250
- - B) Sentry
251
- - C) Bugsnag
252
- - D) None
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)
253
428
 
254
- **Authentication:**
429
+ File upload validation (if applicable from Phase 3.9):
255
430
 
256
- - A) Firebase Auth
257
- - B) Auth0
258
- - C) AWS Cognito
259
- - D) Custom backend
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]
260
436
 
261
- **Maps:**
437
+ Content-Type enforcement:
262
438
 
263
- - A) Google Maps
264
- - B) Mapbox
265
- - C) Apple Maps (iOS only)
266
- - D) None
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
267
442
 
268
- **Payments:**
443
+ Validation approach:
269
444
 
270
- - A) Stripe
271
- - B) PayPal
272
- - C) Apple Pay / Google Pay
273
- - D) None
445
+ A) ⭐ Whitelist - Only allow known good inputs (recommended)
446
+ - Define allowed values explicitly
447
+ - Reject everything else
274
448
 
275
- **Social Login:**
449
+ B) Blacklist - Block known bad inputs (not recommended)
450
+ - Easy to bypass
451
+ - Incomplete protection
276
452
 
277
- - A) Firebase Auth (Google, Facebook, Apple)
278
- - B) Auth0 Social Connections
279
- - C) Custom OAuth
280
- - D) None
453
+ Special character handling:
281
454
 
282
- **Your answer:** (Select all that apply)
283
- ---
284
- ### Question 4.10: Permission Request Strategy
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
+ ```
285
459
 
286
- **How will you request permissions?**
460
+ ### Phase 4 Output
287
461
 
288
- A) ⭐ **Just-In-Time** (Recommended)
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
289
485
 
290
- - Request when feature is needed
291
- - Explain why permission is needed
292
- - Best for: Better user experience
486
+ **Before starting generation:**
293
487
 
294
- B) **On First Launch**
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
+ ```
295
495
 
296
- - Request all permissions upfront
297
- - Less ideal (can overwhelm users)
298
- - Best for: Apps that need all permissions
496
+ **Generate documents automatically:**
299
497
 
300
- C) **Progressive**
498
+ **1. `specs/security.md`**
301
499
 
302
- - Request permissions as features are discovered
303
- - Best for: Apps with optional features
500
+ - Use template: `.ai-flow/templates/specs/security.template.md`
501
+ - Fill with all security policies, authentication, authorization
502
+ - Write to: `specs/security.md`
304
503
 
305
- **Your answer:**
306
- ---
307
- ### Question 4.11: Permission Denial Handling
504
+ **2. Update `ai-instructions.md`**
308
505
 
309
- **How will you handle denied permissions?**
506
+ - Add security rules to NEVER/ALWAYS sections
507
+ - Add authentication/authorization patterns
310
508
 
311
- A) ⭐ **Graceful Degradation** (Recommended)
509
+ ```
510
+ ✅ Generated: specs/security.md
511
+ ✅ Updated: ai-instructions.md (security rules added)
312
512
 
313
- - App works without permission
314
- - Show alternative options
315
- - Best for: Better UX
513
+ Documents have been created with all Phase 4 information.
316
514
 
317
- B) **Show Settings Prompt**
515
+ 📝 Would you like to make any corrections before continuing?
318
516
 
319
- - Guide user to enable in settings
320
- - Best for: Critical permissions
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
+ ```
321
520
 
322
- C) **Block Feature**
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.**
323
525
 
324
- - Feature unavailable if permission denied
325
- - Best for: Core features
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
+ ---
326
529
 
327
- **Your answer:**
328
- ---
329
- ## ✅ Phase 4 Completion
530
+ ---
330
531
 
331
- After answering all questions, summarize:
532
+ ## 📝 Generated Documents
332
533
 
333
- ```
334
- ---
335
- ✅ Phase 4 Complete: Permissions & Native Features
336
- ---
337
- Selected Permissions:
338
- - Camera: Photo capture (react-native-vision-camera)
339
- - Location: When in use (@react-native-community/geolocation)
340
- - Push Notifications: Yes (Firebase Cloud Messaging)
341
- - Photo Library: Read only
342
- - Biometric Auth: Face ID / Touch ID
534
+ After Phase 4, generate/update:
535
+ - `specs/security.md` - Security policies and authentication details
343
536
 
344
- Third-Party SDKs:
345
- - Analytics: Firebase Analytics
346
- - Crash Reporting: Firebase Crashlytics
347
- - Maps: Google Maps
348
- - Authentication: Firebase Auth
537
+ ---
349
538
 
350
- Permission Strategy: Just-In-Time requests with graceful degradation
539
+ **Next Phase:** Phase 5 - Development Standards (15-20 min)
351
540
 
352
- Proceed to Phase 5 (Code Standards)? (Y/n)
353
- ```
354
- ---
355
- ## 📝 Generated Documents
541
+ Read: `.ai-flow/prompts/backend/flow-build-phase-5.md`
356
542
 
357
- After Phase 4, generate/update:
543
+ ---
358
544
 
359
- - `docs/permissions.md` - Permission handling guide
360
- - `docs/native-features.md` - Native features integration guide
361
- - `ai-instructions.md` - Add permission and native feature rules
362
- ---
363
- **Next Phase:** Phase 5 - Code Standards
545
+ **Last Updated:** 2025-12-20
546
+ **Version:** 2.1.8
364
547
 
365
- Read: `.ai-flow/prompts/mobile/flow-build-phase-5-standards.md`
366
- ---
367
- **Last Updated:** 2025-01-XX
548
+ ---
368
549
 
369
- **Version:** 1.4.0
550
+ ## PHASE 5: Development Standards (15-20 min)
370
551
 
371
552
 
372
553