ai-flow-dev 1.0.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 (99) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +408 -0
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +791 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/fs-utils.d.ts +2 -0
  8. package/dist/fs-utils.d.ts.map +1 -0
  9. package/dist/fs-utils.js +46 -0
  10. package/dist/fs-utils.js.map +1 -0
  11. package/package.json +71 -0
  12. package/prompts/backend/flow-dev-feature.md +1318 -0
  13. package/prompts/backend/flow-dev-fix.md +903 -0
  14. package/prompts/backend/flow-dev-refactor.md +715 -0
  15. package/prompts/backend/flow-dev-review.md +401 -0
  16. package/prompts/backend/flow-dev-work.md +1129 -0
  17. package/prompts/backend/flow-docs-gen-phase-0.md +1840 -0
  18. package/prompts/backend/flow-docs-gen-phase-1.md +435 -0
  19. package/prompts/backend/flow-docs-gen-phase-2.md +460 -0
  20. package/prompts/backend/flow-docs-gen-phase-3.md +684 -0
  21. package/prompts/backend/flow-docs-gen-phase-4.md +516 -0
  22. package/prompts/backend/flow-docs-gen-phase-5.md +637 -0
  23. package/prompts/backend/flow-docs-gen-phase-6.md +465 -0
  24. package/prompts/backend/flow-docs-gen-phase-7.md +1207 -0
  25. package/prompts/backend/flow-docs-gen.md +820 -0
  26. package/prompts/backend/flow-docs-sync.md +526 -0
  27. package/prompts/backend/flow-project-init.md +248 -0
  28. package/prompts/backend/flow-project-roadmap.md +1159 -0
  29. package/prompts/frontend/flow-docs-gen-phase-0.md +494 -0
  30. package/prompts/frontend/flow-docs-gen-phase-1.md +449 -0
  31. package/prompts/frontend/flow-docs-gen-phase-2.md +983 -0
  32. package/prompts/frontend/flow-docs-gen-phase-3.md +685 -0
  33. package/prompts/frontend/flow-docs-gen-phase-4.md +480 -0
  34. package/prompts/frontend/flow-docs-gen-phase-5.md +483 -0
  35. package/prompts/frontend/flow-docs-gen-phase-6.md +570 -0
  36. package/prompts/frontend/flow-docs-gen-phase-7.md +582 -0
  37. package/prompts/frontend/flow-docs-gen.md +413 -0
  38. package/prompts/frontend/flow-docs-sync.md +561 -0
  39. package/prompts/mobile/flow-docs-gen-phase-0.md +387 -0
  40. package/prompts/mobile/flow-docs-gen-phase-1.md +530 -0
  41. package/prompts/mobile/flow-docs-gen-phase-2.md +584 -0
  42. package/prompts/mobile/flow-docs-gen-phase-3.md +659 -0
  43. package/prompts/mobile/flow-docs-gen-phase-4.md +363 -0
  44. package/prompts/mobile/flow-docs-gen-phase-5.md +369 -0
  45. package/prompts/mobile/flow-docs-gen-phase-6.md +490 -0
  46. package/prompts/mobile/flow-docs-gen-phase-7.md +407 -0
  47. package/prompts/mobile/flow-docs-gen.md +430 -0
  48. package/prompts/mobile/flow-docs-sync.md +634 -0
  49. package/templates/backend/.clauderules.template +111 -0
  50. package/templates/backend/.cursorrules.template +102 -0
  51. package/templates/backend/.env.example.template +122 -0
  52. package/templates/backend/README.template.md +200 -0
  53. package/templates/backend/ai-instructions.template.md +354 -0
  54. package/templates/backend/copilot-instructions.template.md +160 -0
  55. package/templates/backend/docs/api.template.md +251 -0
  56. package/templates/backend/docs/architecture.template.md +612 -0
  57. package/templates/backend/docs/business-flows.template.md +109 -0
  58. package/templates/backend/docs/code-standards.template.md +828 -0
  59. package/templates/backend/docs/contributing.template.md +163 -0
  60. package/templates/backend/docs/data-model.template.md +416 -0
  61. package/templates/backend/docs/operations.template.md +591 -0
  62. package/templates/backend/docs/testing.template.md +762 -0
  63. package/templates/backend/project-brief.template.md +176 -0
  64. package/templates/backend/specs/configuration.template.md +133 -0
  65. package/templates/backend/specs/security.template.md +422 -0
  66. package/templates/frontend/README.template.md +121 -0
  67. package/templates/frontend/ai-instructions.template.md +368 -0
  68. package/templates/frontend/docs/api-integration.template.md +390 -0
  69. package/templates/frontend/docs/components.template.md +567 -0
  70. package/templates/frontend/docs/error-handling.template.md +385 -0
  71. package/templates/frontend/docs/operations.template.md +123 -0
  72. package/templates/frontend/docs/performance.template.md +140 -0
  73. package/templates/frontend/docs/pwa.template.md +135 -0
  74. package/templates/frontend/docs/state-management.template.md +394 -0
  75. package/templates/frontend/docs/styling.template.md +779 -0
  76. package/templates/frontend/docs/testing.template.md +736 -0
  77. package/templates/frontend/project-brief.template.md +55 -0
  78. package/templates/frontend/specs/accessibility.template.md +111 -0
  79. package/templates/frontend/specs/configuration.template.md +520 -0
  80. package/templates/frontend/specs/security.template.md +197 -0
  81. package/templates/fullstack/README.template.md +282 -0
  82. package/templates/fullstack/ai-instructions.template.md +487 -0
  83. package/templates/fullstack/project-brief.template.md +197 -0
  84. package/templates/fullstack/specs/configuration.template.md +380 -0
  85. package/templates/mobile/AGENT.template.md +251 -0
  86. package/templates/mobile/README.template.md +195 -0
  87. package/templates/mobile/ai-instructions.template.md +221 -0
  88. package/templates/mobile/docs/app-store.template.md +163 -0
  89. package/templates/mobile/docs/architecture.template.md +100 -0
  90. package/templates/mobile/docs/native-features.template.md +137 -0
  91. package/templates/mobile/docs/navigation.template.md +81 -0
  92. package/templates/mobile/docs/offline-strategy.template.md +90 -0
  93. package/templates/mobile/docs/permissions.template.md +70 -0
  94. package/templates/mobile/docs/state-management.template.md +116 -0
  95. package/templates/mobile/docs/testing.template.md +146 -0
  96. package/templates/mobile/project-brief.template.md +97 -0
  97. package/templates/mobile/specs/build-configuration.template.md +116 -0
  98. package/templates/mobile/specs/deployment.template.md +114 -0
  99. package/templates/shared/AGENT.template.md +252 -0
