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.
- package/LICENSE +21 -0
- package/README.md +408 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +791 -0
- package/dist/cli.js.map +1 -0
- package/dist/fs-utils.d.ts +2 -0
- package/dist/fs-utils.d.ts.map +1 -0
- package/dist/fs-utils.js +46 -0
- package/dist/fs-utils.js.map +1 -0
- package/package.json +71 -0
- package/prompts/backend/flow-dev-feature.md +1318 -0
- package/prompts/backend/flow-dev-fix.md +903 -0
- package/prompts/backend/flow-dev-refactor.md +715 -0
- package/prompts/backend/flow-dev-review.md +401 -0
- package/prompts/backend/flow-dev-work.md +1129 -0
- package/prompts/backend/flow-docs-gen-phase-0.md +1840 -0
- package/prompts/backend/flow-docs-gen-phase-1.md +435 -0
- package/prompts/backend/flow-docs-gen-phase-2.md +460 -0
- package/prompts/backend/flow-docs-gen-phase-3.md +684 -0
- package/prompts/backend/flow-docs-gen-phase-4.md +516 -0
- package/prompts/backend/flow-docs-gen-phase-5.md +637 -0
- package/prompts/backend/flow-docs-gen-phase-6.md +465 -0
- package/prompts/backend/flow-docs-gen-phase-7.md +1207 -0
- package/prompts/backend/flow-docs-gen.md +820 -0
- package/prompts/backend/flow-docs-sync.md +526 -0
- package/prompts/backend/flow-project-init.md +248 -0
- package/prompts/backend/flow-project-roadmap.md +1159 -0
- package/prompts/frontend/flow-docs-gen-phase-0.md +494 -0
- package/prompts/frontend/flow-docs-gen-phase-1.md +449 -0
- package/prompts/frontend/flow-docs-gen-phase-2.md +983 -0
- package/prompts/frontend/flow-docs-gen-phase-3.md +685 -0
- package/prompts/frontend/flow-docs-gen-phase-4.md +480 -0
- package/prompts/frontend/flow-docs-gen-phase-5.md +483 -0
- package/prompts/frontend/flow-docs-gen-phase-6.md +570 -0
- package/prompts/frontend/flow-docs-gen-phase-7.md +582 -0
- package/prompts/frontend/flow-docs-gen.md +413 -0
- package/prompts/frontend/flow-docs-sync.md +561 -0
- package/prompts/mobile/flow-docs-gen-phase-0.md +387 -0
- package/prompts/mobile/flow-docs-gen-phase-1.md +530 -0
- package/prompts/mobile/flow-docs-gen-phase-2.md +584 -0
- package/prompts/mobile/flow-docs-gen-phase-3.md +659 -0
- package/prompts/mobile/flow-docs-gen-phase-4.md +363 -0
- package/prompts/mobile/flow-docs-gen-phase-5.md +369 -0
- package/prompts/mobile/flow-docs-gen-phase-6.md +490 -0
- package/prompts/mobile/flow-docs-gen-phase-7.md +407 -0
- package/prompts/mobile/flow-docs-gen.md +430 -0
- package/prompts/mobile/flow-docs-sync.md +634 -0
- package/templates/backend/.clauderules.template +111 -0
- package/templates/backend/.cursorrules.template +102 -0
- package/templates/backend/.env.example.template +122 -0
- package/templates/backend/README.template.md +200 -0
- package/templates/backend/ai-instructions.template.md +354 -0
- package/templates/backend/copilot-instructions.template.md +160 -0
- package/templates/backend/docs/api.template.md +251 -0
- package/templates/backend/docs/architecture.template.md +612 -0
- package/templates/backend/docs/business-flows.template.md +109 -0
- package/templates/backend/docs/code-standards.template.md +828 -0
- package/templates/backend/docs/contributing.template.md +163 -0
- package/templates/backend/docs/data-model.template.md +416 -0
- package/templates/backend/docs/operations.template.md +591 -0
- package/templates/backend/docs/testing.template.md +762 -0
- package/templates/backend/project-brief.template.md +176 -0
- package/templates/backend/specs/configuration.template.md +133 -0
- package/templates/backend/specs/security.template.md +422 -0
- package/templates/frontend/README.template.md +121 -0
- package/templates/frontend/ai-instructions.template.md +368 -0
- package/templates/frontend/docs/api-integration.template.md +390 -0
- package/templates/frontend/docs/components.template.md +567 -0
- package/templates/frontend/docs/error-handling.template.md +385 -0
- package/templates/frontend/docs/operations.template.md +123 -0
- package/templates/frontend/docs/performance.template.md +140 -0
- package/templates/frontend/docs/pwa.template.md +135 -0
- package/templates/frontend/docs/state-management.template.md +394 -0
- package/templates/frontend/docs/styling.template.md +779 -0
- package/templates/frontend/docs/testing.template.md +736 -0
- package/templates/frontend/project-brief.template.md +55 -0
- package/templates/frontend/specs/accessibility.template.md +111 -0
- package/templates/frontend/specs/configuration.template.md +520 -0
- package/templates/frontend/specs/security.template.md +197 -0
- package/templates/fullstack/README.template.md +282 -0
- package/templates/fullstack/ai-instructions.template.md +487 -0
- package/templates/fullstack/project-brief.template.md +197 -0
- package/templates/fullstack/specs/configuration.template.md +380 -0
- package/templates/mobile/AGENT.template.md +251 -0
- package/templates/mobile/README.template.md +195 -0
- package/templates/mobile/ai-instructions.template.md +221 -0
- package/templates/mobile/docs/app-store.template.md +163 -0
- package/templates/mobile/docs/architecture.template.md +100 -0
- package/templates/mobile/docs/native-features.template.md +137 -0
- package/templates/mobile/docs/navigation.template.md +81 -0
- package/templates/mobile/docs/offline-strategy.template.md +90 -0
- package/templates/mobile/docs/permissions.template.md +70 -0
- package/templates/mobile/docs/state-management.template.md +116 -0
- package/templates/mobile/docs/testing.template.md +146 -0
- package/templates/mobile/project-brief.template.md +97 -0
- package/templates/mobile/specs/build-configuration.template.md +116 -0
- package/templates/mobile/specs/deployment.template.md +114 -0
- package/templates/shared/AGENT.template.md +252 -0
|
@@ -0,0 +1,1207 @@
|
|
|
1
|
+
## PHASE 7: Operations & Deployment (10 min)
|
|
2
|
+
|
|
3
|
+
> **Order for this phase:** 7.1 → 7.2 → 7.3 → 7.4 → 7.5 → 7.6 → 7.7 → 7.8 → 7.9 → 7.10 → 7.11
|
|
4
|
+
|
|
5
|
+
> **📌 Scope-based behavior:**
|
|
6
|
+
>
|
|
7
|
+
> - **MVP:** Ask 7.1-7.4 only (deployment basics), skip 7.5-7.11 (monitoring, scaling, backups), mark as "TBD"
|
|
8
|
+
> - **Production-Ready:** Ask 7.1-7.8, simplify 7.9-7.11 (advanced monitoring and scaling)
|
|
9
|
+
> - **Enterprise:** Ask all questions 7.1-7.11 with emphasis on reliability and disaster recovery
|
|
10
|
+
|
|
11
|
+
### Objective
|
|
12
|
+
|
|
13
|
+
Define deployment, monitoring, and operational practices.
|
|
14
|
+
|
|
15
|
+
**7.1 Deployment Environment**
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Where will you deploy?
|
|
20
|
+
|
|
21
|
+
A) ⭐ Cloud Platform
|
|
22
|
+
|
|
23
|
+
- AWS (ECS, Fargate, Lambda, EC2)
|
|
24
|
+
- Google Cloud (Cloud Run, GKE, Compute Engine)
|
|
25
|
+
- Azure (App Service, AKS, VMs)
|
|
26
|
+
|
|
27
|
+
B) 🔥 Platform-as-a-Service (PaaS)
|
|
28
|
+
|
|
29
|
+
- Heroku
|
|
30
|
+
- Railway
|
|
31
|
+
- Render
|
|
32
|
+
- Fly.io
|
|
33
|
+
- Vercel (for APIs)
|
|
34
|
+
|
|
35
|
+
C) 🏢 On-Premises
|
|
36
|
+
|
|
37
|
+
- Company servers
|
|
38
|
+
- Private cloud
|
|
39
|
+
|
|
40
|
+
D) 🐳 Container Orchestration
|
|
41
|
+
|
|
42
|
+
- Kubernetes (GKE, EKS, AKS)
|
|
43
|
+
- Docker Swarm
|
|
44
|
+
- Nomad
|
|
45
|
+
|
|
46
|
+
Your choice: \_\_
|
|
47
|
+
Why?
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**7.2 Containerization**
|
|
52
|
+
|
|
53
|
+
````
|
|
54
|
+
|
|
55
|
+
Will you use Docker?
|
|
56
|
+
|
|
57
|
+
A) ⭐ Yes - Dockerize application
|
|
58
|
+
|
|
59
|
+
- Multi-stage build
|
|
60
|
+
- Optimized image size
|
|
61
|
+
- Docker Compose for local dev
|
|
62
|
+
|
|
63
|
+
B) No - Deploy directly
|
|
64
|
+
|
|
65
|
+
If yes:
|
|
66
|
+
Base image: **
|
|
67
|
+
Estimated image size: ** MB
|
|
68
|
+
|
|
69
|
+
Example stack (local development):
|
|
70
|
+
|
|
71
|
+
```yaml
|
|
72
|
+
services:
|
|
73
|
+
app:
|
|
74
|
+
build: .
|
|
75
|
+
ports: [3000:3000]
|
|
76
|
+
db:
|
|
77
|
+
image: postgres:15
|
|
78
|
+
redis:
|
|
79
|
+
image: redis:7
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
````
|
|
83
|
+
|
|
84
|
+
**7.3 Environment Strategy**
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
How many environments will you have?
|
|
89
|
+
|
|
90
|
+
A) ⭐ Three environments
|
|
91
|
+
|
|
92
|
+
- Development (local)
|
|
93
|
+
- Staging (pre-production, QA)
|
|
94
|
+
- Production (live)
|
|
95
|
+
|
|
96
|
+
B) 🏆 Four+ environments
|
|
97
|
+
|
|
98
|
+
- Development
|
|
99
|
+
- Testing (automated tests)
|
|
100
|
+
- Staging
|
|
101
|
+
- Production
|
|
102
|
+
|
|
103
|
+
C) 🚀 Two environments
|
|
104
|
+
|
|
105
|
+
- Development
|
|
106
|
+
- Production
|
|
107
|
+
|
|
108
|
+
Your choice: \_\_
|
|
109
|
+
|
|
110
|
+
Environment configuration:
|
|
111
|
+
A) ✅ Environment variables (.env files)
|
|
112
|
+
B) ✅ Config service (AWS Secrets Manager, Vault)
|
|
113
|
+
C) ✅ Feature flags (LaunchDarkly, Unleash)
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**7.4 CI/CD Pipeline**
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
CI/CD platform:
|
|
122
|
+
|
|
123
|
+
A) ⭐ GitHub Actions - If using GitHub
|
|
124
|
+
B) 🔥 GitLab CI - If using GitLab
|
|
125
|
+
C) Jenkins - Self-hosted
|
|
126
|
+
D) CircleCI
|
|
127
|
+
E) Travis CI
|
|
128
|
+
F) AWS CodePipeline
|
|
129
|
+
G) Azure DevOps
|
|
130
|
+
|
|
131
|
+
Your choice: \_\_
|
|
132
|
+
|
|
133
|
+
Pipeline stages:
|
|
134
|
+
|
|
135
|
+
1. ✅ Checkout code
|
|
136
|
+
2. ✅ Install dependencies
|
|
137
|
+
3. ✅ Lint
|
|
138
|
+
4. ✅ Test (with coverage)
|
|
139
|
+
5. ✅ Build
|
|
140
|
+
6. ✅ Security scan (optional)
|
|
141
|
+
7. ✅ Deploy to staging
|
|
142
|
+
8. ⏸️ Manual approval (optional)
|
|
143
|
+
9. ✅ Deploy to production
|
|
144
|
+
|
|
145
|
+
Auto-deploy strategy:
|
|
146
|
+
A) ⭐ Auto-deploy to staging, manual approval for production
|
|
147
|
+
B) 🚀 Auto-deploy to production (main branch)
|
|
148
|
+
C) Manual deploy for all environments
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**7.4.1 Deployment Strategy**
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
What deployment strategy will you use?
|
|
156
|
+
|
|
157
|
+
A) ⭐ Standard deployment - Stop old, deploy new (downtime)
|
|
158
|
+
B) 🏆 Blue-Green deployment - Zero-downtime, instant rollback
|
|
159
|
+
C) ⚡ Canary deployment - Gradual rollout, A/B testing
|
|
160
|
+
D) Rolling deployment - Gradual replacement (Kubernetes)
|
|
161
|
+
|
|
162
|
+
If Blue-Green:
|
|
163
|
+
- Traffic switching: [Load balancer, DNS, etc.]
|
|
164
|
+
- Rollback: [Instant switch back to blue]
|
|
165
|
+
- Database migrations: [Strategy for zero-downtime]
|
|
166
|
+
|
|
167
|
+
If Canary:
|
|
168
|
+
- Initial traffic: __%
|
|
169
|
+
- Gradual increase: __% per __ minutes
|
|
170
|
+
- Success criteria: __
|
|
171
|
+
- Rollback trigger: __
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**7.5 Monitoring & Logging**
|
|
175
|
+
|
|
176
|
+
````
|
|
177
|
+
|
|
178
|
+
Monitoring tools:
|
|
179
|
+
|
|
180
|
+
Application Performance Monitoring (APM):
|
|
181
|
+
A) ⭐ Datadog - Full-featured, expensive
|
|
182
|
+
B) 🔥 New Relic - Popular
|
|
183
|
+
C) Sentry - Error tracking focus
|
|
184
|
+
D) ⚡ OpenTelemetry + Grafana - Open source
|
|
185
|
+
E) AWS CloudWatch
|
|
186
|
+
F) None yet
|
|
187
|
+
|
|
188
|
+
Your choice: \_\_
|
|
189
|
+
|
|
190
|
+
Logging:
|
|
191
|
+
A) ⭐ Centralized logging
|
|
192
|
+
|
|
193
|
+
- Winston/Pino (Node.js) → CloudWatch/Datadog
|
|
194
|
+
- Python logging → ELK Stack
|
|
195
|
+
|
|
196
|
+
B) Basic console logs
|
|
197
|
+
|
|
198
|
+
C) Structured JSON logging ⭐
|
|
199
|
+
|
|
200
|
+
```json
|
|
201
|
+
{
|
|
202
|
+
"level": "info",
|
|
203
|
+
"timestamp": "2024-01-15T10:30:00Z",
|
|
204
|
+
"userId": "123",
|
|
205
|
+
"action": "user.login",
|
|
206
|
+
"ip": "192.168.1.1",
|
|
207
|
+
"message": "User logged in successfully"
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Your logging strategy: \_\_
|
|
212
|
+
|
|
213
|
+
Metrics to track:
|
|
214
|
+
|
|
215
|
+
- ✅ Request rate (requests/sec)
|
|
216
|
+
- ✅ Error rate (% of failed requests)
|
|
217
|
+
- ✅ Response time (p50, p95, p99)
|
|
218
|
+
- ✅ Database query time
|
|
219
|
+
- ✅ Cache hit rate
|
|
220
|
+
- ✅ CPU/Memory usage
|
|
221
|
+
- Custom business metrics: \_\_
|
|
222
|
+
|
|
223
|
+
````
|
|
224
|
+
|
|
225
|
+
**7.6 Alerts**
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
When should you be alerted?
|
|
230
|
+
|
|
231
|
+
A) ✅ Error rate > **% (e.g., 1%)
|
|
232
|
+
B) ✅ Response time > **ms (e.g., 1000ms)
|
|
233
|
+
C) ✅ 5xx errors (server errors)
|
|
234
|
+
D) ✅ Service down (health check failure)
|
|
235
|
+
E) ✅ Database connection failures
|
|
236
|
+
F) ✅ Disk space > 80%
|
|
237
|
+
G) ✅ Memory usage > 85%
|
|
238
|
+
|
|
239
|
+
Alert channels:
|
|
240
|
+
A) ⭐ Email
|
|
241
|
+
B) 🔥 Slack/Discord
|
|
242
|
+
C) ⚡ PagerDuty/Opsgenie (on-call)
|
|
243
|
+
D) SMS (critical only)
|
|
244
|
+
|
|
245
|
+
Your preferences: \_\_
|
|
246
|
+
|
|
247
|
+
On-call rotation:
|
|
248
|
+
A) Yes - Using [PagerDuty/Opsgenie]
|
|
249
|
+
B) No - Monitor during business hours
|
|
250
|
+
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**7.7 Backup & Disaster Recovery**
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Backup strategy:
|
|
258
|
+
|
|
259
|
+
Database backups:
|
|
260
|
+
A) ⭐ Automated daily backups
|
|
261
|
+
|
|
262
|
+
- Retention: 30 days
|
|
263
|
+
- Point-in-time recovery
|
|
264
|
+
|
|
265
|
+
B) 🏆 Continuous backups
|
|
266
|
+
|
|
267
|
+
- Every hour
|
|
268
|
+
- 90 days retention
|
|
269
|
+
|
|
270
|
+
C) Manual backups weekly
|
|
271
|
+
|
|
272
|
+
Your strategy: **
|
|
273
|
+
Retention period: ** days
|
|
274
|
+
|
|
275
|
+
Disaster recovery:
|
|
276
|
+
|
|
277
|
+
- Recovery Time Objective (RTO): \_\_ (how fast to restore)
|
|
278
|
+
- Recovery Point Objective (RPO): \_\_ (acceptable data loss)
|
|
279
|
+
|
|
280
|
+
Example:
|
|
281
|
+
|
|
282
|
+
- RTO: 1 hour (service restored within 1 hour)
|
|
283
|
+
- RPO: 15 minutes (lose max 15 min of data)
|
|
284
|
+
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
**7.7.1 Database Migrations in Production**
|
|
288
|
+
|
|
289
|
+
```
|
|
290
|
+
How will you handle database migrations in production?
|
|
291
|
+
|
|
292
|
+
Zero-downtime migrations:
|
|
293
|
+
A) ⭐ Yes - Plan for zero-downtime migrations (Production-Ready/Enterprise)
|
|
294
|
+
B) No - Accept maintenance windows (MVP)
|
|
295
|
+
|
|
296
|
+
If zero-downtime:
|
|
297
|
+
- Strategy: [Expand/Contract, Blue-Green migrations, etc.]
|
|
298
|
+
- Rollback plan: __
|
|
299
|
+
- Testing: [Tested on staging, Dry-run process]
|
|
300
|
+
|
|
301
|
+
Migration windows (if not zero-downtime):
|
|
302
|
+
- Preferred time: __
|
|
303
|
+
- Duration: __ minutes
|
|
304
|
+
- Notification: __
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
**7.7.2 Database Connection Pooling**
|
|
308
|
+
|
|
309
|
+
```
|
|
310
|
+
Database connection pooling configuration:
|
|
311
|
+
|
|
312
|
+
Pool tool: [ORM built-in, pgBouncer, HikariCP, etc.]
|
|
313
|
+
|
|
314
|
+
Settings:
|
|
315
|
+
- Min connections: __
|
|
316
|
+
- Max connections: __
|
|
317
|
+
- Connection timeout: __ ms
|
|
318
|
+
- Idle timeout: __ ms
|
|
319
|
+
- Max lifetime: __ ms
|
|
320
|
+
|
|
321
|
+
Monitoring:
|
|
322
|
+
- Track active/idle connections: [Yes/No]
|
|
323
|
+
- Alert on pool exhaustion: [Yes/No]
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
**7.8 Scaling Strategy**
|
|
327
|
+
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
How will you handle growth?
|
|
331
|
+
|
|
332
|
+
A) ⭐ Horizontal scaling - Add more instances
|
|
333
|
+
|
|
334
|
+
- Load balancer distributes traffic
|
|
335
|
+
- Stateless application design
|
|
336
|
+
|
|
337
|
+
B) Vertical scaling - Bigger instances
|
|
338
|
+
|
|
339
|
+
- Increase CPU/RAM
|
|
340
|
+
- Simpler but limited
|
|
341
|
+
|
|
342
|
+
C) ⚡ Auto-scaling - Automatic based on load
|
|
343
|
+
|
|
344
|
+
- Scale up during high traffic
|
|
345
|
+
- Scale down to save costs
|
|
346
|
+
- Metrics: CPU > 70%, requests > threshold
|
|
347
|
+
|
|
348
|
+
Your strategy: \_\_
|
|
349
|
+
|
|
350
|
+
Expected load:
|
|
351
|
+
|
|
352
|
+
- Initial: \_\_ requests/minute
|
|
353
|
+
- Year 1: \_\_ requests/minute
|
|
354
|
+
- Peak traffic: \_\_x normal load
|
|
355
|
+
|
|
356
|
+
Database scaling:
|
|
357
|
+
A) Read replicas - Scale reads
|
|
358
|
+
B) Sharding - Split data across DBs
|
|
359
|
+
C) Vertical scaling - Bigger DB instance
|
|
360
|
+
D) Not needed yet
|
|
361
|
+
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
**7.9 Health Checks**
|
|
365
|
+
|
|
366
|
+
````
|
|
367
|
+
|
|
368
|
+
Health check endpoints:
|
|
369
|
+
|
|
370
|
+
A) ✅ /health - Basic liveness
|
|
371
|
+
|
|
372
|
+
- Returns 200 OK if app is running
|
|
373
|
+
|
|
374
|
+
B) ✅ /health/ready - Readiness check
|
|
375
|
+
|
|
376
|
+
- Returns 200 OK if app can handle traffic
|
|
377
|
+
- Checks: DB connected, Redis connected, etc.
|
|
378
|
+
|
|
379
|
+
C) ✅ /health/live - Liveness check
|
|
380
|
+
|
|
381
|
+
- Returns 200 OK if app is alive
|
|
382
|
+
- Load balancer uses this
|
|
383
|
+
|
|
384
|
+
Example response:
|
|
385
|
+
|
|
386
|
+
```json
|
|
387
|
+
{
|
|
388
|
+
"status": "healthy",
|
|
389
|
+
"timestamp": "2024-01-15T10:30:00Z",
|
|
390
|
+
"checks": {
|
|
391
|
+
"database": "ok",
|
|
392
|
+
"redis": "ok",
|
|
393
|
+
"disk_space": "ok"
|
|
394
|
+
},
|
|
395
|
+
"version": "1.2.3"
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
Your health check endpoints: \_\_
|
|
400
|
+
|
|
401
|
+
````
|
|
402
|
+
|
|
403
|
+
**7.9.1 Graceful Shutdown**
|
|
404
|
+
|
|
405
|
+
```
|
|
406
|
+
Will you implement graceful shutdown?
|
|
407
|
+
|
|
408
|
+
A) ⭐ Yes - Handle shutdown gracefully (Production-Ready/Enterprise)
|
|
409
|
+
B) No - Standard shutdown
|
|
410
|
+
|
|
411
|
+
If yes:
|
|
412
|
+
Shutdown sequence:
|
|
413
|
+
1. Stop accepting new requests (timeout: __s)
|
|
414
|
+
2. Finish processing current requests (timeout: __s)
|
|
415
|
+
3. Close database connections (timeout: __s)
|
|
416
|
+
4. Close other connections (Redis, message queues, etc.)
|
|
417
|
+
5. Exit process
|
|
418
|
+
|
|
419
|
+
Total shutdown timeout: __s
|
|
420
|
+
|
|
421
|
+
Implementation:
|
|
422
|
+
- Signal handling: [SIGTERM, SIGINT]
|
|
423
|
+
- Health check grace period: __s
|
|
424
|
+
- Connection drain timeout: __s
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
**7.9.2 Circuit Breakers & Resilience**
|
|
428
|
+
|
|
429
|
+
```
|
|
430
|
+
Will you implement circuit breakers?
|
|
431
|
+
|
|
432
|
+
A) ⭐ Yes - Protect against cascading failures (Production-Ready/Enterprise)
|
|
433
|
+
B) No - Direct service calls
|
|
434
|
+
|
|
435
|
+
If yes:
|
|
436
|
+
Circuit breaker tool: [Resilience4j, Hystrix, Polly, etc.]
|
|
437
|
+
|
|
438
|
+
Configuration:
|
|
439
|
+
- Failure threshold: __% (open circuit after X% failures)
|
|
440
|
+
- Success threshold: __% (close circuit after X% successes)
|
|
441
|
+
- Timeout: __ms
|
|
442
|
+
- Half-open retries: __
|
|
443
|
+
- Reset timeout: __s
|
|
444
|
+
|
|
445
|
+
Fallback strategy:
|
|
446
|
+
A) ⭐ Return cached data
|
|
447
|
+
B) Return default/empty response
|
|
448
|
+
C) Call alternative service
|
|
449
|
+
D) Return error gracefully
|
|
450
|
+
|
|
451
|
+
Services to protect:
|
|
452
|
+
{{#EACH SERVICE_TO_PROTECT}}
|
|
453
|
+
- **{{SERVICE_NAME}}**: {{FAILURE_THRESHOLD}}% threshold, fallback: {{FALLBACK_STRATEGY}}
|
|
454
|
+
{{/EACH}}
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
**7.10 Documentation & Runbooks**
|
|
458
|
+
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
Operational documentation:
|
|
462
|
+
|
|
463
|
+
A) ✅ Deployment guide - How to deploy
|
|
464
|
+
B) ✅ Runbooks - How to handle incidents
|
|
465
|
+
|
|
466
|
+
- Database connection failure → steps to diagnose/fix
|
|
467
|
+
- High CPU usage → steps to investigate
|
|
468
|
+
- Service down → recovery procedure
|
|
469
|
+
|
|
470
|
+
C) ✅ Architecture diagrams (Mermaid format)
|
|
471
|
+
|
|
472
|
+
- System architecture diagram (mermaid)
|
|
473
|
+
- Data flow diagram (mermaid)
|
|
474
|
+
- Infrastructure diagram (mermaid)
|
|
475
|
+
|
|
476
|
+
D) ✅ API documentation
|
|
477
|
+
|
|
478
|
+
- Swagger/OpenAPI
|
|
479
|
+
- Auto-generated from code
|
|
480
|
+
|
|
481
|
+
Will you create these?
|
|
482
|
+
A) Yes - All of them ⭐
|
|
483
|
+
B) Yes - Critical ones only (deployment, runbooks)
|
|
484
|
+
C) Later - Start without docs
|
|
485
|
+
|
|
486
|
+
API documentation strategy:
|
|
487
|
+
A) ⭐ Code-First (Recommended)
|
|
488
|
+
|
|
489
|
+
- Generate docs from code (Swagger/OpenAPI decorators)
|
|
490
|
+
- Always in sync with code
|
|
491
|
+
- Tools: @nestjs/swagger, FastAPI docs
|
|
492
|
+
|
|
493
|
+
B) 📝 Design-First
|
|
494
|
+
|
|
495
|
+
- Write openapi.yaml manually first
|
|
496
|
+
- Generate code from spec
|
|
497
|
+
- Better for large teams/contracts
|
|
498
|
+
|
|
499
|
+
C) 📄 Manual
|
|
500
|
+
|
|
501
|
+
- Write Markdown/Notion docs
|
|
502
|
+
- Hard to keep in sync (Not recommended)
|
|
503
|
+
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
---
|
|
507
|
+
|
|
508
|
+
#### 🎨 MERMAID OPERATIONS DIAGRAM FORMATS - CRITICAL
|
|
509
|
+
|
|
510
|
+
**Use these exact formats** for operational and infrastructure diagrams mentioned in question 7.10:
|
|
511
|
+
|
|
512
|
+
---
|
|
513
|
+
|
|
514
|
+
##### 1️⃣ System Architecture Diagram (Deployment View)
|
|
515
|
+
|
|
516
|
+
Use `graph TD` to show deployed system components with scaling and redundancy:
|
|
517
|
+
|
|
518
|
+
````markdown
|
|
519
|
+
```mermaid
|
|
520
|
+
graph TD
|
|
521
|
+
subgraph "Production Environment"
|
|
522
|
+
subgraph "Load Balancer Layer"
|
|
523
|
+
LB1[Load Balancer 1]
|
|
524
|
+
LB2[Load Balancer 2]
|
|
525
|
+
end
|
|
526
|
+
|
|
527
|
+
subgraph "Application Layer"
|
|
528
|
+
App1[API Server 1<br/>4 vCPU, 8GB RAM]
|
|
529
|
+
App2[API Server 2<br/>4 vCPU, 8GB RAM]
|
|
530
|
+
App3[API Server 3<br/>4 vCPU, 8GB RAM]
|
|
531
|
+
end
|
|
532
|
+
|
|
533
|
+
subgraph "Data Layer"
|
|
534
|
+
Primary[(Primary DB<br/>PostgreSQL 15)]
|
|
535
|
+
Replica1[(Read Replica 1)]
|
|
536
|
+
Replica2[(Read Replica 2)]
|
|
537
|
+
Cache[Redis Cluster<br/>3 Nodes]
|
|
538
|
+
end
|
|
539
|
+
|
|
540
|
+
subgraph "Message Queue"
|
|
541
|
+
Queue[RabbitMQ Cluster<br/>3 Nodes]
|
|
542
|
+
end
|
|
543
|
+
end
|
|
544
|
+
|
|
545
|
+
Internet[Internet] -->|HTTPS| LB1
|
|
546
|
+
Internet -->|HTTPS| LB2
|
|
547
|
+
LB1 --> App1
|
|
548
|
+
LB1 --> App2
|
|
549
|
+
LB2 --> App2
|
|
550
|
+
LB2 --> App3
|
|
551
|
+
|
|
552
|
+
App1 -->|Write| Primary
|
|
553
|
+
App2 -->|Write| Primary
|
|
554
|
+
App3 -->|Write| Primary
|
|
555
|
+
|
|
556
|
+
App1 -->|Read| Replica1
|
|
557
|
+
App2 -->|Read| Replica2
|
|
558
|
+
App3 -->|Read| Replica1
|
|
559
|
+
|
|
560
|
+
App1 -->|Cache| Cache
|
|
561
|
+
App2 -->|Cache| Cache
|
|
562
|
+
App3 -->|Cache| Cache
|
|
563
|
+
|
|
564
|
+
App1 -->|Async Jobs| Queue
|
|
565
|
+
App2 -->|Async Jobs| Queue
|
|
566
|
+
App3 -->|Async Jobs| Queue
|
|
567
|
+
|
|
568
|
+
Primary -.->|Replication| Replica1
|
|
569
|
+
Primary -.->|Replication| Replica2
|
|
570
|
+
|
|
571
|
+
style Internet fill:#e1f5ff
|
|
572
|
+
style Primary fill:#e1ffe1
|
|
573
|
+
style Cache fill:#f0e1ff
|
|
574
|
+
style Queue fill:#ffe1f5
|
|
575
|
+
```
|
|
576
|
+
````
|
|
577
|
+
|
|
578
|
+
**Use for:** Showing deployed infrastructure, scaling configuration, redundancy, high availability
|
|
579
|
+
|
|
580
|
+
---
|
|
581
|
+
|
|
582
|
+
##### 2️⃣ Data Flow Diagram (Request Flow)
|
|
583
|
+
|
|
584
|
+
Use `flowchart LR` to show how data moves through the system step-by-step:
|
|
585
|
+
|
|
586
|
+
````markdown
|
|
587
|
+
```mermaid
|
|
588
|
+
flowchart LR
|
|
589
|
+
User[User Request] -->|1. HTTPS POST| LB[Load Balancer]
|
|
590
|
+
LB -->|2. Route| API[API Server]
|
|
591
|
+
API -->|3. Validate JWT| Auth[Auth Service]
|
|
592
|
+
Auth -->|4. Token Valid| API
|
|
593
|
+
|
|
594
|
+
API -->|5. Check Cache| Cache[(Redis Cache)]
|
|
595
|
+
Cache -->|6. Cache Miss| API
|
|
596
|
+
|
|
597
|
+
API -->|7. Query| DB[(PostgreSQL)]
|
|
598
|
+
DB -->|8. Data| API
|
|
599
|
+
|
|
600
|
+
API -->|9. Store in Cache| Cache
|
|
601
|
+
API -->|10. Enqueue Job| Queue[Message Queue]
|
|
602
|
+
|
|
603
|
+
Queue -->|11. Process| Worker[Background Worker]
|
|
604
|
+
Worker -->|12. Send Email| Email[Email Service]
|
|
605
|
+
|
|
606
|
+
API -->|13. JSON Response| User
|
|
607
|
+
|
|
608
|
+
style User fill:#e1f5ff
|
|
609
|
+
style Cache fill:#f0e1ff
|
|
610
|
+
style DB fill:#e1ffe1
|
|
611
|
+
style Email fill:#fff4e1
|
|
612
|
+
```
|
|
613
|
+
````
|
|
614
|
+
|
|
615
|
+
**Use for:** Documenting request/response cycles, async processing flows, numbered execution steps
|
|
616
|
+
|
|
617
|
+
---
|
|
618
|
+
|
|
619
|
+
##### 3️⃣ Infrastructure Diagram (Cloud Resources)
|
|
620
|
+
|
|
621
|
+
Use `graph TB` with subgraphs to show cloud infrastructure and network topology:
|
|
622
|
+
|
|
623
|
+
````markdown
|
|
624
|
+
```mermaid
|
|
625
|
+
graph TB
|
|
626
|
+
subgraph "AWS Cloud - Production (us-east-1)"
|
|
627
|
+
subgraph "VPC (10.0.0.0/16)"
|
|
628
|
+
subgraph "Public Subnet (10.0.1.0/24)"
|
|
629
|
+
ALB[Application Load Balancer]
|
|
630
|
+
NAT[NAT Gateway]
|
|
631
|
+
end
|
|
632
|
+
|
|
633
|
+
subgraph "Private Subnet 1 (10.0.10.0/24)"
|
|
634
|
+
ECS1[ECS Cluster<br/>Auto Scaling Group]
|
|
635
|
+
App1[Container: API<br/>Fargate Task]
|
|
636
|
+
App2[Container: API<br/>Fargate Task]
|
|
637
|
+
end
|
|
638
|
+
|
|
639
|
+
subgraph "Private Subnet 2 (10.0.20.0/24)"
|
|
640
|
+
RDS[(RDS PostgreSQL<br/>Multi-AZ)]
|
|
641
|
+
ElastiCache[ElastiCache Redis<br/>Cluster Mode]
|
|
642
|
+
end
|
|
643
|
+
|
|
644
|
+
subgraph "Private Subnet 3 (10.0.30.0/24)"
|
|
645
|
+
SQS[Amazon SQS<br/>Message Queue]
|
|
646
|
+
Lambda[Lambda Functions<br/>Background Workers]
|
|
647
|
+
end
|
|
648
|
+
end
|
|
649
|
+
|
|
650
|
+
subgraph "Supporting Services"
|
|
651
|
+
S3[S3 Bucket<br/>File Storage]
|
|
652
|
+
CloudWatch[CloudWatch<br/>Monitoring & Logs]
|
|
653
|
+
SecretsManager[Secrets Manager<br/>API Keys & Credentials]
|
|
654
|
+
end
|
|
655
|
+
end
|
|
656
|
+
|
|
657
|
+
Internet[Internet Users] -->|HTTPS| ALB
|
|
658
|
+
ALB --> App1
|
|
659
|
+
ALB --> App2
|
|
660
|
+
|
|
661
|
+
App1 --> RDS
|
|
662
|
+
App2 --> RDS
|
|
663
|
+
App1 --> ElastiCache
|
|
664
|
+
App2 --> ElastiCache
|
|
665
|
+
|
|
666
|
+
App1 -->|Upload/Download| S3
|
|
667
|
+
App2 -->|Upload/Download| S3
|
|
668
|
+
|
|
669
|
+
App1 -->|Send Message| SQS
|
|
670
|
+
SQS -->|Trigger| Lambda
|
|
671
|
+
Lambda --> RDS
|
|
672
|
+
|
|
673
|
+
App1 -->|Logs & Metrics| CloudWatch
|
|
674
|
+
App2 -->|Logs & Metrics| CloudWatch
|
|
675
|
+
Lambda -->|Logs| CloudWatch
|
|
676
|
+
|
|
677
|
+
App1 -->|Fetch Secrets| SecretsManager
|
|
678
|
+
App2 -->|Fetch Secrets| SecretsManager
|
|
679
|
+
|
|
680
|
+
style Internet fill:#e1f5ff
|
|
681
|
+
style RDS fill:#e1ffe1
|
|
682
|
+
style ElastiCache fill:#f0e1ff
|
|
683
|
+
style S3 fill:#fff4e1
|
|
684
|
+
style CloudWatch fill:#ffe1e1
|
|
685
|
+
```
|
|
686
|
+
````
|
|
687
|
+
|
|
688
|
+
**Use for:** Documenting cloud architecture, network topology, AWS/GCP/Azure resources, VPC design
|
|
689
|
+
|
|
690
|
+
---
|
|
691
|
+
|
|
692
|
+
##### 4️⃣ Monitoring & Observability Diagram (Optional)
|
|
693
|
+
|
|
694
|
+
Use `graph TD` to show monitoring, logging, and alerting stack:
|
|
695
|
+
|
|
696
|
+
````markdown
|
|
697
|
+
```mermaid
|
|
698
|
+
graph TD
|
|
699
|
+
subgraph "Application Layer"
|
|
700
|
+
App[API Servers]
|
|
701
|
+
Worker[Background Workers]
|
|
702
|
+
end
|
|
703
|
+
|
|
704
|
+
subgraph "Monitoring Stack"
|
|
705
|
+
Prometheus[Prometheus<br/>Metrics Collection]
|
|
706
|
+
Grafana[Grafana<br/>Dashboards]
|
|
707
|
+
AlertManager[Alert Manager<br/>Notifications]
|
|
708
|
+
end
|
|
709
|
+
|
|
710
|
+
subgraph "Logging Stack"
|
|
711
|
+
FluentBit[Fluent Bit<br/>Log Collector]
|
|
712
|
+
Elasticsearch[Elasticsearch<br/>Log Storage]
|
|
713
|
+
Kibana[Kibana<br/>Log Viewer]
|
|
714
|
+
end
|
|
715
|
+
|
|
716
|
+
subgraph "Tracing"
|
|
717
|
+
Jaeger[Jaeger<br/>Distributed Tracing]
|
|
718
|
+
end
|
|
719
|
+
|
|
720
|
+
subgraph "Alerts"
|
|
721
|
+
PagerDuty[PagerDuty]
|
|
722
|
+
Slack[Slack Notifications]
|
|
723
|
+
end
|
|
724
|
+
|
|
725
|
+
App -->|Metrics| Prometheus
|
|
726
|
+
Worker -->|Metrics| Prometheus
|
|
727
|
+
Prometheus --> Grafana
|
|
728
|
+
Prometheus --> AlertManager
|
|
729
|
+
|
|
730
|
+
App -->|Logs| FluentBit
|
|
731
|
+
Worker -->|Logs| FluentBit
|
|
732
|
+
FluentBit --> Elasticsearch
|
|
733
|
+
Elasticsearch --> Kibana
|
|
734
|
+
|
|
735
|
+
App -->|Traces| Jaeger
|
|
736
|
+
Worker -->|Traces| Jaeger
|
|
737
|
+
|
|
738
|
+
AlertManager --> PagerDuty
|
|
739
|
+
AlertManager --> Slack
|
|
740
|
+
|
|
741
|
+
style Grafana fill:#e1f5ff
|
|
742
|
+
style Kibana fill:#f0e1ff
|
|
743
|
+
style PagerDuty fill:#ffe1e1
|
|
744
|
+
```
|
|
745
|
+
````
|
|
746
|
+
|
|
747
|
+
**Use for:** Documenting observability strategy, monitoring infrastructure, alerting workflows
|
|
748
|
+
|
|
749
|
+
---
|
|
750
|
+
|
|
751
|
+
**Best Practices for Operations Diagrams:**
|
|
752
|
+
|
|
753
|
+
1. **Include Resource Specs:** Add CPU/RAM/disk info to nodes (e.g., `[API Server<br/>4 vCPU, 8GB RAM]`)
|
|
754
|
+
2. **Show Redundancy:** Display load balancers, replicas, multi-AZ deployments, failover paths
|
|
755
|
+
3. **Label Network Boundaries:** Use subgraphs for VPCs, subnets, availability zones, regions
|
|
756
|
+
4. **Document Protocols:** Label connections with HTTPS, gRPC, TCP, WebSocket, etc.
|
|
757
|
+
5. **Add IP Ranges:** Include CIDR blocks for network subnets (e.g., `10.0.1.0/24`)
|
|
758
|
+
6. **Show Auto-Scaling:** Indicate which components scale horizontally/vertically
|
|
759
|
+
7. **Include External Services:** SaaS tools, third-party APIs, CDNs, email providers
|
|
760
|
+
8. **Color Code by Layer:** Infrastructure (blue), data (green), monitoring (purple), alerts (red)
|
|
761
|
+
|
|
762
|
+
**Common Formatting Rules:**
|
|
763
|
+
|
|
764
|
+
- Code fence: ` ```mermaid ` (lowercase, no spaces, three backticks)
|
|
765
|
+
- Use `subgraph "Name"` to group related components by layer/zone
|
|
766
|
+
- Use `[(Cylinder)]` for databases, data stores, and persistent storage
|
|
767
|
+
- Use `[Square Brackets]` for services, servers, and compute resources
|
|
768
|
+
- Use dotted arrows `-.->` for replication, backup, and async flows
|
|
769
|
+
- Apply consistent styling: `style NodeName fill:#colorcode`
|
|
770
|
+
|
|
771
|
+
**Deployment Context Examples:**
|
|
772
|
+
|
|
773
|
+
- For Docker: Show containers, volumes, networks, registries
|
|
774
|
+
- For Kubernetes: Show pods, services, ingress, namespaces, persistent volumes
|
|
775
|
+
- For Serverless: Show Lambda functions, API Gateway, S3 triggers, event sources
|
|
776
|
+
- For VMs: Show instances, security groups, load balancers, auto-scaling groups
|
|
777
|
+
|
|
778
|
+
**Validation:** Test diagrams at https://mermaid.live/ before saving to ensure syntax is correct
|
|
779
|
+
|
|
780
|
+
---
|
|
781
|
+
|
|
782
|
+
### Phase 7 Output
|
|
783
|
+
|
|
784
|
+
```
|
|
785
|
+
📋 PHASE 7 SUMMARY:
|
|
786
|
+
|
|
787
|
+
Deployment Environment: [cloud/PaaS/on-premises/container-orchestration + platform choice + rationale] (7.1)
|
|
788
|
+
Containerization: [yes/no + Docker setup (base image, size, compose stack)] (7.2)
|
|
789
|
+
Environments: [number of environments (dev/staging/prod) + config approach (env vars/secrets/feature flags)] (7.3)
|
|
790
|
+
CI/CD Pipeline: [platform (GitHub Actions/GitLab CI/etc.) + pipeline stages + auto-deploy strategy] (7.4)
|
|
791
|
+
Deployment Strategy: [standard/blue-green/canary/rolling + zero-downtime approach + rollback plan] (7.4.1)
|
|
792
|
+
Monitoring & Logging: [APM tool + logging strategy (centralized/structured JSON) + metrics to track] (7.5)
|
|
793
|
+
Alerts: [alert conditions (error rate/response time/5xx/etc.) + channels (email/Slack/PagerDuty) + on-call rotation] (7.6)
|
|
794
|
+
Backup & Disaster Recovery: [backup strategy + retention period + RTO/RPO targets] (7.7)
|
|
795
|
+
Database Migrations in Production: [zero-downtime strategy + rollback plan + migration windows] (7.7.1)
|
|
796
|
+
Database Connection Pooling: [pool tool + settings (min/max/timeouts) + monitoring] (7.7.2)
|
|
797
|
+
Scaling Strategy: [horizontal/vertical/auto-scaling + expected load + database scaling approach] (7.8)
|
|
798
|
+
Health Checks: [endpoints (/health, /health/ready, /health/live) + checks performed] (7.9)
|
|
799
|
+
Graceful Shutdown: [yes/no + shutdown sequence + timeouts] (7.9.1)
|
|
800
|
+
Circuit Breakers & Resilience: [yes/no + tool + configuration + fallback strategies] (7.9.2)
|
|
801
|
+
Documentation & Runbooks: [what will be created (deployment guide/runbooks/architecture diagrams in mermaid format/API docs) + API doc strategy (code-first/design-first)] (7.10)
|
|
802
|
+
|
|
803
|
+
Is this correct? (Yes/No)
|
|
804
|
+
```
|
|
805
|
+
|
|
806
|
+
---
|
|
807
|
+
|
|
808
|
+
### 📄 Generate Phase 7 Documents
|
|
809
|
+
|
|
810
|
+
**Before starting generation:**
|
|
811
|
+
|
|
812
|
+
```
|
|
813
|
+
📖 Loading context from previous phases...
|
|
814
|
+
✅ Re-reading docs/testing.md
|
|
815
|
+
✅ Re-reading ai-instructions.md
|
|
816
|
+
```
|
|
817
|
+
|
|
818
|
+
Once confirmed, generate:
|
|
819
|
+
|
|
820
|
+
**1. `docs/operations.md`**
|
|
821
|
+
|
|
822
|
+
- Use template: `.ai-flow/templates/docs/operations.template.md`
|
|
823
|
+
- Fill with deployment, monitoring, alerting, backup, scaling
|
|
824
|
+
|
|
825
|
+
**2. `specs/configuration.md`**
|
|
826
|
+
|
|
827
|
+
- Use template: `.ai-flow/templates/specs/configuration.template.md`
|
|
828
|
+
- Fill with environment variables, secrets management, feature flags
|
|
829
|
+
|
|
830
|
+
**3. `.env.example`**
|
|
831
|
+
|
|
832
|
+
- List all environment variables needed
|
|
833
|
+
- Include comments explaining each variable
|
|
834
|
+
|
|
835
|
+
```
|
|
836
|
+
✅ Generated: docs/operations.md
|
|
837
|
+
✅ Generated: specs/configuration.md
|
|
838
|
+
✅ Generated: .env.example
|
|
839
|
+
|
|
840
|
+
📝 Please review these documents. Do you need to make any corrections?
|
|
841
|
+
|
|
842
|
+
A) ✅ Look perfect, continue to final checkpoint
|
|
843
|
+
B) 📝 I'll edit them now (I'll wait)
|
|
844
|
+
C) 🔄 Regenerate with changes (tell me what to modify)
|
|
845
|
+
```
|
|
846
|
+
|
|
847
|
+
**If user selects B:**
|
|
848
|
+
|
|
849
|
+
```
|
|
850
|
+
Perfect. Please edit the documents and type "ready" when you're done.
|
|
851
|
+
I'll re-read all files to update my context before continuing.
|
|
852
|
+
```
|
|
853
|
+
|
|
854
|
+
---
|
|
855
|
+
|
|
856
|
+
**Proceed to final generation only after documents are validated.**
|
|
857
|
+
|
|
858
|
+
---
|
|
859
|
+
|
|
860
|
+
## FINAL STEP: Generate Remaining Documents & Tool Configs
|
|
861
|
+
|
|
862
|
+
### ⏸️ CHECKPOINT: Final Document Review
|
|
863
|
+
|
|
864
|
+
```
|
|
865
|
+
⏸️ CHECKPOINT: Review Generated Documents
|
|
866
|
+
|
|
867
|
+
We have successfully generated the following documents across all phases:
|
|
868
|
+
|
|
869
|
+
✅ project-brief.md (Phase 1)
|
|
870
|
+
✅ docs/data-model.md (Phase 2)
|
|
871
|
+
✅ docs/architecture.md (Phase 3)
|
|
872
|
+
✅ ai-instructions.md (Phase 3)
|
|
873
|
+
✅ specs/security.md (Phase 4)
|
|
874
|
+
✅ docs/code-standards.md (Phase 5)
|
|
875
|
+
✅ docs/testing.md (Phase 6)
|
|
876
|
+
✅ docs/operations.md (Phase 7)
|
|
877
|
+
✅ specs/configuration.md (Phase 7)
|
|
878
|
+
✅ .env.example (Phase 7)
|
|
879
|
+
|
|
880
|
+
Before generating the final documents (AGENT.md, README.md, API docs, etc.),
|
|
881
|
+
do you want to review or edit any of these documents?
|
|
882
|
+
|
|
883
|
+
A) ✅ All documents are correct, proceed with final generation
|
|
884
|
+
B) 📝 I need to review/edit some documents (I'll wait)
|
|
885
|
+
```
|
|
886
|
+
|
|
887
|
+
**If user selects B:**
|
|
888
|
+
|
|
889
|
+
```
|
|
890
|
+
Perfect. Please review and edit any documents you need to change.
|
|
891
|
+
When you're done, type "ready" and I'll re-read ALL documents
|
|
892
|
+
to ensure the final generation uses the most up-to-date information.
|
|
893
|
+
```
|
|
894
|
+
|
|
895
|
+
Then execute `read_file()` for ALL previously generated documents.
|
|
896
|
+
|
|
897
|
+
---
|
|
898
|
+
|
|
899
|
+
### 📖 Loading Complete Context for Final Generation
|
|
900
|
+
|
|
901
|
+
```
|
|
902
|
+
📖 Re-reading all generated documents to ensure accuracy...
|
|
903
|
+
|
|
904
|
+
✅ Re-reading project-brief.md
|
|
905
|
+
✅ Re-reading docs/data-model.md
|
|
906
|
+
✅ Re-reading docs/architecture.md
|
|
907
|
+
✅ Re-reading ai-instructions.md
|
|
908
|
+
✅ Re-reading specs/security.md
|
|
909
|
+
✅ Re-reading docs/code-standards.md
|
|
910
|
+
✅ Re-reading docs/testing.md
|
|
911
|
+
✅ Re-reading docs/operations.md
|
|
912
|
+
✅ Re-reading specs/configuration.md
|
|
913
|
+
✅ Re-reading .env.example
|
|
914
|
+
|
|
915
|
+
✅ Context fully loaded and updated!
|
|
916
|
+
|
|
917
|
+
🎉 Now generating final 5 documents:
|
|
918
|
+
|
|
919
|
+
1. docs/business-flows.md - Business process flows and mermaid diagrams
|
|
920
|
+
2. docs/api.md - API endpoints and conventions reference
|
|
921
|
+
3. docs/contributing.md - Contribution guidelines
|
|
922
|
+
4. README.md - Project overview (requires all previous context)
|
|
923
|
+
5. AGENT.md - Universal AI configuration (aggregates all docs)
|
|
924
|
+
|
|
925
|
+
Plus tool-specific configurations:
|
|
926
|
+
- .clauderules (if Claude selected)
|
|
927
|
+
- .cursorrules (if Cursor selected)
|
|
928
|
+
- .github/copilot-instructions.md (if Copilot selected)
|
|
929
|
+
|
|
930
|
+
Generating...
|
|
931
|
+
```
|
|
932
|
+
|
|
933
|
+
### Generation Instructions for Final Documents
|
|
934
|
+
|
|
935
|
+
For EACH final document:
|
|
936
|
+
|
|
937
|
+
**1. `docs/business-flows.md`**
|
|
938
|
+
|
|
939
|
+
- Use template: `.ai-flow/templates/docs/business-flows.template.md`
|
|
940
|
+
- Fill with business flows from Phase 1
|
|
941
|
+
- Generate mermaid diagrams for each flow
|
|
942
|
+
|
|
943
|
+
**2. `docs/api.md`**
|
|
944
|
+
|
|
945
|
+
- Use template: `.ai-flow/templates/docs/api.template.md`
|
|
946
|
+
- Auto-generate CRUD endpoints for each entity from Phase 2
|
|
947
|
+
- Apply API conventions from Phase 3 (question 3.5)
|
|
948
|
+
- Include authentication, pagination, error formats
|
|
949
|
+
|
|
950
|
+
**3. `docs/contributing.md`**
|
|
951
|
+
|
|
952
|
+
- Use template: `.ai-flow/templates/docs/contributing.template.md`
|
|
953
|
+
- Fill with git workflow, commit format from Phase 5
|
|
954
|
+
- Include setup instructions from Phase 3 & 7
|
|
955
|
+
|
|
956
|
+
**4. `README.md`**
|
|
957
|
+
|
|
958
|
+
- Use template: `.ai-flow/templates/README.template.md`
|
|
959
|
+
- **CRITICAL:** This aggregates info from ALL phases
|
|
960
|
+
- Re-read ALL previously generated docs before filling
|
|
961
|
+
- Include quick start, tech stack, deployment info
|
|
962
|
+
|
|
963
|
+
**5. `AGENT.md`**
|
|
964
|
+
|
|
965
|
+
- Use template: `.ai-flow/templates/AGENT.template.md`
|
|
966
|
+
- **CRITICAL:** This is the master index
|
|
967
|
+
- Lists ALL 15 documents with descriptions
|
|
968
|
+
- Includes quick reference to tech stack and critical rules
|
|
969
|
+
- Re-read ALL previously generated docs to ensure accuracy
|
|
970
|
+
|
|
971
|
+
### Special Documents
|
|
972
|
+
|
|
973
|
+
**AGENT.md**: Acts as aggregator
|
|
974
|
+
|
|
975
|
+
- Links to other documents
|
|
976
|
+
- Provides quick reference
|
|
977
|
+
- Auto-generated summary of stack and rules
|
|
978
|
+
|
|
979
|
+
**Tool-specific configs**:
|
|
980
|
+
If AI tool selected was:
|
|
981
|
+
|
|
982
|
+
- Claude → Create `.clauderules` (references AGENT.md)
|
|
983
|
+
- Cursor → Create `.cursorrules` (references AGENT.md)
|
|
984
|
+
- Copilot → Create `.github/copilot-instructions.md` (references AGENT.md)
|
|
985
|
+
- All → Create all three
|
|
986
|
+
|
|
987
|
+
**Framework initialization**:
|
|
988
|
+
If user wants framework initialized:
|
|
989
|
+
|
|
990
|
+
```bash
|
|
991
|
+
# Example for NestJS
|
|
992
|
+
nest new . --skip-git --package-manager npm
|
|
993
|
+
|
|
994
|
+
# Example for FastAPI
|
|
995
|
+
# Create main.py, requirements.txt, etc.
|
|
996
|
+
```
|
|
997
|
+
|
|
998
|
+
### Success Message
|
|
999
|
+
|
|
1000
|
+
```
|
|
1001
|
+
✅ AI Flow Complete!
|
|
1002
|
+
|
|
1003
|
+
Generated 15 documents successfully:
|
|
1004
|
+
|
|
1005
|
+
Phase 1:
|
|
1006
|
+
✅ project-brief.md
|
|
1007
|
+
|
|
1008
|
+
Phase 2:
|
|
1009
|
+
✅ docs/data-model.md
|
|
1010
|
+
|
|
1011
|
+
Phase 3:
|
|
1012
|
+
✅ docs/architecture.md
|
|
1013
|
+
✅ ai-instructions.md
|
|
1014
|
+
|
|
1015
|
+
Phase 4:
|
|
1016
|
+
✅ specs/security.md
|
|
1017
|
+
|
|
1018
|
+
Phase 5:
|
|
1019
|
+
✅ docs/code-standards.md
|
|
1020
|
+
|
|
1021
|
+
Phase 6:
|
|
1022
|
+
✅ docs/testing.md
|
|
1023
|
+
|
|
1024
|
+
Phase 7:
|
|
1025
|
+
✅ docs/operations.md
|
|
1026
|
+
✅ specs/configuration.md
|
|
1027
|
+
✅ .env.example
|
|
1028
|
+
|
|
1029
|
+
Final Generation:
|
|
1030
|
+
✅ docs/business-flows.md
|
|
1031
|
+
✅ docs/api.md
|
|
1032
|
+
✅ docs/contributing.md
|
|
1033
|
+
✅ README.md
|
|
1034
|
+
✅ AGENT.md
|
|
1035
|
+
|
|
1036
|
+
Tool-specific configs:
|
|
1037
|
+
✅ [Selected tool configs generated]
|
|
1038
|
+
|
|
1039
|
+
Next steps:
|
|
1040
|
+
1. Review all generated documents
|
|
1041
|
+
2. Customize as needed for your specific project
|
|
1042
|
+
3. Initialize git repository (if not already done)
|
|
1043
|
+
4. Set up environment variables (.env file from .env.example)
|
|
1044
|
+
5. Install dependencies
|
|
1045
|
+
6. Start building! 🚀
|
|
1046
|
+
7. Start building! 🚀
|
|
1047
|
+
|
|
1048
|
+
---
|
|
1049
|
+
|
|
1050
|
+
💡 Remember:
|
|
1051
|
+
- Update documents as project evolves
|
|
1052
|
+
- Documents are living artifacts, not set-in-stone
|
|
1053
|
+
- AI assistants will reference these docs for all future work
|
|
1054
|
+
|
|
1055
|
+
Happy building! 🎉
|
|
1056
|
+
```
|
|
1057
|
+
|
|
1058
|
+
---
|
|
1059
|
+
|
|
1060
|
+
## EXECUTION CHECKLIST FOR AI ASSISTANT
|
|
1061
|
+
|
|
1062
|
+
When executing this master prompt:
|
|
1063
|
+
|
|
1064
|
+
**PHASE 0 (Existing Projects Only):**
|
|
1065
|
+
|
|
1066
|
+
- [ ] Check if project has existing code/documentation
|
|
1067
|
+
- [ ] Search for AI instruction files (copilot-instructions.md, .clauderules, .cursorrules, AGENT.md, etc.)
|
|
1068
|
+
- [ ] Search for README.md, package.json, and config files
|
|
1069
|
+
- [ ] **Perform deep code analysis:**
|
|
1070
|
+
- [ ] Recursively scan source directories (src/, app/, lib/, modules/)
|
|
1071
|
+
- [ ] Count files by type (controllers, services, entities, DTOs, etc.)
|
|
1072
|
+
- [ ] Identify architecture pattern (feature-based, layer-based, modular, hybrid)
|
|
1073
|
+
- [ ] **Parse source code files for AST-based analysis:**
|
|
1074
|
+
- [ ] Detect decorators (@Controller, @Get, @Post for NestJS; @app.get() for FastAPI)
|
|
1075
|
+
- [ ] Extract API endpoints (method, path, parameters, middleware)
|
|
1076
|
+
- [ ] Identify services and dependency injection patterns
|
|
1077
|
+
- [ ] Detect error handling patterns
|
|
1078
|
+
- [ ] **Analyze database schemas:**
|
|
1079
|
+
- [ ] Parse Prisma schema.prisma (models, relationships, indexes)
|
|
1080
|
+
- [ ] Parse TypeORM entities (@Entity, @Column, relationships)
|
|
1081
|
+
- [ ] Parse SQLAlchemy models
|
|
1082
|
+
- [ ] Extract complete entity definitions with fields and relationships
|
|
1083
|
+
- [ ] **Analyze dependencies:**
|
|
1084
|
+
- [ ] Extract exact versions from package.json/requirements.txt/etc.
|
|
1085
|
+
- [ ] Identify framework, ORM, validation, auth, testing libraries
|
|
1086
|
+
- [ ] Detect security-related packages
|
|
1087
|
+
- [ ] **Detect code patterns:**
|
|
1088
|
+
- [ ] Dependency injection usage
|
|
1089
|
+
- [ ] Error handling implementation
|
|
1090
|
+
- [ ] Validation patterns (DTOs, schemas)
|
|
1091
|
+
- [ ] Logging setup
|
|
1092
|
+
- [ ] Testing configuration
|
|
1093
|
+
- [ ] Caching strategies
|
|
1094
|
+
- [ ] Background job systems
|
|
1095
|
+
- [ ] Present detailed detection results (0.2) including:
|
|
1096
|
+
- [ ] Architecture pattern detected
|
|
1097
|
+
- [ ] Complete list of API endpoints with details
|
|
1098
|
+
- [ ] All entities with schemas and relationships
|
|
1099
|
+
- [ ] Dependencies with versions
|
|
1100
|
+
- [ ] Code quality indicators
|
|
1101
|
+
- [ ] **Generate proactive suggestions (0.2.1):**
|
|
1102
|
+
- [ ] Analyze code for security gaps (validation, rate limiting, CORS, etc.)
|
|
1103
|
+
- [ ] Identify architecture improvements
|
|
1104
|
+
- [ ] Detect documentation gaps
|
|
1105
|
+
- [ ] Suggest testing improvements
|
|
1106
|
+
- [ ] Recommend performance optimizations
|
|
1107
|
+
- [ ] Present suggestions with actions and impacts
|
|
1108
|
+
- [ ] **Offer export option (0.3):**
|
|
1109
|
+
- [ ] Ask if user wants to export analysis to JSON
|
|
1110
|
+
- [ ] If yes, create .ai-flow/analysis.json with complete analysis
|
|
1111
|
+
- [ ] Let user choose: A) Use detected info, B) Start fresh, C) Review/edit detected info
|
|
1112
|
+
- [ ] **Handle suggestions:**
|
|
1113
|
+
- [ ] If user selected A (address during bootstrap), integrate suggestions into relevant phases
|
|
1114
|
+
- [ ] If user selected B (save for later), create suggestions.md file
|
|
1115
|
+
- [ ] If user selected C (skip), continue without changes
|
|
1116
|
+
- [ ] Pre-populate answers based on detected information
|
|
1117
|
+
- [ ] Mark questions that still need answers
|
|
1118
|
+
|
|
1119
|
+
**PHASES 1-7 (All Projects):**
|
|
1120
|
+
|
|
1121
|
+
- [ ] Execute phases 1-7 in exact order
|
|
1122
|
+
- [ ] **SKIP questions already answered** from Phase 0 detection (existing projects)
|
|
1123
|
+
- [ ] Ask remaining questions ONE BY ONE (wait for answer)
|
|
1124
|
+
- [ ] Wait for user response before proceeding
|
|
1125
|
+
- [ ] Provide recommendations (⭐🔥⚡🏆)
|
|
1126
|
+
- [ ] Offer multiple choice where applicable
|
|
1127
|
+
- [ ] Summarize each phase for confirmation
|
|
1128
|
+
- [ ] Collect ALL required information
|
|
1129
|
+
- [ ] Generate documents **incrementally** after each phase
|
|
1130
|
+
- [ ] Ask for user validation after each document generation
|
|
1131
|
+
- [ ] Re-read generated documents at start of each new phase
|
|
1132
|
+
- [ ] Perform final checkpoint before generating AGENT.md and README.md
|
|
1133
|
+
- [ ] Re-read ALL documents before final generation to ensure accuracy
|
|
1134
|
+
- [ ] Use templates from `.ai-flow/templates/`
|
|
1135
|
+
- [ ] Create tool-specific configs based on AI selection
|
|
1136
|
+
- [ ] Validate no placeholders remain
|
|
1137
|
+
- [ ] Provide clear next steps
|
|
1138
|
+
|
|
1139
|
+
**DO NOT:**
|
|
1140
|
+
|
|
1141
|
+
- ❌ Skip Phase 0 detection for existing projects
|
|
1142
|
+
- ❌ Skip deep code analysis - always perform comprehensive AST-based parsing when code exists
|
|
1143
|
+
- ❌ Present superficial analysis - include detailed endpoints, entities, and patterns
|
|
1144
|
+
- ❌ Ignore proactive suggestions - always generate and present improvement opportunities
|
|
1145
|
+
- ❌ Ask questions already answered by detected files or code analysis
|
|
1146
|
+
- ❌ Ignore existing AI instruction files
|
|
1147
|
+
- ❌ Skip questions or phases
|
|
1148
|
+
- ❌ Assume answers without asking (when info is not detected)
|
|
1149
|
+
- ❌ Generate ALL documents at the end (generate incrementally!)
|
|
1150
|
+
- ❌ Skip document validation after generation
|
|
1151
|
+
- ❌ Forget to re-read documents before using their info
|
|
1152
|
+
- ❌ Generate final documents without re-reading all previous docs
|
|
1153
|
+
- ❌ Leave placeholder text in final documents
|
|
1154
|
+
- ❌ Skip exporting analysis JSON if user requested it
|
|
1155
|
+
- ❌ Rush through the analysis - thoroughness saves time later
|
|
1156
|
+
|
|
1157
|
+
**ESTIMATED TIME:**
|
|
1158
|
+
|
|
1159
|
+
**New Projects:**
|
|
1160
|
+
|
|
1161
|
+
- Phase 1: 15-20 min
|
|
1162
|
+
- Phase 2: 15-20 min
|
|
1163
|
+
- Phase 3: 15-20 min
|
|
1164
|
+
- Phase 4: 15-20 min
|
|
1165
|
+
- Phase 5: 15-20 min
|
|
1166
|
+
- Phase 6: 10 min
|
|
1167
|
+
- Phase 7: 10 min
|
|
1168
|
+
- **Total: 90-120 minutes**
|
|
1169
|
+
|
|
1170
|
+
**Existing Projects (with Phase 0 detection):**
|
|
1171
|
+
|
|
1172
|
+
- Phase 0: 10-20 min (deep code analysis + suggestions + review)
|
|
1173
|
+
- File detection: 2-3 min
|
|
1174
|
+
- Deep code analysis (AST parsing, schema extraction): 5-10 min
|
|
1175
|
+
- Generating suggestions: 2-3 min
|
|
1176
|
+
- User review and export: 1-4 min
|
|
1177
|
+
- Phases 1-7: 30-60 min (only missing questions)
|
|
1178
|
+
- **Total: 40-80 minutes** (40-60% time saved!)
|
|
1179
|
+
|
|
1180
|
+
This is an investment that will save 10-20 hours over the project lifecycle.
|
|
1181
|
+
|
|
1182
|
+
---
|
|
1183
|
+
|
|
1184
|
+
**EXECUTION FLOW:**
|
|
1185
|
+
|
|
1186
|
+
1. **START:** User runs `/flow-docs-gen`
|
|
1187
|
+
2. **DETECT:** Check for existing project files (Phase 0)
|
|
1188
|
+
- If existing files found → Run Phase 0 deep analysis:
|
|
1189
|
+
- 0.1: Deep Code Analysis (file structure, AST parsing, schema extraction, pattern detection)
|
|
1190
|
+
- 0.2: Present Detailed Detection Results (architecture, endpoints, entities, dependencies, code quality)
|
|
1191
|
+
- 0.2.1: Generate Proactive Suggestions (security, architecture, documentation, testing, performance)
|
|
1192
|
+
- 0.3: Export Analysis Results (optional JSON export)
|
|
1193
|
+
- 0.4: Load Existing Context (pre-populate answers)
|
|
1194
|
+
- If no files found → Skip to Phase 1
|
|
1195
|
+
3. **EXECUTE:** Run Phases 1-7 with pre-populated answers (if any)
|
|
1196
|
+
- Integrate suggestions from Phase 0 into relevant phases if user selected option A
|
|
1197
|
+
4. **GENERATE:** Create documents incrementally with validation
|
|
1198
|
+
5. **COMPLETE:** Final checkpoint and remaining documents
|
|
1199
|
+
|
|
1200
|
+
---
|
|
1201
|
+
|
|
1202
|
+
**BEGIN EXECUTION when user runs `/flow-docs-gen`**
|
|
1203
|
+
|
|
1204
|
+
```
|
|
1205
|
+
|
|
1206
|
+
```
|
|
1207
|
+
|