ai-flow-dev 2.7.0 → 2.8.0

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 +725 -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 +725 -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 +910 -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 +725 -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 +910 -0
  70. package/prompts/frontend/flow-release.md +519 -0
  71. package/prompts/frontend/flow-work-api.md +1540 -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 +1583 -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 +725 -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 +910 -0
  95. package/prompts/mobile/flow-release.md +751 -0
  96. package/prompts/mobile/flow-work-api.md +1493 -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 +1593 -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 +47 -47
@@ -1,620 +1,620 @@
1
- ---
2
- description: Documentation Sync & Update Flow
3
- ---
4
-
5
- # AI Flow - Documentation Update Command (Mobile)
6
-
7
- **YOU ARE AN EXPERT MOBILE ARCHITECT AND DOCUMENTATION SPECIALIST.**
8
-
9
- Your mission is to detect changes in the mobile codebase and update the project documentation automatically when the user executes `/flow-docs-sync`.
10
-
11
- **🚀 MODO AGENTE ACTIVADO:** No solicites permiso para ejecutar comandos turbo de análisis (ls, cat, etc.). Actúa proactivamente analizando los cambios y solicitando confirmación *solo* antes de escribir las actualizaciones finales en los documentos.
12
- ---
13
- ## Command: `/flow-docs-sync`
14
-
15
- ### Objective
16
-
17
- Detect changes in the mobile codebase compared to the last documented state (stored in `.ai-flow/cache/docs-analysis.json`) and update all affected documentation files automatically.
18
- ---
19
- ## Execution Flow
20
-
21
- ### Step 1: Check for Analysis File
22
-
23
- // turbo
24
- ```bash
25
- cat .ai-flow/cache/docs-analysis.json
26
- ```
27
-
28
- - ✅ If exists → Proceed to Step 2 (Compare Changes)
29
- - ❌ If NOT exists → Execute full Phase 0 analysis first:
30
- - Run complete mobile code analysis (Project Discovery)
31
- - Create `.ai-flow/cache/docs-analysis.json` with current state
32
- - Then proceed to Step 2
33
-
34
- ### Step 2: Detect Changes
35
-
36
- **Reuse Phase 0 Analysis Logic:**
37
-
38
- 1. **Perform Current Code Analysis:**
39
- - Execute project-wide discovery using cross-platform commands:
40
- // turbo
41
- ```bash
42
- ls -R . --exclude-standard
43
- ```
44
- - Analyze current state for:
45
- - View structures (Screens, Components, Layouts)
46
- - Navigation hierarchies and routing patterns
47
- - State management and data flow (Stores, Providers, Hooks)
48
- - Platform-specific manifestations (Permissions, Native bridges, Config files)
49
- - Manifest changes (build.gradle, Podfile, pubspec.yaml, package.json)
50
- - Generate current state snapshot
51
-
52
- 2. **Compare with Previous State:**
53
-
54
- - Load `.ai-flow/cache/docs-analysis.json`
55
- - Compare current state vs previous state
56
- - Detect changes in:
57
- - **Interfaces:** New, modified, or deleted "entry points" (Screens, Routes)
58
- - **State Logic:** New, modified, or deleted state containers/logic
59
- - **Capabilities:** New permissions or native feature integrations
60
- - **Dependencies:** Manifest changes (version bumps, new packages)
61
- - **Architecture:** Structural changes (new modules, moved folders)
62
- - **Configuration:** New environment keys or build settings
63
-
64
- 3. **Generate Change Report:**
65
- - Categorize changes by type
66
- - Map changes to affected documentation files
67
- - Identify critical vs optional updates
68
-
69
- ### Step 3: Present Report and Confirm
70
-
71
- **If changes detected:**
72
-
73
- ```
74
- 📊 CHANGES DETECTED:
75
-
76
- 🔴 Documents that require updating:
77
- - docs/navigation.md (2 new screens: ProfileScreen, SettingsScreen)
78
- - docs/permissions.md (new permission: Camera)
79
- - docs/native-features.md (new native module: react-native-camera)
80
- - docs/state-management.md (new Redux store: userSlice)
81
- - ai-instructions.md (new dependency "react-native-camera")
82
-
83
- ⚠️ Moderate changes detected:
84
- - docs/architecture.md (change in folder structure)
85
- - specs/build-configuration.md (change in build.gradle)
86
-
87
- ✅ No changes: docs/testing.md, docs/offline-strategy.md
88
-
89
- Update all detected documents? (Y/N)
90
- ```
91
-
92
- **If NO changes detected:**
93
-
94
- ```
95
- ✅ No changes detected. Documentation is synchronized with current code.
96
-
97
- No updates required.
98
- ```
99
-
100
- ### Step 4: Update Documents (If User Confirms)
101
-
102
- **If user responds "Y", "Yes", "y", "yes", or similar:**
103
-
104
- 1. **For each document that needs updating:**
105
-
106
- **A) `docs/navigation.md`** (if screens/navigation changed):
107
-
108
- - Read current `docs/navigation.md`
109
- - Identify new/modified screens from analysis
110
- - Add new screens following existing navigation conventions
111
- - Update navigation structure if changed
112
- - Remove deleted screens (if any)
113
- - Maintain all existing content that hasn't changed
114
- - Regenerate affected sections only
115
-
116
- **B) `docs/permissions.md`** (if permissions changed):
117
-
118
- - Read current `docs/permissions.md`
119
- - Add new permissions detected in Info.plist or AndroidManifest.xml
120
- - Update permission descriptions if changed
121
- - Maintain all existing permissions
122
-
123
- **C) `docs/native-features.md`** (if native modules changed):
124
-
125
- - Read current `docs/native-features.md`
126
- - Add new native modules detected in dependencies
127
- - Update native feature integrations
128
- - Maintain all existing native features
129
-
130
- **D) `docs/state-management.md`** (if state management changed):
131
-
132
- - Read current `docs/state-management.md`
133
- - Update state management patterns with new stores/hooks
134
- - Update state structure if changed
135
- - Maintain all existing content that hasn't changed
136
-
137
- **E) `docs/offline-strategy.md`** (if offline strategy changed):
138
-
139
- - Read current `docs/offline-strategy.md`
140
- - Update offline patterns if storage solution changed
141
- - Update sync strategy if changed
142
- - Maintain all existing content
143
-
144
- **F) `ai-instructions.md`** (if dependencies changed):
145
-
146
- - Read current `ai-instructions.md`
147
- - Add new dependencies to appropriate sections
148
- - Update version numbers if changed
149
- - Maintain all existing rules and patterns
150
-
151
- **G) `docs/architecture.md`** (if architecture changed):
152
-
153
- - Read current `docs/architecture.md`
154
- - Update architecture diagram (mermaid) if structure changed
155
- - Update module descriptions
156
- - Maintain all existing content
157
-
158
- **H) `specs/build-configuration.md`** (if build config changed):
159
-
160
- - Read current `specs/build-configuration.md`
161
- - Update build configuration if build.gradle, Podfile, or app.json changed
162
- - Update version information if changed
163
- - Maintain existing configuration
164
-
165
- **I) `specs/deployment.md`** (if deployment changed):
166
-
167
- - Read current `specs/deployment.md`
168
- - Update deployment procedures if changed
169
- - Maintain existing procedures
170
-
171
- **J) `docs/app-store.md`** (if app store config changed):
172
-
173
- - Read current `docs/app-store.md`
174
- - Update app store configuration if app.json or build config changed
175
- - Maintain existing configuration
176
-
177
- 2. **Update `docs-analysis.json`:**
178
-
179
- - Save current state to `.ai-flow/cache/docs-analysis.json`
180
- - Update timestamp
181
- - Include all detected changes in metadata
182
-
183
- 3. **Present Summary:**
184
-
185
- ```
186
- ✅ DOCUMENTATION UPDATED:
187
-
188
- 📝 docs/navigation.md
189
- - Added 2 new screens (ProfileScreen, SettingsScreen)
190
- - Updated navigation structure
191
- - Maintained all existing navigation documentation
192
-
193
- 📝 docs/permissions.md
194
- - Added new permission (Camera)
195
- - Updated permission handling section
196
-
197
- 📝 docs/native-features.md
198
- - Added new native module (react-native-camera)
199
- - Updated native features integration section
200
-
201
- 📝 docs/state-management.md
202
- - Added new Redux store (userSlice)
203
- - Updated state management patterns
204
-
205
- 📝 ai-instructions.md
206
- - Added dependency "react-native-camera"
207
- - Updated tools section
208
-
209
- 📝 specs/build-configuration.md
210
- - Updated build.gradle configuration
211
-
212
- ✅ docs-analysis.json updated with new state
213
- ```
214
-
215
- ### Step 5: Handle Cancellation
216
-
217
- **If user responds "N", "No", "n", "no", or similar:**
218
-
219
- ```
220
- Update cancelled. Run `/flow-docs-sync` when you're ready to update the documentation.
221
- ```
222
- ---
223
- ## Change Detection Rules
224
-
225
- ### View & Interface Detection (Agnostic)
226
-
227
- **What triggers document update (e.g., `docs/navigation.md`):**
228
-
229
- - New view markers (e.g., Screen definitions, route mappings, or public component exports)
230
- - Modified navigation paths, hierarchies, or routing logic
231
- - Deleted views or screens
232
-
233
- **How to update:**
234
-
235
- - Add new views following the established patterns in the project
236
- - Update navigation diagrams (Mermaid) to reflect new hierarchies
237
- - Maintain existing documentation for unchanged segments
238
-
239
- ### Capabilities & Native Detection (Agnostic)
240
-
241
- **What triggers document update (e.g., `docs/permissions.md`, `docs/native-features.md`):**
242
-
243
- - New platform capabilities requested (e.g., Info.plist keys, AndroidManifest permissions, or native package declarations)
244
- - New native bridges or modules detected in codebase
245
- - Modified permission usage or descriptions
246
-
247
- **How to update:**
248
-
249
- - Document new capabilities and their usage rationale
250
- - Update native integration guides if patterns changed
251
- - Maintain existing documentation for stable features
252
-
253
- ### Native Features Detection
254
-
255
- **What triggers `docs/native-features.md` update:**
256
-
257
- - New native modules in `package.json` (React Native)
258
- - New native modules in `pubspec.yaml` (Flutter)
259
- - New native code files (`.swift`, `.kt`, `.m`, `.java`)
260
- - Modified native integrations
261
-
262
- **How to update:**
263
-
264
- - Add new native modules to native features documentation
265
- - Update integration patterns if changed
266
- - Maintain all existing native features
267
-
268
- ### State Management Detection
269
-
270
- **What triggers `docs/state-management.md` update:**
271
-
272
- - New store files (Redux, Zustand, MobX, Provider, Bloc, etc.)
273
- - New custom hooks (`use*` files)
274
- - New state management patterns
275
- - Modified state structure
276
- - Deleted stores or hooks
277
-
278
- **How to update:**
279
-
280
- - Add new stores/hooks to state management documentation
281
- - Update state patterns if changed
282
- - Maintain all existing state management documentation
283
-
284
- ### Build Configuration Detection
285
-
286
- **What triggers `specs/build-configuration.md` update:**
287
-
288
- - Changes in `build.gradle` (Android)
289
- - Changes in `Podfile` (iOS)
290
- - Changes in `app.json` or `app.config.js` (React Native)
291
- - Changes in `pubspec.yaml` (Flutter)
292
- - Version number changes
293
-
294
- **How to update:**
295
-
296
- - Update build configuration documentation
297
- - Update version information
298
- - Maintain existing configuration
299
-
300
- ### Dependencies Detection
301
-
302
- **What triggers `ai-instructions.md` update:**
303
-
304
- - New entries in `package.json` or `pubspec.yaml`
305
- - Updated version numbers
306
- - New framework or library
307
-
308
- **How to update:**
309
-
310
- - Add to dependencies section
311
- - Update version information
312
- - Add to tools/libraries list if significant
313
- - Maintain all existing dependencies
314
-
315
- ### Architecture Detection
316
-
317
- **What triggers `docs/architecture.md` update:**
318
-
319
- - New modules or directories
320
- - Changed directory structure
321
- - New architectural patterns detected
322
-
323
- **How to update:**
324
-
325
- - Update architecture diagram (mermaid)
326
- - Add new modules to description
327
- - Maintain existing architecture description
328
-
329
- ### Configuration Detection
330
-
331
- **What triggers `specs/configuration.md` update:**
332
-
333
- - New environment variables in code
334
- - New external service integrations
335
- - Changed configuration patterns
336
-
337
- **How to update:**
338
-
339
- - Add new variables to configuration spec
340
- - Maintain existing variables
341
- ---
342
- ## Important Rules
343
-
344
- 1. **Incremental Updates Only:**
345
-
346
- - Only modify sections that changed
347
- - Preserve all existing content that hasn't changed
348
- - Maintain document structure and formatting
349
-
350
- 2. **Follow Existing Patterns:**
351
-
352
- - Use same format as existing documentation
353
- - Follow conventions established in original build
354
- - Maintain consistency with existing docs
355
-
356
- 3. **Update Analysis File:**
357
-
358
- - Always update `.ai-flow/cache/docs-analysis.json` after document updates
359
- - Include timestamp and change summary
360
- - Save complete current state for next comparison
361
-
362
- 4. **Mermaid Diagrams:**
363
-
364
- - Regenerate navigation diagrams when screens change
365
- - Regenerate architecture diagrams when structure changes
366
- - Use mermaid format for all diagrams
367
- ---
368
- ## 📊 MOBILE DIAGRAM REGENERATION GUIDELINES
369
-
370
- When regenerating mobile diagrams, follow these **critical** formatting rules:
371
-
372
- ### Navigation Diagrams (navigation.md)
373
-
374
- **Diagram Types:** `graph TD`, `graph LR`
375
-
376
- **Requirements:**
377
- 1. Show navigation hierarchy (Root → Tab → Stack → Screens)
378
- 2. Use subgraphs to group navigators and screens
379
- 3. Color code by level (Root=light blue, Tabs=blue, Stacks=orange)
380
- 4. Show authentication flows with decision diamonds
381
- 5. Include deep linking routes with ⚠️ for protected routes
382
- 6. Include actual screen names from the codebase
383
-
384
- **Quality Checklist:**
385
- - [ ] Code fence is exactly ` ```mermaid ` (lowercase, no spaces)
386
- - [ ] All major screens from src/screens/ are represented
387
- - [ ] Navigation hierarchy is clear (Tab + Stack pattern)
388
- - [ ] Colors are consistent (Root=#e3f2fd, Tabs=#e1f5ff, Stacks=#fff4e6)
389
- - [ ] Diagram renders without errors
390
- - [ ] Screen names match actual file names
391
- - [ ] Authentication flow shows protected routes
392
-
393
- **Example (Tab + Stack Navigation):**
394
- ````markdown
395
- ```mermaid
396
- graph TD
397
- subgraph "App Navigation"
398
- ROOT[Root Navigator]
399
- end
400
-
401
- subgraph "Tab Navigator"
402
- TAB1[Home Tab]
403
- TAB2[Profile Tab]
404
- end
405
-
406
- subgraph "Stack Navigators"
407
- subgraph "Home Stack"
408
- H1[Home Screen]
409
- H2[Product Detail]
410
- end
411
-
412
- subgraph "Profile Stack"
413
- P1[Profile Screen]
414
- P2[Edit Profile]
415
- end
416
- end
417
-
418
- ROOT --> TAB1
419
- ROOT --> TAB2
420
-
421
- TAB1 --> H1
422
- H1 --> H2
423
-
424
- TAB2 --> P1
425
- P1 --> P2
426
-
427
- style ROOT fill:#e3f2fd
428
- style TAB1 fill:#e1f5ff
429
- style H1 fill:#fff4e6
430
- style P1 fill:#fff4e6
431
- ```
432
- ````
433
- ---
434
- ### State Management Diagrams (state-management.md)
435
-
436
- **Diagram Types:** `graph LR`, `sequenceDiagram`, `graph TD`
437
-
438
- **Requirements:**
439
- 1. Show all state types (Server, Client, Local Storage, Cache)
440
- 2. Label with actual tools used (Redux, TanStack Query, AsyncStorage, etc.)
441
- 3. For sequence diagrams: show complete offline/online flow
442
- 4. For decision trees: show clear Yes/No branches
443
- 5. Include mobile-specific concerns (offline-first, slow networks)
444
- 6. Show cache layers (AsyncStorage, MMKV, WatermelonDB, Realm)
445
-
446
- **Quality Checklist:**
447
- - [ ] Code fence is exactly ` ```mermaid `
448
- - [ ] All state management tools are documented
449
- - [ ] Offline/online paths are clearly distinguished
450
- - [ ] State types are color coded consistently
451
- - [ ] Sequence diagrams show timing and sync operations
452
- - [ ] Cache layers are explicitly shown
453
- - [ ] Decision trees have all paths covered
454
-
455
- **Example (Mobile State with Offline):**
456
- ````markdown
457
- ```mermaid
458
- sequenceDiagram
459
- participant U as User
460
- participant UI as Screen
461
- participant Store as State Manager
462
- participant Cache as Local Cache
463
- participant API as API Service
464
- participant BE as Backend
465
-
466
- U->>UI: Open Product List
467
- UI->>Store: Request products
468
- Store->>Cache: Check local cache
469
-
470
- alt Cache Hit (Offline Mode)
471
- Cache-->>Store: Return cached data
472
- Store-->>UI: Display cached products
473
- UI-->>U: Show products (stale)
474
- end
475
-
476
- alt Online Mode
477
- Store->>API: Fetch fresh products
478
- API->>BE: GET /api/products
479
- BE-->>API: 200 OK + data
480
- API-->>Store: Return products
481
- Store->>Cache: Update cache
482
- Store-->>UI: Display fresh products
483
- UI-->>U: Show products (fresh)
484
- end
485
-
486
- Note over Cache: Cache valid for 5min
487
- ```
488
- ````
489
- ---
490
- ### Testing Diagrams (testing.md)
491
-
492
- **Diagram Type:** `graph TB`
493
-
494
- **Requirements:**
495
- 1. Show testing pyramid (70/20/10 distribution)
496
- 2. Distinguish between device and emulator tests
497
- 3. Include platform-specific tests (iOS/Android)
498
- 4. Show speed/cost trade-offs
499
- 5. Include all test types (Unit, Integration, E2E, Static)
500
-
501
- **Quality Checklist:**
502
- - [ ] Code fence is exactly ` ```mermaid `
503
- - [ ] Testing pyramid shows correct percentages
504
- - [ ] Mobile-specific concerns are highlighted (devices, emulators)
505
- - [ ] Platform-specific tests are distinguished (iOS vs Android)
506
- - [ ] Speed/cost annotations are included
507
- - [ ] Cross-platform testing strategy is clear
508
-
509
- **Example (Mobile Testing Pyramid):**
510
- ````markdown
511
- ```mermaid
512
- graph TB
513
- subgraph "Mobile Testing Pyramid"
514
- E2E["📱 E2E Tests (10%)<br/>Detox/Appium<br/>Slow, Expensive<br/>Full user flows on device"]
515
- INT["🔗 Integration Tests (20%)<br/>Component + API<br/>Medium Speed<br/>Screen rendering + navigation"]
516
- UNIT["⚡ Unit Tests (70%)<br/>Jest/XCTest<br/>Fast, Cheap<br/>Business logic, hooks, utilities"]
517
- end
518
-
519
- E2E --> INT
520
- INT --> UNIT
521
-
522
- style E2E fill:#fce4ec,stroke:#c2185b,stroke-width:2px
523
- style INT fill:#fff4e6,stroke:#f57c00,stroke-width:2px
524
- style UNIT fill:#e8f5e9,stroke:#388e3c,stroke-width:3px
525
- ```
526
- ````
527
- ---
528
- ### Common Formatting Rules (ALL Mobile Diagrams)
529
-
530
- **CRITICAL - Code Fence Syntax:**
531
- ```
532
- ✅ CORRECT: ```mermaid
533
- ❌ WRONG: ```Mermaid (capital M)
534
- ❌ WRONG: ``` mermaid (extra space)
535
- ```
536
-
537
- **Color Coding Standards (Mobile):**
538
- - Root Navigator: `#e3f2fd` (very light blue)
539
- - Tab Navigator: `#e1f5ff` (light blue)
540
- - Stack Navigator: `#fff4e6` (light orange)
541
- - Screens: default or specific colors
542
- - Protected Routes: `#fce4ec` (light pink)
543
- - Server State: `#e1f5ff` (light blue)
544
- - Client State: `#fff4e6` (light orange)
545
- - Local Storage: `#e8f5e9` (light green)
546
- - Cache: `#f3e5f5` (light purple)
547
- - E2E Tests: `#fce4ec` (light pink)
548
- - Integration Tests: `#fff4e6` (light orange)
549
- - Unit Tests: `#e8f5e9` (light green)
550
-
551
- **Validation Steps:**
552
- 1. Test diagram at https://mermaid.live/ before saving
553
- 2. Verify all screen/component names match actual codebase
554
- 3. Check that arrows flow in logical direction (top-down, left-right)
555
- 4. Confirm colors are applied consistently
556
- 5. Ensure diagram is readable (not too crowded)
557
- 6. Verify platform-specific considerations are included
558
-
559
- **When Updating Existing Diagrams:**
560
- 1. Read current diagram first
561
- 2. Identify added/removed/modified screens or components
562
- 3. Maintain existing styling and layout patterns
563
- 4. Update relationships based on code changes
564
- 5. Verify entire diagram still renders after changes
565
-
566
- **Mobile-Specific Considerations:**
567
- - Always show offline/online paths for state diagrams
568
- - Include cache layers (AsyncStorage, MMKV, WatermelonDB, Realm)
569
- - Distinguish between iOS and Android when platform-specific
570
- - Show device vs emulator distinction in testing diagrams
571
- - Include deep linking routes in navigation diagrams
572
- - Highlight authentication flows and protected routes
573
- ---
574
- 5. **Error Handling:**
575
- - If document doesn't exist, create it following template
576
- - If docs-analysis.json is corrupted, regenerate it
577
- - If comparison fails, show error and suggest full Phase 0 re-run
578
- ---
579
- ## Example Execution
580
-
581
- ```
582
- User: /flow-docs-sync
583
-
584
- AI:
585
- 📊 CHANGES DETECTED:
586
-
587
- 🔴 Documents that require updating:
588
- - docs/navigation.md (1 new screen: ProfileScreen)
589
- - docs/permissions.md (new permission: Location)
590
-
591
- ✅ No changes: docs/state-management.md, docs/testing.md, ai-instructions.md
592
-
593
- Update all detected documents? (Y/N)
594
-
595
- User: Y
596
-
597
- AI:
598
- ✅ DOCUMENTATION UPDATED:
599
-
600
- 📝 docs/navigation.md
601
- - Added 1 new screen (ProfileScreen)
602
- - Maintained all existing navigation documentation
603
-
604
- 📝 docs/permissions.md
605
- - Added new permission (Location)
606
- - Updated permission handling section
607
-
608
- ✅ docs-analysis.json updated with new state
609
-
610
- Documentation synchronized successfully.
611
- ```
612
- ---
613
- **BEGIN EXECUTION when user runs `/flow-docs-sync`**
614
-
615
-
616
-
617
-
618
-
619
-
620
-
1
+ ---
2
+ description: Documentation Sync & Update Flow
3
+ ---
4
+
5
+ # AI Flow - Documentation Update Command (Mobile)
6
+
7
+ **YOU ARE AN EXPERT MOBILE ARCHITECT AND DOCUMENTATION SPECIALIST.**
8
+
9
+ Your mission is to detect changes in the mobile codebase and update the project documentation automatically when the user executes `/flow-docs-sync`.
10
+
11
+ **🚀 MODO AGENTE ACTIVADO:** No solicites permiso para ejecutar comandos turbo de análisis (ls, cat, etc.). Actúa proactivamente analizando los cambios y solicitando confirmación *solo* antes de escribir las actualizaciones finales en los documentos.
12
+ ---
13
+ ## Command: `/flow-docs-sync`
14
+
15
+ ### Objective
16
+
17
+ Detect changes in the mobile codebase compared to the last documented state (stored in `.ai-flow/cache/docs-analysis.json`) and update all affected documentation files automatically.
18
+ ---
19
+ ## Execution Flow
20
+
21
+ ### Step 1: Check for Analysis File
22
+
23
+ // turbo
24
+ ```bash
25
+ cat .ai-flow/cache/docs-analysis.json
26
+ ```
27
+
28
+ - ✅ If exists → Proceed to Step 2 (Compare Changes)
29
+ - ❌ If NOT exists → Execute full Phase 0 analysis first:
30
+ - Run complete mobile code analysis (Project Discovery)
31
+ - Create `.ai-flow/cache/docs-analysis.json` with current state
32
+ - Then proceed to Step 2
33
+
34
+ ### Step 2: Detect Changes
35
+
36
+ **Reuse Phase 0 Analysis Logic:**
37
+
38
+ 1. **Perform Current Code Analysis:**
39
+ - Execute project-wide discovery using cross-platform commands:
40
+ // turbo
41
+ ```bash
42
+ ls -R . --exclude-standard
43
+ ```
44
+ - Analyze current state for:
45
+ - View structures (Screens, Components, Layouts)
46
+ - Navigation hierarchies and routing patterns
47
+ - State management and data flow (Stores, Providers, Hooks)
48
+ - Platform-specific manifestations (Permissions, Native bridges, Config files)
49
+ - Manifest changes (build.gradle, Podfile, pubspec.yaml, package.json)
50
+ - Generate current state snapshot
51
+
52
+ 2. **Compare with Previous State:**
53
+
54
+ - Load `.ai-flow/cache/docs-analysis.json`
55
+ - Compare current state vs previous state
56
+ - Detect changes in:
57
+ - **Interfaces:** New, modified, or deleted "entry points" (Screens, Routes)
58
+ - **State Logic:** New, modified, or deleted state containers/logic
59
+ - **Capabilities:** New permissions or native feature integrations
60
+ - **Dependencies:** Manifest changes (version bumps, new packages)
61
+ - **Architecture:** Structural changes (new modules, moved folders)
62
+ - **Configuration:** New environment keys or build settings
63
+
64
+ 3. **Generate Change Report:**
65
+ - Categorize changes by type
66
+ - Map changes to affected documentation files
67
+ - Identify critical vs optional updates
68
+
69
+ ### Step 3: Present Report and Confirm
70
+
71
+ **If changes detected:**
72
+
73
+ ```
74
+ 📊 CHANGES DETECTED:
75
+
76
+ 🔴 Documents that require updating:
77
+ - docs/navigation.md (2 new screens: ProfileScreen, SettingsScreen)
78
+ - docs/permissions.md (new permission: Camera)
79
+ - docs/native-features.md (new native module: react-native-camera)
80
+ - docs/state-management.md (new Redux store: userSlice)
81
+ - ai-instructions.md (new dependency "react-native-camera")
82
+
83
+ ⚠️ Moderate changes detected:
84
+ - docs/architecture.md (change in folder structure)
85
+ - specs/build-configuration.md (change in build.gradle)
86
+
87
+ ✅ No changes: docs/testing.md, docs/offline-strategy.md
88
+
89
+ Update all detected documents? (Y/N)
90
+ ```
91
+
92
+ **If NO changes detected:**
93
+
94
+ ```
95
+ ✅ No changes detected. Documentation is synchronized with current code.
96
+
97
+ No updates required.
98
+ ```
99
+
100
+ ### Step 4: Update Documents (If User Confirms)
101
+
102
+ **If user responds "Y", "Yes", "y", "yes", or similar:**
103
+
104
+ 1. **For each document that needs updating:**
105
+
106
+ **A) `docs/navigation.md`** (if screens/navigation changed):
107
+
108
+ - Read current `docs/navigation.md`
109
+ - Identify new/modified screens from analysis
110
+ - Add new screens following existing navigation conventions
111
+ - Update navigation structure if changed
112
+ - Remove deleted screens (if any)
113
+ - Maintain all existing content that hasn't changed
114
+ - Regenerate affected sections only
115
+
116
+ **B) `docs/permissions.md`** (if permissions changed):
117
+
118
+ - Read current `docs/permissions.md`
119
+ - Add new permissions detected in Info.plist or AndroidManifest.xml
120
+ - Update permission descriptions if changed
121
+ - Maintain all existing permissions
122
+
123
+ **C) `docs/native-features.md`** (if native modules changed):
124
+
125
+ - Read current `docs/native-features.md`
126
+ - Add new native modules detected in dependencies
127
+ - Update native feature integrations
128
+ - Maintain all existing native features
129
+
130
+ **D) `docs/state-management.md`** (if state management changed):
131
+
132
+ - Read current `docs/state-management.md`
133
+ - Update state management patterns with new stores/hooks
134
+ - Update state structure if changed
135
+ - Maintain all existing content that hasn't changed
136
+
137
+ **E) `docs/offline-strategy.md`** (if offline strategy changed):
138
+
139
+ - Read current `docs/offline-strategy.md`
140
+ - Update offline patterns if storage solution changed
141
+ - Update sync strategy if changed
142
+ - Maintain all existing content
143
+
144
+ **F) `ai-instructions.md`** (if dependencies changed):
145
+
146
+ - Read current `ai-instructions.md`
147
+ - Add new dependencies to appropriate sections
148
+ - Update version numbers if changed
149
+ - Maintain all existing rules and patterns
150
+
151
+ **G) `docs/architecture.md`** (if architecture changed):
152
+
153
+ - Read current `docs/architecture.md`
154
+ - Update architecture diagram (mermaid) if structure changed
155
+ - Update module descriptions
156
+ - Maintain all existing content
157
+
158
+ **H) `specs/build-configuration.md`** (if build config changed):
159
+
160
+ - Read current `specs/build-configuration.md`
161
+ - Update build configuration if build.gradle, Podfile, or app.json changed
162
+ - Update version information if changed
163
+ - Maintain existing configuration
164
+
165
+ **I) `specs/deployment.md`** (if deployment changed):
166
+
167
+ - Read current `specs/deployment.md`
168
+ - Update deployment procedures if changed
169
+ - Maintain existing procedures
170
+
171
+ **J) `docs/app-store.md`** (if app store config changed):
172
+
173
+ - Read current `docs/app-store.md`
174
+ - Update app store configuration if app.json or build config changed
175
+ - Maintain existing configuration
176
+
177
+ 2. **Update `docs-analysis.json`:**
178
+
179
+ - Save current state to `.ai-flow/cache/docs-analysis.json`
180
+ - Update timestamp
181
+ - Include all detected changes in metadata
182
+
183
+ 3. **Present Summary:**
184
+
185
+ ```
186
+ ✅ DOCUMENTATION UPDATED:
187
+
188
+ 📝 docs/navigation.md
189
+ - Added 2 new screens (ProfileScreen, SettingsScreen)
190
+ - Updated navigation structure
191
+ - Maintained all existing navigation documentation
192
+
193
+ 📝 docs/permissions.md
194
+ - Added new permission (Camera)
195
+ - Updated permission handling section
196
+
197
+ 📝 docs/native-features.md
198
+ - Added new native module (react-native-camera)
199
+ - Updated native features integration section
200
+
201
+ 📝 docs/state-management.md
202
+ - Added new Redux store (userSlice)
203
+ - Updated state management patterns
204
+
205
+ 📝 ai-instructions.md
206
+ - Added dependency "react-native-camera"
207
+ - Updated tools section
208
+
209
+ 📝 specs/build-configuration.md
210
+ - Updated build.gradle configuration
211
+
212
+ ✅ docs-analysis.json updated with new state
213
+ ```
214
+
215
+ ### Step 5: Handle Cancellation
216
+
217
+ **If user responds "N", "No", "n", "no", or similar:**
218
+
219
+ ```
220
+ Update cancelled. Run `/flow-docs-sync` when you're ready to update the documentation.
221
+ ```
222
+ ---
223
+ ## Change Detection Rules
224
+
225
+ ### View & Interface Detection (Agnostic)
226
+
227
+ **What triggers document update (e.g., `docs/navigation.md`):**
228
+
229
+ - New view markers (e.g., Screen definitions, route mappings, or public component exports)
230
+ - Modified navigation paths, hierarchies, or routing logic
231
+ - Deleted views or screens
232
+
233
+ **How to update:**
234
+
235
+ - Add new views following the established patterns in the project
236
+ - Update navigation diagrams (Mermaid) to reflect new hierarchies
237
+ - Maintain existing documentation for unchanged segments
238
+
239
+ ### Capabilities & Native Detection (Agnostic)
240
+
241
+ **What triggers document update (e.g., `docs/permissions.md`, `docs/native-features.md`):**
242
+
243
+ - New platform capabilities requested (e.g., Info.plist keys, AndroidManifest permissions, or native package declarations)
244
+ - New native bridges or modules detected in codebase
245
+ - Modified permission usage or descriptions
246
+
247
+ **How to update:**
248
+
249
+ - Document new capabilities and their usage rationale
250
+ - Update native integration guides if patterns changed
251
+ - Maintain existing documentation for stable features
252
+
253
+ ### Native Features Detection
254
+
255
+ **What triggers `docs/native-features.md` update:**
256
+
257
+ - New native modules in `package.json` (React Native)
258
+ - New native modules in `pubspec.yaml` (Flutter)
259
+ - New native code files (`.swift`, `.kt`, `.m`, `.java`)
260
+ - Modified native integrations
261
+
262
+ **How to update:**
263
+
264
+ - Add new native modules to native features documentation
265
+ - Update integration patterns if changed
266
+ - Maintain all existing native features
267
+
268
+ ### State Management Detection
269
+
270
+ **What triggers `docs/state-management.md` update:**
271
+
272
+ - New store files (Redux, Zustand, MobX, Provider, Bloc, etc.)
273
+ - New custom hooks (`use*` files)
274
+ - New state management patterns
275
+ - Modified state structure
276
+ - Deleted stores or hooks
277
+
278
+ **How to update:**
279
+
280
+ - Add new stores/hooks to state management documentation
281
+ - Update state patterns if changed
282
+ - Maintain all existing state management documentation
283
+
284
+ ### Build Configuration Detection
285
+
286
+ **What triggers `specs/build-configuration.md` update:**
287
+
288
+ - Changes in `build.gradle` (Android)
289
+ - Changes in `Podfile` (iOS)
290
+ - Changes in `app.json` or `app.config.js` (React Native)
291
+ - Changes in `pubspec.yaml` (Flutter)
292
+ - Version number changes
293
+
294
+ **How to update:**
295
+
296
+ - Update build configuration documentation
297
+ - Update version information
298
+ - Maintain existing configuration
299
+
300
+ ### Dependencies Detection
301
+
302
+ **What triggers `ai-instructions.md` update:**
303
+
304
+ - New entries in `package.json` or `pubspec.yaml`
305
+ - Updated version numbers
306
+ - New framework or library
307
+
308
+ **How to update:**
309
+
310
+ - Add to dependencies section
311
+ - Update version information
312
+ - Add to tools/libraries list if significant
313
+ - Maintain all existing dependencies
314
+
315
+ ### Architecture Detection
316
+
317
+ **What triggers `docs/architecture.md` update:**
318
+
319
+ - New modules or directories
320
+ - Changed directory structure
321
+ - New architectural patterns detected
322
+
323
+ **How to update:**
324
+
325
+ - Update architecture diagram (mermaid)
326
+ - Add new modules to description
327
+ - Maintain existing architecture description
328
+
329
+ ### Configuration Detection
330
+
331
+ **What triggers `specs/configuration.md` update:**
332
+
333
+ - New environment variables in code
334
+ - New external service integrations
335
+ - Changed configuration patterns
336
+
337
+ **How to update:**
338
+
339
+ - Add new variables to configuration spec
340
+ - Maintain existing variables
341
+ ---
342
+ ## Important Rules
343
+
344
+ 1. **Incremental Updates Only:**
345
+
346
+ - Only modify sections that changed
347
+ - Preserve all existing content that hasn't changed
348
+ - Maintain document structure and formatting
349
+
350
+ 2. **Follow Existing Patterns:**
351
+
352
+ - Use same format as existing documentation
353
+ - Follow conventions established in original build
354
+ - Maintain consistency with existing docs
355
+
356
+ 3. **Update Analysis File:**
357
+
358
+ - Always update `.ai-flow/cache/docs-analysis.json` after document updates
359
+ - Include timestamp and change summary
360
+ - Save complete current state for next comparison
361
+
362
+ 4. **Mermaid Diagrams:**
363
+
364
+ - Regenerate navigation diagrams when screens change
365
+ - Regenerate architecture diagrams when structure changes
366
+ - Use mermaid format for all diagrams
367
+ ---
368
+ ## 📊 MOBILE DIAGRAM REGENERATION GUIDELINES
369
+
370
+ When regenerating mobile diagrams, follow these **critical** formatting rules:
371
+
372
+ ### Navigation Diagrams (navigation.md)
373
+
374
+ **Diagram Types:** `graph TD`, `graph LR`
375
+
376
+ **Requirements:**
377
+ 1. Show navigation hierarchy (Root → Tab → Stack → Screens)
378
+ 2. Use subgraphs to group navigators and screens
379
+ 3. Color code by level (Root=light blue, Tabs=blue, Stacks=orange)
380
+ 4. Show authentication flows with decision diamonds
381
+ 5. Include deep linking routes with ⚠️ for protected routes
382
+ 6. Include actual screen names from the codebase
383
+
384
+ **Quality Checklist:**
385
+ - [ ] Code fence is exactly ` ```mermaid ` (lowercase, no spaces)
386
+ - [ ] All major screens from src/screens/ are represented
387
+ - [ ] Navigation hierarchy is clear (Tab + Stack pattern)
388
+ - [ ] Colors are consistent (Root=#e3f2fd, Tabs=#e1f5ff, Stacks=#fff4e6)
389
+ - [ ] Diagram renders without errors
390
+ - [ ] Screen names match actual file names
391
+ - [ ] Authentication flow shows protected routes
392
+
393
+ **Example (Tab + Stack Navigation):**
394
+ ````markdown
395
+ ```mermaid
396
+ graph TD
397
+ subgraph "App Navigation"
398
+ ROOT[Root Navigator]
399
+ end
400
+
401
+ subgraph "Tab Navigator"
402
+ TAB1[Home Tab]
403
+ TAB2[Profile Tab]
404
+ end
405
+
406
+ subgraph "Stack Navigators"
407
+ subgraph "Home Stack"
408
+ H1[Home Screen]
409
+ H2[Product Detail]
410
+ end
411
+
412
+ subgraph "Profile Stack"
413
+ P1[Profile Screen]
414
+ P2[Edit Profile]
415
+ end
416
+ end
417
+
418
+ ROOT --> TAB1
419
+ ROOT --> TAB2
420
+
421
+ TAB1 --> H1
422
+ H1 --> H2
423
+
424
+ TAB2 --> P1
425
+ P1 --> P2
426
+
427
+ style ROOT fill:#e3f2fd
428
+ style TAB1 fill:#e1f5ff
429
+ style H1 fill:#fff4e6
430
+ style P1 fill:#fff4e6
431
+ ```
432
+ ````
433
+ ---
434
+ ### State Management Diagrams (state-management.md)
435
+
436
+ **Diagram Types:** `graph LR`, `sequenceDiagram`, `graph TD`
437
+
438
+ **Requirements:**
439
+ 1. Show all state types (Server, Client, Local Storage, Cache)
440
+ 2. Label with actual tools used (Redux, TanStack Query, AsyncStorage, etc.)
441
+ 3. For sequence diagrams: show complete offline/online flow
442
+ 4. For decision trees: show clear Yes/No branches
443
+ 5. Include mobile-specific concerns (offline-first, slow networks)
444
+ 6. Show cache layers (AsyncStorage, MMKV, WatermelonDB, Realm)
445
+
446
+ **Quality Checklist:**
447
+ - [ ] Code fence is exactly ` ```mermaid `
448
+ - [ ] All state management tools are documented
449
+ - [ ] Offline/online paths are clearly distinguished
450
+ - [ ] State types are color coded consistently
451
+ - [ ] Sequence diagrams show timing and sync operations
452
+ - [ ] Cache layers are explicitly shown
453
+ - [ ] Decision trees have all paths covered
454
+
455
+ **Example (Mobile State with Offline):**
456
+ ````markdown
457
+ ```mermaid
458
+ sequenceDiagram
459
+ participant U as User
460
+ participant UI as Screen
461
+ participant Store as State Manager
462
+ participant Cache as Local Cache
463
+ participant API as API Service
464
+ participant BE as Backend
465
+
466
+ U->>UI: Open Product List
467
+ UI->>Store: Request products
468
+ Store->>Cache: Check local cache
469
+
470
+ alt Cache Hit (Offline Mode)
471
+ Cache-->>Store: Return cached data
472
+ Store-->>UI: Display cached products
473
+ UI-->>U: Show products (stale)
474
+ end
475
+
476
+ alt Online Mode
477
+ Store->>API: Fetch fresh products
478
+ API->>BE: GET /api/products
479
+ BE-->>API: 200 OK + data
480
+ API-->>Store: Return products
481
+ Store->>Cache: Update cache
482
+ Store-->>UI: Display fresh products
483
+ UI-->>U: Show products (fresh)
484
+ end
485
+
486
+ Note over Cache: Cache valid for 5min
487
+ ```
488
+ ````
489
+ ---
490
+ ### Testing Diagrams (testing.md)
491
+
492
+ **Diagram Type:** `graph TB`
493
+
494
+ **Requirements:**
495
+ 1. Show testing pyramid (70/20/10 distribution)
496
+ 2. Distinguish between device and emulator tests
497
+ 3. Include platform-specific tests (iOS/Android)
498
+ 4. Show speed/cost trade-offs
499
+ 5. Include all test types (Unit, Integration, E2E, Static)
500
+
501
+ **Quality Checklist:**
502
+ - [ ] Code fence is exactly ` ```mermaid `
503
+ - [ ] Testing pyramid shows correct percentages
504
+ - [ ] Mobile-specific concerns are highlighted (devices, emulators)
505
+ - [ ] Platform-specific tests are distinguished (iOS vs Android)
506
+ - [ ] Speed/cost annotations are included
507
+ - [ ] Cross-platform testing strategy is clear
508
+
509
+ **Example (Mobile Testing Pyramid):**
510
+ ````markdown
511
+ ```mermaid
512
+ graph TB
513
+ subgraph "Mobile Testing Pyramid"
514
+ E2E["📱 E2E Tests (10%)<br/>Detox/Appium<br/>Slow, Expensive<br/>Full user flows on device"]
515
+ INT["🔗 Integration Tests (20%)<br/>Component + API<br/>Medium Speed<br/>Screen rendering + navigation"]
516
+ UNIT["⚡ Unit Tests (70%)<br/>Jest/XCTest<br/>Fast, Cheap<br/>Business logic, hooks, utilities"]
517
+ end
518
+
519
+ E2E --> INT
520
+ INT --> UNIT
521
+
522
+ style E2E fill:#fce4ec,stroke:#c2185b,stroke-width:2px
523
+ style INT fill:#fff4e6,stroke:#f57c00,stroke-width:2px
524
+ style UNIT fill:#e8f5e9,stroke:#388e3c,stroke-width:3px
525
+ ```
526
+ ````
527
+ ---
528
+ ### Common Formatting Rules (ALL Mobile Diagrams)
529
+
530
+ **CRITICAL - Code Fence Syntax:**
531
+ ```
532
+ ✅ CORRECT: ```mermaid
533
+ ❌ WRONG: ```Mermaid (capital M)
534
+ ❌ WRONG: ``` mermaid (extra space)
535
+ ```
536
+
537
+ **Color Coding Standards (Mobile):**
538
+ - Root Navigator: `#e3f2fd` (very light blue)
539
+ - Tab Navigator: `#e1f5ff` (light blue)
540
+ - Stack Navigator: `#fff4e6` (light orange)
541
+ - Screens: default or specific colors
542
+ - Protected Routes: `#fce4ec` (light pink)
543
+ - Server State: `#e1f5ff` (light blue)
544
+ - Client State: `#fff4e6` (light orange)
545
+ - Local Storage: `#e8f5e9` (light green)
546
+ - Cache: `#f3e5f5` (light purple)
547
+ - E2E Tests: `#fce4ec` (light pink)
548
+ - Integration Tests: `#fff4e6` (light orange)
549
+ - Unit Tests: `#e8f5e9` (light green)
550
+
551
+ **Validation Steps:**
552
+ 1. Test diagram at https://mermaid.live/ before saving
553
+ 2. Verify all screen/component names match actual codebase
554
+ 3. Check that arrows flow in logical direction (top-down, left-right)
555
+ 4. Confirm colors are applied consistently
556
+ 5. Ensure diagram is readable (not too crowded)
557
+ 6. Verify platform-specific considerations are included
558
+
559
+ **When Updating Existing Diagrams:**
560
+ 1. Read current diagram first
561
+ 2. Identify added/removed/modified screens or components
562
+ 3. Maintain existing styling and layout patterns
563
+ 4. Update relationships based on code changes
564
+ 5. Verify entire diagram still renders after changes
565
+
566
+ **Mobile-Specific Considerations:**
567
+ - Always show offline/online paths for state diagrams
568
+ - Include cache layers (AsyncStorage, MMKV, WatermelonDB, Realm)
569
+ - Distinguish between iOS and Android when platform-specific
570
+ - Show device vs emulator distinction in testing diagrams
571
+ - Include deep linking routes in navigation diagrams
572
+ - Highlight authentication flows and protected routes
573
+ ---
574
+ 5. **Error Handling:**
575
+ - If document doesn't exist, create it following template
576
+ - If docs-analysis.json is corrupted, regenerate it
577
+ - If comparison fails, show error and suggest full Phase 0 re-run
578
+ ---
579
+ ## Example Execution
580
+
581
+ ```
582
+ User: /flow-docs-sync
583
+
584
+ AI:
585
+ 📊 CHANGES DETECTED:
586
+
587
+ 🔴 Documents that require updating:
588
+ - docs/navigation.md (1 new screen: ProfileScreen)
589
+ - docs/permissions.md (new permission: Location)
590
+
591
+ ✅ No changes: docs/state-management.md, docs/testing.md, ai-instructions.md
592
+
593
+ Update all detected documents? (Y/N)
594
+
595
+ User: Y
596
+
597
+ AI:
598
+ ✅ DOCUMENTATION UPDATED:
599
+
600
+ 📝 docs/navigation.md
601
+ - Added 1 new screen (ProfileScreen)
602
+ - Maintained all existing navigation documentation
603
+
604
+ 📝 docs/permissions.md
605
+ - Added new permission (Location)
606
+ - Updated permission handling section
607
+
608
+ ✅ docs-analysis.json updated with new state
609
+
610
+ Documentation synchronized successfully.
611
+ ```
612
+ ---
613
+ **BEGIN EXECUTION when user runs `/flow-docs-sync`**
614
+
615
+
616
+
617
+
618
+
619
+
620
+