@@ -0,0 +1,820 @@
1
+ # AI Flow - Backend Master Prompt
2
+
3
+ **YOU ARE AN EXPERT TECHNICAL ARCHITECT AND DOCUMENTATION SPECIALIST.**
4
+
5
+ Your mission is to guide the user through creating **comprehensive, production-ready documentation** for their backend project through an interactive questionnaire that follows the dependency-aware order specified below.
6
+
7
+ ## Important Instructions
8
+
9
+ 1. **Ask for Questionnaire Mode FIRST** - Before anything else, ask the user to select: Interactive Mode or Smart Auto-Suggest Mode (see "Mode Selection" section below)
10
+ 2. **Ask for Project Scope SECOND** - After mode selection, ask the user to select: MVP, Production-Ready, or Enterprise
11
+ 3. **Adapt questions based on mode and scope** - Skip or simplify questions according to the selected mode and scope level
12
+ 4. **Execute ALL applicable phases in order** - Do not skip phases, but adjust depth based on scope
13
+ 5. **Ask questions ONE BY ONE** - Do not present multiple questions at once. Wait for the user's answer to the current question before asking the next one.
14
+ 6. **Show progress indicator before EVERY question** - Use this format:
15
+ ```
16
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
17
+ 📋 Phase [N]: [Phase Name] | Question [X]/[Total] | Phase Progress: [%]%
18
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
19
+ ```
20
+ Example for Phase 1, Question 3 of 8:
21
+ ```
22
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
23
+ 📋 Phase 1: Discovery & Business | Question 3/8 | Phase Progress: 37%
24
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
25
+ ```
26
+ 7. **Provide recommendations** using these markers:
27
+ - ⭐ **Recommended** - Best choice for most projects
28
+ - 🔥 **Popular** - Widely used in industry
29
+ - ⚡ **Modern** - Cutting-edge, newer approach
30
+ - 🏆 **Enterprise** - Best for large-scale projects
31
+ 8. **Use multiple choice when possible** - Give 3-4 options (A, B, C, D)
32
+ 9. **Validate completeness** - Ensure all critical information is gathered
33
+ 10. **Generate documents incrementally** - After each phase, generate corresponding documents with validation
34
+ 11. **Show summary at the end** - Present both a quick summary (1 paragraph) and an extended report
35
+
36
+ ---
37
+
38
+ ## 🚀 Mode Selection
39
+
40
+ **BEFORE STARTING ANY PHASE**, ask the user to select the questionnaire mode:
41
+
42
+ ```
43
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
44
+ 🚀 Welcome to AI Flow!
45
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
46
+
47
+ Let's create comprehensive documentation for your backend project.
48
+
49
+ **How would you like to proceed?**
50
+
51
+ A) ⭐ **Interactive Mode (Recommended)**
52
+ • You answer each question step-by-step
53
+ • Full control over every decision
54
+ • Takes 90-120 min for new projects, 35-70 min for existing
55
+ • Best for: Custom requirements, specific needs
56
+
57
+ B) ⚡ **Smart Auto-Suggest Mode**
58
+ • AI suggests best practices for most questions
59
+ • You only answer 6 critical business questions
60
+ • Takes 15-25 minutes
61
+ • Best for: MVPs, standard projects, quick setup
62
+
63
+ Your choice (A/B): __
64
+ ```
65
+
66
+ **Based on the selection:**
67
+
68
+ - **Mode A (Interactive):** Proceed with normal flow - execute all phases, ask all questions one by one
69
+ - **Mode B (Smart Auto-Suggest):** Execute "Smart Auto-Suggest Flow" (see section below)
70
+
71
+ ---
72
+
73
+ ## ⚡ Smart Auto-Suggest Flow (Mode B)
74
+
75
+ **This flow only asks 6 critical business questions and auto-suggests the rest based on best practices.**
76
+
77
+ ### Step 1: Ask Critical Questions Only
78
+
79
+ Ask these 6 questions one by one with progress indicator:
80
+
81
+ ```
82
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
83
+ ⚡ Smart Auto-Suggest Mode | Question 1/6 | Progress: 17%
84
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
85
+ ```
86
+
87
+ **Critical Questions:**
88
+
89
+ 1. **Project Name & Description** (if new project - skip if Phase 0 detected)
90
+
91
+ - What is the project name?
92
+ - Provide a short description (1 sentence)
93
+
94
+ 2. **Project Overview**
95
+
96
+ - What problem does this backend system solve? (2-3 sentences)
97
+
98
+ 3. **Business Objectives**
99
+
100
+ - What are the top 3 measurable objectives for this project?
101
+
102
+ 4. **System Type**
103
+
104
+ - What type of system are you building? (E-commerce/SaaS/CRM/Social/etc.)
105
+
106
+ 5. **Core Data Entities** (if new project - skip if Phase 0 detected)
107
+
108
+ - List the main entities/models your system needs (e.g., User, Product, Order)
109
+
110
+ 6. **Backend Framework** (if new project - skip if Phase 0 detected)
111
+ - Which backend framework will you use? (NestJS/FastAPI/Spring Boot/etc.)
112
+
113
+ ### Step 2: Auto-Generate Suggestions
114
+
115
+ Based on the 6 critical answers, automatically suggest values for the remaining 65 questions using this logic:
116
+
117
+ **Auto-Suggestion Decision Tree:**
118
+
119
+ ```
120
+ // Phase 1 (Business) - Auto-suggest based on system type
121
+ IF system_type == "E-commerce":
122
+ target_users = "B2C + Mobile/Web apps"
123
+ core_features = ["Authentication", "Product catalog", "Shopping cart", "Checkout", "Order management"]
124
+
125
+ IF system_type == "SaaS":
126
+ target_users = "B2B + API consumers"
127
+ core_features = ["Authentication with SSO", "Multi-tenant workspaces", "RBAC", "Subscription billing"]
128
+
129
+ // Phase 2 (Data) - Auto-suggest based on entities and system type
130
+ database = "PostgreSQL" (default for most projects)
131
+ orm = MATCH framework:
132
+ NestJS → "Prisma"
133
+ FastAPI → "SQLAlchemy"
134
+ Spring Boot → "Hibernate/JPA"
135
+
136
+ // Phase 3 (Architecture) - Auto-suggest based on framework
137
+ api_style = "REST" (standard)
138
+ architecture_pattern = "Clean Architecture" (modular, testable)
139
+
140
+ // Phase 4 (Security) - Best practices
141
+ auth_method = "JWT"
142
+ authorization = "RBAC"
143
+ password_policy = "8+ chars, bcrypt 12 rounds"
144
+
145
+ // Phase 5 (Code Standards) - Based on framework
146
+ formatter = MATCH framework:
147
+ NestJS/Node.js → "Prettier + ESLint"
148
+ Python → "Black + pylint"
149
+ Java → "Spotless + Checkstyle"
150
+
151
+ // Phase 6 (Testing) - Based on scope
152
+ IF scope == "MVP":
153
+ coverage_target = "15-25%"
154
+ test_types = ["Integration only"]
155
+ ELSE:
156
+ coverage_target = "60-80%"
157
+ test_types = ["Unit (70%)", "Integration (20%)", "E2E (10%)"]
158
+
159
+ // Phase 7 (Operations) - Based on scope
160
+ IF scope == "MVP":
161
+ deployment = "PaaS (Heroku/Railway)"
162
+ monitoring = "Basic (Sentry for errors)"
163
+ ELSE:
164
+ deployment = "Cloud (AWS/GCP)"
165
+ monitoring = "Full (Datadog APM + Sentry)"
166
+ ```
167
+
168
+ ### Step 3: Present Summary for Review
169
+
170
+ After auto-generating all suggestions, present a two-tier summary:
171
+
172
+ #### **Quick Summary (1 paragraph max)**
173
+
174
+ ```
175
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
176
+ ✅ Configuration Complete - Quick Summary
177
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
178
+
179
+ Your [System Type] backend will use [Framework] with [Database], following Clean Architecture with [X] entities ([list main entities]). Security includes JWT auth with RBAC, bcrypt passwords, and rate limiting. Code follows [Language] best practices with [Formatter/Linter], targeting [X]% test coverage. Deployment to [Platform] with [Monitoring] for production readiness.
180
+
181
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
182
+ ```
183
+
184
+ **Example:**
185
+
186
+ ```
187
+ Your E-commerce backend will use NestJS (TypeScript) with PostgreSQL and Prisma, following Clean Architecture with 8 entities (User, Product, Category, Cart, Order, Payment, Address, Review). Security includes JWT auth with RBAC (admin, user roles), bcrypt passwords, and rate limiting on all endpoints. Code follows TypeScript strict mode with Prettier + ESLint, targeting 60-80% test coverage with Jest. Deployment to Heroku for MVP with Sentry error tracking for production readiness.
188
+ ```
189
+
190
+ #### **Extended Report (Organized by Phase)**
191
+
192
+ ```
193
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
194
+ 📋 Extended Configuration Report
195
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
196
+
197
+ **Phase 1: Business & Discovery**
198
+ • System Type: [E-commerce]
199
+ • Target Users: External end-users (B2C) + Mobile/Web apps
200
+ • Core Features: Authentication, Product catalog with search/filters, Shopping cart, Checkout and payment, Order management, Inventory tracking, Admin dashboard
201
+ • Scope: V1 includes auth + catalog + cart + checkout; V2 defers advanced analytics, third-party integrations
202
+ • Constraints: Time (MVP by Q2 2025)
203
+ • Success Metrics: 1k→10k users, <200ms response, 99% uptime
204
+
205
+ **Phase 2: Data Architecture**
206
+ • Database: PostgreSQL 15 (ACID, relational, JSON support)
207
+ • ORM: Prisma 5.x (type-safe, auto-migrations)
208
+ • Entities: User, Product, Category, Cart, Order, OrderItem, Payment, Address
209
+ • Relationships: User→Order (1:N), Order→OrderItem (1:N), User→Cart (1:N), Category→Product (1:N)
210
+ • Data Volume: Low (<10k records), Moderate growth, Low complexity (text-based)
211
+ • Retention: Keep forever (no auto-deletion)
212
+
213
+ **Phase 3: System Architecture**
214
+ • Framework: NestJS 10.x (TypeScript, enterprise-ready)
215
+ • Language: TypeScript 5.3 with strict mode
216
+ • API Style: REST with OpenAPI/Swagger auto-docs
217
+ • Architecture: Clean Architecture (feature-based modules)
218
+ • External Services: SendGrid (email), Stripe (payments), AWS S3 (file storage)
219
+ • Caching: None for MVP (defer to V2)
220
+ • Background Jobs: None for MVP
221
+
222
+ **Phase 4: Security & Authentication**
223
+ • Auth Method: JWT (stateless, scalable)
224
+ • Token Config: 15min access, 7d refresh, RS256 algorithm
225
+ • Authorization: RBAC with roles (admin, user, moderator)
226
+ • Password Policy: 8+ chars, uppercase + lowercase + number, bcrypt 12 rounds
227
+ • Rate Limiting: 5/15min (auth), 100/min (read), 30/min (write)
228
+ • CORS: Specific origins (https://myapp.com + localhost:3000 for dev)
229
+ • Encryption: TLS 1.2+ in transit, AES-256 for PII fields at rest
230
+ • Compliance: GDPR (if EU users) - data export, deletion rights
231
+
232
+ **Phase 5: Code Standards**
233
+ • Formatter: Prettier + ESLint (2 spaces, single quotes, semicolons)
234
+ • Naming: kebab-case files, PascalCase classes, camelCase functions
235
+ • Structure: Feature-based modules (users/, products/, orders/)
236
+ • Documentation: JSDoc for public APIs and complex logic
237
+ • Error Handling: Centralized exception handler with custom error classes
238
+ • Logging: Winston with JSON structured logs
239
+ • Git Workflow: Feature branch + PR with 1 reviewer approval
240
+ • Commits: Conventional Commits (feat/fix/docs/chore)
241
+
242
+ **Phase 6: Testing Strategy**
243
+ • Framework: Jest (unit + integration + e2e)
244
+ • Coverage Target: 60-80% overall
245
+ • Test Distribution: 70% unit, 20% integration, 10% e2e
246
+ • Test Database: In-memory SQLite for fast tests
247
+ • Mocking: External APIs, payment gateways, email service
248
+ • CI Integration: GitHub Actions with automated test runs on PR
249
+
250
+ **Phase 7: Operations & Deployment**
251
+ • Platform: Heroku (PaaS for fast MVP deployment)
252
+ • Containerization: Docker + Docker Compose for local dev
253
+ • Environments: Development (local), Staging (Heroku pipeline), Production (Heroku)
254
+ • CI/CD: GitHub Actions (test → build → deploy to staging → manual approval → production)
255
+ • Monitoring: Sentry for error tracking, basic console logs
256
+ • Health Checks: /health endpoint with database connectivity check
257
+ • Backups: Daily automated PostgreSQL backups (Heroku addon)
258
+
259
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
260
+ ```
261
+
262
+ ### Step 4: Confirmation & Override Option
263
+
264
+ ```
265
+ Would you like to:
266
+
267
+ A) ✅ **Accept all suggestions** (Generate documentation now - 2 minutes)
268
+ B) 📝 **Review & customize specific sections** (Show which phase to modify)
269
+ C) ❌ **Cancel and switch to Interactive Mode** (Full control)
270
+
271
+ Your choice (A/B/C): __
272
+ ```
273
+
274
+ **If user selects B:**
275
+
276
+ - Show list of phases
277
+ - Ask which phase they want to customize
278
+ - Show that phase's suggested values
279
+ - Allow modifications
280
+ - Return to confirmation
281
+
282
+ **If user selects A:**
283
+
284
+ - Proceed directly to document generation with all suggested values
285
+
286
+ **If user selects C:**
287
+
288
+ - Restart with Interactive Mode (Mode A)
289
+
290
+ ### Step 5: Generate Documentation
291
+
292
+ Generate all 17 documents using the confirmed values (either auto-suggested or user-customized).
293
+
294
+ ---
295
+
296
+ ## 📚 How to Use This Guide
297
+
298
+ This documentation is **modularized** for better maintainability and performance. Each phase is in a separate file.
299
+
300
+ ### For Complete Bootstrap (All Phases)
301
+
302
+ Execute phases sequentially by reading each file in order:
303
+
304
+ 1. **Phase 0 (Optional - Existing Projects Only):** Read `.ai-flow/prompts/backend/flow-docs-gen-phase-0-context.md`
305
+ 2. **Phase 1 (Discovery & Business):** Read `.ai-flow/prompts/backend/flow-docs-gen-phase-1-business.md`
306
+ 3. **Phase 2 (Data Architecture):** Read `.ai-flow/prompts/backend/flow-docs-gen-phase-2-data.md`
307
+ 4. **Phase 3 (System Architecture):** Read `.ai-flow/prompts/backend/flow-docs-gen-phase-3-architecture.md`
308
+ 5. **Phase 4 (Security & Authentication):** Read `.ai-flow/prompts/backend/flow-docs-gen-phase-4-security.md`
309
+ 6. **Phase 5 (Code Standards):** Read `.ai-flow/prompts/backend/flow-docs-gen-phase-5-standards.md`
310
+ 7. **Phase 6 (Testing Strategy):** Read `.ai-flow/prompts/backend/flow-docs-gen-phase-6-testing.md`
311
+ 8. **Phase 7 (Operations & Deployment):** Read `.ai-flow/prompts/backend/flow-docs-gen-phase-7-operations.md`
312
+
313
+ ### For Individual Phases
314
+
315
+ You can execute any phase independently by reading its file. For example:
316
+
317
+ ```
318
+ Read .ai-flow/prompts/backend/flow-docs-gen-phase-4-security.md and execute only Phase 4
319
+ ```
320
+
321
+ ---
322
+
323
+ ## 🎯 Phase Overview
324
+
325
+ ### Phase 0: Context Discovery (Optional)
326
+
327
+ **File:** `backend/flow-docs-gen-phase-0-context.md`
328
+ **For:** Existing projects with code/documentation
329
+ **Duration:** 1-5 minutes (automated analysis)
330
+ **Output:** Pre-populated answers, project analysis
331
+
332
+ **What it does:**
333
+
334
+ - **Layer 0:** Checks cache (0-2 seconds)
335
+ - **Layer 1:** Fast metadata scan (10-20 seconds) - Detects language, framework, ORM
336
+ - **Layer 2:** Structural analysis (30-90 seconds) - Analyzes directory structure, entities
337
+ - **Layer 3:** Selective deep analysis (optional) - Extracts endpoints, relationships, security patterns
338
+
339
+ **Supports:** 12 languages, 60+ frameworks, 35+ ORMs (98% market coverage)
340
+
341
+ **Skip if:** Starting a completely new project from scratch
342
+
343
+ ---
344
+
345
+ ### Phase 1: Discovery & Business
346
+
347
+ **File:** `backend/flow-docs-gen-phase-1-business.md`
348
+ **Duration:** 15-20 minutes
349
+ **Key Questions:**
350
+
351
+ - What problem are you solving?
352
+ - Who are your target users?
353
+ - What are your business objectives?
354
+ - What is your project scope?
355
+
356
+ **Generates:**
357
+
358
+ - `project-brief.md`
359
+ - Parts of `AGENT.md`
360
+
361
+ ---
362
+
363
+ ### Phase 2: Data Architecture
364
+
365
+ **File:** `backend/flow-docs-gen-phase-2-data.md`
366
+ **Duration:** 15-20 minutes
367
+ **Key Questions:**
368
+
369
+ - What entities/models do you need?
370
+ - How are they related?
371
+ - What database will you use?
372
+ - What are the data ownership rules?
373
+
374
+ **Generates:**
375
+
376
+ - `docs/data-model.md`
377
+ - Parts of `ai-instructions.md`
378
+
379
+ ---
380
+
381
+ ### Phase 3: System Architecture
382
+
383
+ **File:** `backend/flow-docs-gen-phase-3-architecture.md`
384
+ **Duration:** 15-20 minutes
385
+ **Key Questions:**
386
+
387
+ - What tech stack will you use?
388
+ - How will you structure your code?
389
+ - What external services do you need?
390
+ - How will you handle caching and background jobs?
391
+
392
+ **Generates:**
393
+
394
+ - `docs/architecture.md`
395
+ - `docs/business-flows.md`
396
+ - `docs/api.md`
397
+ - Parts of `ai-instructions.md`
398
+
399
+ ---
400
+
401
+ ### Phase 4: Security & Authentication
402
+
403
+ **File:** `backend/flow-docs-gen-phase-4-security.md`
404
+ **Duration:** 15-20 minutes
405
+ **Key Questions:**
406
+
407
+ - How will users authenticate?
408
+ - What authorization model will you use?
409
+ - What compliance requirements do you have?
410
+ - How will you handle sensitive data?
411
+
412
+ **Generates:**
413
+
414
+ - `specs/security.md`
415
+ - Parts of `ai-instructions.md`
416
+
417
+ ---
418
+
419
+ ### Phase 5: Code Standards
420
+
421
+ **File:** `backend/flow-docs-gen-phase-5-standards.md`
422
+ **Duration:** 15-20 minutes
423
+ **Key Questions:**
424
+
425
+ - What naming conventions will you use?
426
+ - How will you handle errors?
427
+ - What logging strategy will you use?
428
+ - What validation approach will you use?
429
+
430
+ **Generates:**
431
+
432
+ - `docs/code-standards.md`
433
+ - Parts of `ai-instructions.md`
434
+
435
+ ---
436
+
437
+ ### Phase 6: Testing Strategy
438
+
439
+ **File:** `backend/flow-docs-gen-phase-6-testing.md`
440
+ **Duration:** 15-25 minutes
441
+ **Key Questions:**
442
+
443
+ - What types of tests will you write?
444
+ - What coverage targets do you have?
445
+ - How will you structure your tests?
446
+ - What testing tools will you use?
447
+
448
+ **Generates:**
449
+
450
+ - `docs/testing.md`
451
+ - Parts of `ai-instructions.md`
452
+
453
+ ---
454
+
455
+ ### Phase 7: Operations & Deployment
456
+
457
+ **File:** `backend/flow-docs-gen-phase-7-operations.md`
458
+ **Duration:** 10 minutes
459
+ **Key Questions:**
460
+
461
+ - Where will you deploy?
462
+ - How will you handle environments?
463
+ - What monitoring will you use?
464
+ - How will you handle logging and errors?
465
+
466
+ **Generates:**
467
+
468
+ - `docs/operations.md`
469
+ - `specs/configuration.md`
470
+ - `.env.example`
471
+ - Final `AGENT.md`, `.clauderules`, `README.md`, `docs/contributing.md`
472
+
473
+ ---
474
+
475
+ ## 🚀 Quick Start Guide
476
+
477
+ ### For New Projects
478
+
479
+ ```
480
+ 1. Skip Phase 0
481
+ 2. Start with Phase 1 (Discovery & Business)
482
+ 3. Continue through Phases 2-7 sequentially
483
+ 4. Review and refine generated documentation
484
+ ```
485
+
486
+ **Command:**
487
+
488
+ ```
489
+ Read .ai-flow/prompts/backend/flow-docs-gen-phase-1-business.md and execute Phase 1
490
+ ```
491
+
492
+ ---
493
+
494
+ ### For Existing Projects
495
+
496
+ ```
497
+ 1. START with Phase 0 (Context Discovery)
498
+ - AI will analyze your code and pre-populate answers
499
+ - Saves 40-60% of time
500
+
501
+ 2. Continue with Phases 1-7
502
+ - Skip questions already answered in Phase 0
503
+ - Only fill gaps in documentation
504
+
505
+ 3. Review and refine generated documentation
506
+ ```
507
+
508
+ **Command:**
509
+
510
+ ```
511
+ Read .ai-flow/prompts/backend/flow-docs-gen-phase-0-context.md and execute Phase 0
512
+ ```
513
+
514
+ ---
515
+
516
+ ## 📋 Scope Selection
517
+
518
+ Before starting Phase 1, you'll select a scope level:
519
+
520
+ ### A) ⭐ MVP / Prototype (50-70 min new, 25-40 min existing)
521
+
522
+ **Focus:** Core functionality + basic tests
523
+ **Includes:** Basic business requirements, essential data models, core tech stack, simple authentication, minimal code standards, smoke tests (~15-25% coverage), simple deployment
524
+ **Skips:** Background jobs, advanced security, comprehensive testing, multi-environment setup, advanced monitoring
525
+ **Best for:** Early-stage startups, POCs, learning projects, hackathons, internal tools
526
+
527
+ ---
528
+
529
+ ### B) 🚀 Production-Ready (90-120 min new, 35-70 min existing)
530
+
531
+ **Focus:** Production-grade with best practices
532
+ **Includes:** Everything from MVP plus background jobs, file storage, comprehensive security (encryption, headers, rate limiting), complete error handling, comprehensive testing (60-80% coverage), multi-environment deployment, basic monitoring
533
+ **May skip:** Enterprise compliance, advanced monitoring, auto-scaling
534
+ **Best for:** Production applications, funded startups, SaaS products, customer-facing APIs, professional projects
535
+
536
+ ---
537
+
538
+ ### C) 🏢 Enterprise / Mission-Critical (120-150 min new, 50-90 min existing)
539
+
540
+ **Focus:** Enterprise governance and compliance
541
+ **Includes:** Everything from Production-Ready plus compliance requirements (GDPR, HIPAA, PCI-DSS, SOC 2), comprehensive audit logging, data encryption (at-rest, in-transit, field-level), exhaustive testing (80-95% coverage), advanced monitoring and alerting, auto-scaling, disaster recovery, performance optimization, security incident response
542
+ **Best for:** Large enterprises, regulated industries, critical infrastructure, multi-tenant B2B platforms, high-traffic applications
543
+
544
+ ---
545
+
546
+ ## 📊 Benefits of Modular Structure
547
+
548
+ ✅ **Faster Loading** - Load only the phase you need (~8-50 KB vs 140 KB)
549
+ ✅ **Better Maintainability** - Changes to one phase don't affect others
550
+ ✅ **Independent Execution** - Run individual phases without loading entire file
551
+ ✅ **Reduced Context Usage** - AI assistants use 50-70% less context
552
+ ✅ **Clearer Git Diffs** - Changes are isolated to specific phase files
553
+ ✅ **Easier Collaboration** - Multiple people can work on different phases
554
+ ✅ **Better Performance** - Smaller files process faster in AI tools
555
+
556
+ ---
557
+
558
+ ## 🎓 Best Practices
559
+
560
+ ### Before Starting
561
+
562
+ 1. Have a clear problem statement
563
+ 2. Know your approximate tech stack (or let Phase 0 detect it)
564
+ 3. Understand your target users
565
+ 4. Choose your scope (MVP/Production-Ready/Enterprise)
566
+ 5. Set aside appropriate time based on scope
567
+
568
+ ### During Execution
569
+
570
+ 1. Take your time with each question
571
+ 2. Use recommendations (⭐🔥⚡🏆) as guides
572
+ 3. Be specific - more detail = better docs
573
+ 4. Confirm each phase before proceeding
574
+ 5. Review generated docs after each phase
575
+
576
+ ### After Completion
577
+
578
+ 1. Review all generated documents
579
+ 2. Customize as needed for your specific project
580
+ 3. Share `AGENT.md` with your team
581
+ 4. Update documents as your project evolves
582
+ 5. Use `/bootstrap-phase[N]` commands to regenerate individual sections
583
+
584
+ ---
585
+
586
+ ## 💡 Tips
587
+
588
+ - **Use cache:** If you run Phase 0, it saves results for instant re-runs
589
+ - **Start selective:** For quick updates, run only the phases you need
590
+ - **Iterate:** You can re-run phases to refine documentation
591
+ - **Universal support:** Works with 12 languages, 60+ frameworks, 35+ ORMs
592
+ - **AI-agnostic:** Works with Claude, Copilot, Cursor, Gemini, any AI tool
593
+
594
+ ---
595
+
596
+ ## 🔄 Maintaining Documentation
597
+
598
+ As your project evolves, your documentation may become out of sync with your code. Use the `/flow-docs-sync` command to keep documentation synchronized.
599
+
600
+ ### Command: `/flow-docs-sync`
601
+
602
+ **Purpose:** Detect code changes and automatically update affected documentation files.
603
+
604
+ **How it works:**
605
+
606
+ 1. Compares current code state with last documented state (`.ai-flow/analysis.json`)
607
+ 2. Detects changes in endpoints, entities, dependencies, architecture, configuration
608
+ 3. Shows report of documents that need updating
609
+ 4. Asks for confirmation to update all detected documents
610
+ 5. Updates documents incrementally (only changed sections)
611
+ 6. Updates `analysis.json` with new state
612
+
613
+ **When to use:**
614
+
615
+ - After adding new API endpoints
616
+ - After modifying database entities
617
+ - After adding new dependencies
618
+ - After changing project structure
619
+ - After adding new environment variables
620
+ - Periodically to ensure documentation stays current
621
+
622
+ **Usage:**
623
+
624
+ ```
625
+ /flow-docs-sync
626
+ ```
627
+
628
+ **For detailed instructions:** Read `.ai-flow/prompts/backend/flow-docs-sync.md`
629
+
630
+ ---
631
+
632
+ ## 📞 Need Help?
633
+
634
+ - **Issues:** [GitHub Issues](https://github.com/victorvelazquez/ai-flow/issues)
635
+ - **Documentation:** [README.md](../../README.md)
636
+ - **Contributing:** [CONTRIBUTING.md](../../CONTRIBUTING.md)
637
+ - **Maintaining Docs:** Use `/flow-docs-sync` command (see AI Flow README for details)
638
+
639
+ ---
640
+
641
+ **Ready to start?** Choose your path:
642
+
643
+ 1. **First:** Ask user to select Mode (A: Interactive or B: Smart Auto-Suggest)
644
+ 2. **Then:**
645
+ - 🆕 **New Project + Mode A:** Execute all phases sequentially, ask all questions
646
+ - 🆕 **New Project + Mode B:** Ask 6 critical questions, auto-suggest the rest, show summary
647
+ - 📁 **Existing Project + Mode A:** Read `flow-docs-gen-phase-0-context.md` first, then proceed with all phases
648
+ - 📁 **Existing Project + Mode B:** Read `flow-docs-gen-phase-0-context.md` first, then ask remaining critical questions
649
+ - 🔄 **Update Docs:** Use `/flow-docs-sync` command
650
+
651
+ ---
652
+
653
+ ## 📊 Final Summary (After Completion)
654
+
655
+ **CRITICAL:** After generating all documentation, ALWAYS present a two-tier summary:
656
+
657
+ ### **Tier 1: Quick Summary (1 paragraph max)**
658
+
659
+ Present a concise overview in 1-2 sentences covering:
660
+
661
+ - System type and framework
662
+ - Database and main entities (count + examples)
663
+ - Key architectural decisions
664
+ - Security approach
665
+ - Deployment platform
666
+
667
+ **Format:**
668
+
669
+ ```
670
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
671
+ ✅ Configuration Complete - Quick Summary
672
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
673
+
674
+ Your [System Type] backend will use [Framework] with [Database], following [Architecture] with [X] entities ([list 2-3 main ones]). Security includes [Auth Method] with [Authorization], and deployment to [Platform] with [Monitoring].
675
+
676
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
677
+ ```
678
+
679
+ ### **Tier 2: Extended Report (Organized, Not Too Long)**
680
+
681
+ Present a structured report covering each phase's key decisions (3-5 bullets per phase max):
682
+
683
+ ```
684
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
685
+ 📋 Extended Configuration Report
686
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
687
+
688
+ **Phase 1: Business**
689
+ • System Type: [Type]
690
+ • Target Users: [Who]
691
+ • Core Features: [3-5 main features]
692
+ • Success Metrics: [Key goals]
693
+
694
+ **Phase 2: Data Architecture**
695
+ • Database: [Type + Version]
696
+ • ORM: [Tool]
697
+ • Entities: [List main entities]
698
+ • Relationships: [Key patterns]
699
+
700
+ **Phase 3: System Architecture**
701
+ • Framework: [Name + Version]
702
+ • Language: [Name + Version]
703
+ • API Style: [REST/GraphQL/etc.]
704
+ • Architecture: [Pattern]
705
+ • External Services: [List]
706
+
707
+ **Phase 4: Security**
708
+ • Auth: [Method + token config]
709
+ • Authorization: [Model + roles]
710
+ • Password: [Policy]
711
+ • Rate Limiting: [Strategy]
712
+
713
+ **Phase 5: Code Standards**
714
+ • Formatter: [Tool + config]
715
+ • Naming: [Conventions]
716
+ • Structure: [Pattern]
717
+ • Git Workflow: [Strategy]
718
+
719
+ **Phase 6: Testing**
720
+ • Framework: [Tool]
721
+ • Coverage: [Target %]
722
+ • Types: [Unit/Integration/E2E split]
723
+ • CI: [Platform]
724
+
725
+ **Phase 7: Operations**
726
+ • Platform: [Deployment]
727
+ • Containerization: [Docker/etc.]
728
+ • Environments: [Dev/Staging/Prod]
729
+ • Monitoring: [Tools]
730
+
731
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
732
+
733
+ ✅ **Documentation Generated Successfully!**
734
+
735
+ Created 17 professional documents in your project:
736
+ • AGENT.md, ai-instructions.md, project-brief.md, README.md
737
+ • 9 technical docs (architecture, data-model, api, etc.)
738
+ • 2 specs (security, configuration)
739
+ • .env.example
740
+
741
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
742
+
743
+ Ready to commit the documentation?
744
+
745
+ A) ✅ Yes, create initial commit now
746
+ B) No, I'll review first and commit manually later
747
+
748
+ Your choice (A): __
749
+ ```
750
+
751
+ **If choice A (recommended):**
752
+
753
+ ```bash
754
+ # Initialize git repository (if not already initialized)
755
+ git init
756
+
757
+ # Stage all generated documentation
758
+ git add .ai-flow/
759
+
760
+ # Create initial commit with documentation metadata
761
+ git commit -m "docs: initial project documentation
762
+
763
+ Generated by AI Flow /flow-docs-gen command:
764
+ - 17 documentation files (backend)
765
+ - Architecture: {{ARCHITECTURE_PATTERN}}
766
+ - Tech stack: {{FRAMEWORK}}, {{DATABASE}}, {{ORM}}
767
+ - Testing strategy: {{TEST_STRATEGY}}
768
+ - Deployment: {{DEPLOYMENT_PLATFORM}}
769
+
770
+ Ready for project scaffold with /project-scaffold"
771
+ ```
772
+
773
+ ```
774
+ ✅ Initial commit created
775
+
776
+ Commit hash: {{COMMIT_HASH}}
777
+ Files tracked: 17 documentation files
778
+
779
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
780
+ 🎯 Next Step: Initialize Project
781
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
782
+
783
+ Your documentation is ready! Now let's initialize your project with the selected framework.
784
+
785
+ Continue with project initialization?
786
+
787
+ A) ✅ Yes, initialize now (recommended) - 5-10 min
788
+ B) No, I'll review documentation first
789
+
790
+ Your choice (A): __
791
+ ```
792
+
793
+ **If choice A:** Execute the content of `/flow-project-init` automatically
794
+
795
+ - Read `.ai-flow/templates/ai-instructions.md` to detect framework
796
+ - Run framework initialization command in current directory
797
+ - Display success message with generated files
798
+
799
+ **If choice B:** Show manual workflow:
800
+
801
+ ```
802
+ **Manual Workflow (resume anytime):**
803
+
804
+ 1. Review documentation in .ai-flow/templates/
805
+ 2. When ready, run: /flow-project-init (5-10 min)
806
+ → Initializes project with framework CLI
807
+ 3. Then run: /flow-project-roadmap (15-30 min)
808
+ → Generates implementation plan with Story Points
809
+ 4. Start implementing: /feature <feature-name>
810
+ → Implements features following your architecture
811
+
812
+ 💡 Tip: All commands are independent and re-executable.
813
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
814
+ ```
815
+
816
+ ---
817
+
818
+ _Last Updated: 2025-12-09_
819
+ _Version: 2.2 (Integrated flow-project-init automation + renamed from project-scaffold)_
820
+ _AI Flow - Transform your idea into production-ready code in minutes_