@enki-dev-expert/global-engineering-standards 0.0.0-stage → 0.1.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 (51) hide show
  1. package/AGENTS.md +303 -0
  2. package/CHANGELOG.md +28 -0
  3. package/CITATION.cff +21 -0
  4. package/CODE_OF_CONDUCT.md +13 -0
  5. package/CONTRIBUTING.md +27 -0
  6. package/LICENSE +21 -0
  7. package/README.md +159 -2
  8. package/SECURITY.md +25 -0
  9. package/dist/cli.js +40 -0
  10. package/dist/content.js +71 -0
  11. package/dist/filesystem.js +83 -0
  12. package/dist/installer.js +243 -0
  13. package/dist/layout.js +42 -0
  14. package/dist/transaction.js +143 -0
  15. package/docs/ai-and-llm.md +1312 -0
  16. package/docs/architecture.md +1007 -0
  17. package/docs/cost-engineering.md +1322 -0
  18. package/docs/data.md +993 -0
  19. package/docs/governance.md +1744 -0
  20. package/docs/mobile-and-web.md +1362 -0
  21. package/docs/observability.md +1345 -0
  22. package/docs/platforms-and-applications.md +1581 -0
  23. package/docs/privacy.md +566 -0
  24. package/docs/quality-and-testing.md +1278 -0
  25. package/docs/scalability.md +1012 -0
  26. package/docs/security.md +373 -0
  27. package/handbook/claude-plugin.md +31 -0
  28. package/handbook/compatibility.md +27 -0
  29. package/handbook/recovery.md +29 -0
  30. package/handbook/releasing.md +50 -0
  31. package/handbook/security-review.md +41 -0
  32. package/handbook/signing.md +18 -0
  33. package/handbook/validation.md +50 -0
  34. package/package.json +65 -4
  35. package/scripts/content-baseline.json +25 -0
  36. package/skills/engineering-architecture-review/SKILL.md +1531 -0
  37. package/skills/engineering-cost-estimate/SKILL.md +1599 -0
  38. package/skills/engineering-database-review/SKILL.md +1364 -0
  39. package/skills/engineering-privacy-check/SKILL.md +1295 -0
  40. package/skills/engineering-safe-implementation/SKILL.md +1502 -0
  41. package/skills/engineering-security-standards-check/SKILL.md +1112 -0
  42. package/src/cli.ts +45 -0
  43. package/src/content.ts +82 -0
  44. package/src/filesystem.ts +94 -0
  45. package/src/installer.ts +280 -0
  46. package/src/layout.ts +70 -0
  47. package/src/transaction.ts +167 -0
  48. package/templates/ADR.md +1302 -0
  49. package/templates/AUDIT_REPORT.md +1693 -0
  50. package/templates/EXCEPTIONS.md +647 -0
  51. package/templates/PROJECT_AGENTS.md +868 -0
@@ -0,0 +1,1322 @@
1
+
2
+ # Global Cost Engineering and FinOps Standards
3
+
4
+ ## 1. Mission
5
+
6
+ Design, develop, deploy and operate secure, scalable, reliable and financially sustainable software systems.
7
+
8
+ These standards define mandatory cost-awareness requirements for Claude Code, OpenAI Codex and other AI-assisted engineering workflows.
9
+
10
+ They apply to:
11
+
12
+ - New applications.
13
+ - Existing production applications.
14
+ - Web applications.
15
+ - iOS and Android applications.
16
+ - SaaS platforms.
17
+ - Backend APIs.
18
+ - AI-powered systems.
19
+ - Database infrastructure.
20
+ - Cloud infrastructure.
21
+ - Kubernetes.
22
+ - Serverless platforms.
23
+ - Third-party services.
24
+ - Enterprise integrations.
25
+
26
+ The objective is to support millions of users without unnecessary spending, unexpected infrastructure costs or avoidable vendor dependence.
27
+
28
+ Cost optimization must never compromise security, privacy, correctness, data integrity or required reliability.
29
+
30
+ ## 2. Fundamental Principles
31
+
32
+ Follow these principles:
33
+
34
+ 1. Design for future scalability.
35
+ 2. Provision infrastructure for current demand.
36
+ 3. Measure before optimizing.
37
+ 4. Prefer the simplest suitable architecture.
38
+ 5. Understand the complete cost of each dependency.
39
+ 6. Estimate costs before significant changes.
40
+ 7. Monitor costs after deployment.
41
+ 8. Prevent unbounded consumption.
42
+ 9. Reduce waste without sacrificing quality.
43
+ 10. Preserve production stability.
44
+ 11. Verify actual provider pricing.
45
+ 12. Require approval for significant financial commitments.
46
+
47
+ Never assume that a managed service, serverless platform or cloud provider is automatically cheaper.
48
+
49
+ Never recommend infrastructure solely because it is fashionable or technically sophisticated.
50
+
51
+ ## 3. Provider Neutrality
52
+
53
+ These standards are cloud-agnostic, database-agnostic and vendor-neutral.
54
+
55
+ No infrastructure provider is mandatory by default.
56
+
57
+ Support cost analysis for:
58
+
59
+ ### Amazon Web Services
60
+
61
+ Including relevant services such as:
62
+
63
+ - EC2.
64
+ - ECS.
65
+ - EKS.
66
+ - Lambda.
67
+ - RDS.
68
+ - Aurora.
69
+ - DynamoDB.
70
+ - S3.
71
+ - CloudFront.
72
+ - CloudWatch.
73
+ - Load balancers.
74
+ - Networking and data transfer.
75
+
76
+ ### Microsoft Azure
77
+
78
+ Including relevant services such as:
79
+
80
+ - Azure Virtual Machines.
81
+ - Azure App Service.
82
+ - Azure Functions.
83
+ - Azure Kubernetes Service.
84
+ - Azure SQL.
85
+ - Cosmos DB.
86
+ - Azure Storage.
87
+ - Azure Front Door.
88
+ - Azure Monitor.
89
+ - Networking and data transfer.
90
+
91
+ ### Google Cloud Platform
92
+
93
+ Including relevant services such as:
94
+
95
+ - Compute Engine.
96
+ - Cloud Run.
97
+ - Google Kubernetes Engine.
98
+ - Cloud SQL.
99
+ - AlloyDB.
100
+ - Firestore.
101
+ - BigQuery.
102
+ - Cloud Storage.
103
+ - Cloud CDN.
104
+ - Cloud Monitoring.
105
+ - Networking and data transfer.
106
+
107
+ ### Other Providers
108
+
109
+ Including:
110
+
111
+ - Supabase.
112
+ - Firebase.
113
+ - Vercel.
114
+ - Netlify.
115
+ - Cloudflare.
116
+ - DigitalOcean.
117
+ - Render.
118
+ - Railway.
119
+ - Fly.io.
120
+ - Neon.
121
+ - MongoDB Atlas.
122
+ - PlanetScale.
123
+ - Managed AI providers.
124
+ - Self-hosted systems.
125
+ - Hybrid infrastructure.
126
+ - On-premises environments.
127
+
128
+ These are examples, not mandatory technologies.
129
+
130
+ Use the existing project's provider unless there is a justified reason to consider alternatives.
131
+
132
+ Never recommend a migration solely on the basis of an incomplete price comparison.
133
+
134
+ ## 4. Complete Cost Ownership
135
+
136
+ Evaluate the total cost of ownership (TCO).
137
+
138
+ Include:
139
+
140
+ - Compute.
141
+ - Databases.
142
+ - Storage.
143
+ - Network traffic.
144
+ - CDN.
145
+ - Load balancing.
146
+ - Managed services.
147
+ - Authentication.
148
+ - Email.
149
+ - SMS.
150
+ - Push notifications.
151
+ - Third-party APIs.
152
+ - AI inference.
153
+ - Embeddings.
154
+ - Vector storage.
155
+ - Background processing.
156
+ - Monitoring.
157
+ - Logs.
158
+ - Backups.
159
+ - Disaster recovery.
160
+ - Security services.
161
+ - Deployment infrastructure.
162
+ - Maintenance.
163
+ - Operational labor.
164
+ - Support.
165
+ - Migration costs.
166
+
167
+ Distinguish recurring costs from one-time costs.
168
+
169
+ Document costs not yet measurable.
170
+
171
+ Never present an incomplete infrastructure estimate as total operating cost.
172
+
173
+ ## 5. Cost Classification
174
+
175
+ Classify costs as appropriate:
176
+
177
+ - Fixed.
178
+ - Variable.
179
+ - Usage-based.
180
+ - Per-request.
181
+ - Per-user.
182
+ - Per-seat.
183
+ - Per-transaction.
184
+ - Per-token.
185
+ - Per-message.
186
+ - Per-connection.
187
+ - Per-gigabyte.
188
+ - Per-operation.
189
+ - Per-compute-hour.
190
+ - Per-resource-hour.
191
+ - Subscription-based.
192
+ - Reserved capacity.
193
+ - One-time migration.
194
+ - Operational maintenance.
195
+
196
+ Understand minimum charges, billing increments and contractual commitments.
197
+
198
+ Identify costs that increase with traffic, storage, concurrency or feature adoption.
199
+
200
+ ## 6. Pricing Verification
201
+
202
+ Before presenting significant cost recommendations:
203
+
204
+ 1. Identify the exact provider.
205
+ 2. Identify the actual service and plan.
206
+ 3. Identify the relevant billing region.
207
+ 4. Review current official pricing.
208
+ 5. Identify included quotas.
209
+ 6. Identify overage charges.
210
+ 7. Check billing units.
211
+ 8. Review applicable discounts or commitments.
212
+ 9. Identify additional dependencies.
213
+ 10. Document assumptions and verification dates.
214
+
215
+ Never fabricate current prices.
216
+
217
+ Never assume historical pricing remains valid.
218
+
219
+ Clearly distinguish:
220
+
221
+ - Verified prices.
222
+ - Estimated prices.
223
+ - Hypothetical scenarios.
224
+ - Unknown costs.
225
+
226
+ If current pricing cannot be verified, explain the limitation.
227
+
228
+ ## 7. Cost Estimation Before Implementation
229
+
230
+ For changes with meaningful cost implications, provide an estimate before implementation.
231
+
232
+ Examples:
233
+
234
+ - Adding AI inference.
235
+ - Introducing video processing.
236
+ - Creating new databases.
237
+ - Introducing realtime messaging.
238
+ - Changing hosting platforms.
239
+ - Adding managed Kubernetes.
240
+ - Enabling expensive monitoring.
241
+ - Adding external APIs.
242
+ - Increasing storage retention.
243
+ - Deploying cross-region infrastructure.
244
+
245
+ Identify expected usage and cost drivers.
246
+
247
+ Present an estimated monthly cost range when supported by sufficient information.
248
+
249
+ Do not invent a precise amount when workload assumptions are uncertain.
250
+
251
+ Require explicit approval before creating significant recurring charges.
252
+
253
+ ## 8. Cost Forecasting
254
+
255
+ Evaluate meaningful growth scenarios.
256
+
257
+ Examples:
258
+
259
+ - 1,000 active users.
260
+ - 10,000 active users.
261
+ - 100,000 active users.
262
+ - 1,000,000 active users.
263
+ - 5,000,000 active users.
264
+ - 10,000,000 active users.
265
+
266
+ These are planning scenarios, not guaranteed capacity or actual usage.
267
+
268
+ Distinguish:
269
+
270
+ - Registered users.
271
+ - Monthly active users.
272
+ - Daily active users.
273
+ - Concurrent users.
274
+ - Requests per user.
275
+ - AI operations per user.
276
+ - Storage per user.
277
+ - Messages per user.
278
+ - Data transfer per user.
279
+
280
+ Estimate normal and peak demand.
281
+
282
+ Never calculate costs using registered-user counts alone when usage drives billing.
283
+
284
+ ## 9. Unit Economics
285
+
286
+ Where meaningful, calculate:
287
+
288
+ - Cost per active user.
289
+ - Cost per API request.
290
+ - Cost per AI operation.
291
+ - Cost per completed transaction.
292
+ - Cost per processed document.
293
+ - Cost per notification.
294
+ - Cost per uploaded gigabyte.
295
+ - Cost per generated image.
296
+ - Cost per minute of processed audio or video.
297
+ - Cost per tenant.
298
+ - Cost per business workflow.
299
+
300
+ Identify costs that grow faster than revenue or usage.
301
+
302
+ Compare unit costs before and after significant architectural changes.
303
+
304
+ Avoid optimizing irrelevant low-cost operations while ignoring expensive recurring workloads.
305
+
306
+ ## 10. Cost Modeling Method
307
+
308
+ Use explicit formulas.
309
+
310
+ For usage-based services:
311
+
312
+ Monthly Cost = Fixed Charges + Sum(Usage Quantity x Applicable Unit Price) + Other Applicable Charges
313
+
314
+ Account for:
315
+
316
+ - Included quotas.
317
+ - Tiered pricing.
318
+ - Regional differences.
319
+ - Billing minimums.
320
+ - Billing increments.
321
+ - Peak capacity.
322
+ - Data transfer.
323
+ - Taxes where relevant.
324
+ - Discounts and commitments where verified.
325
+
326
+ For tiered pricing, calculate each applicable tier correctly rather than applying one rate to all usage.
327
+
328
+ Do not mix incompatible billing units.
329
+
330
+ Avoid double-counting shared infrastructure.
331
+
332
+ Clearly state when the formula is an approximation.
333
+
334
+ ## 11. Cloud Compute Costs
335
+
336
+ Evaluate:
337
+
338
+ - Instance types.
339
+ - CPU allocation.
340
+ - Memory allocation.
341
+ - Runtime hours.
342
+ - Utilization.
343
+ - Autoscaling.
344
+ - Reserved or committed capacity.
345
+ - Spot or interruptible capacity.
346
+ - Availability requirements.
347
+ - Idle resources.
348
+ - Deployment environments.
349
+
350
+ Use measured demand when available.
351
+
352
+ Avoid permanently overprovisioned compute.
353
+
354
+ Do not reduce capacity below reliability or performance requirements.
355
+
356
+ Evaluate whether smaller instances, autoscaling or managed platforms provide better value.
357
+
358
+ ## 12. Serverless Cost Engineering
359
+
360
+ Evaluate:
361
+
362
+ - Invocation count.
363
+ - Execution duration.
364
+ - Memory allocation.
365
+ - CPU allocation.
366
+ - Concurrency.
367
+ - Provisioned capacity.
368
+ - Cold starts.
369
+ - Request volume.
370
+ - Network traffic.
371
+ - Logging.
372
+ - Database connections.
373
+ - Retry behavior.
374
+ - Timeouts.
375
+
376
+ Identify workloads where serverless is economically appropriate.
377
+
378
+ Compare bursty and sustained workloads.
379
+
380
+ Do not assume serverless costs remain low under continuous high-volume execution.
381
+
382
+ Set appropriate concurrency and execution limits.
383
+
384
+ ## 13. Kubernetes Cost Engineering
385
+
386
+ Kubernetes is optional.
387
+
388
+ Never introduce Kubernetes solely because an application targets millions of users.
389
+
390
+ Evaluate the complete cost of:
391
+
392
+ - Cluster control planes.
393
+ - Worker nodes.
394
+ - CPU reservations.
395
+ - Memory reservations.
396
+ - Autoscaling.
397
+ - Persistent volumes.
398
+ - Storage operations.
399
+ - Load balancers.
400
+ - Network egress.
401
+ - Cross-zone traffic.
402
+ - Cross-region traffic.
403
+ - Container registries.
404
+ - Logging.
405
+ - Monitoring.
406
+ - Backups.
407
+ - Security services.
408
+ - Cluster administration.
409
+ - Operational maintenance.
410
+
411
+ Evaluate resource requests, limits and actual utilization.
412
+
413
+ Identify idle capacity and oversized workloads.
414
+
415
+ Use appropriate scaling policies and resource quotas.
416
+
417
+ Compare managed Kubernetes with simpler managed application platforms and serverless alternatives.
418
+
419
+ Never claim Kubernetes reduces costs without workload-specific evidence.
420
+
421
+ ## 14. EKS, AKS and GKE
422
+
423
+ When using managed Kubernetes, evaluate provider-specific billing.
424
+
425
+ ### Amazon EKS
426
+
427
+ Review applicable:
428
+
429
+ - Cluster management charges.
430
+ - Worker compute.
431
+ - Networking.
432
+ - Storage.
433
+ - Load balancing.
434
+ - Logging.
435
+ - Data transfer.
436
+ - Support or extended lifecycle charges.
437
+
438
+ ### Azure Kubernetes Service
439
+
440
+ Review applicable:
441
+
442
+ - Cluster management tiers or charges.
443
+ - Node pools.
444
+ - Compute.
445
+ - Networking.
446
+ - Persistent storage.
447
+ - Load balancing.
448
+ - Monitoring.
449
+ - Backup and recovery.
450
+
451
+ ### Google Kubernetes Engine
452
+
453
+ Review applicable:
454
+
455
+ - Cluster management charges.
456
+ - Compute.
457
+ - Autopilot or Standard operating models.
458
+ - Storage.
459
+ - Load balancing.
460
+ - Network traffic.
461
+ - Observability.
462
+ - Backup and recovery.
463
+
464
+ Verify current official pricing.
465
+
466
+ Do not assume EKS, AKS and GKE have identical billing models.
467
+
468
+ Do not compare only control plane pricing.
469
+
470
+ ## 15. Database Cost Engineering
471
+
472
+ Evaluate:
473
+
474
+ - Database compute.
475
+ - Storage.
476
+ - Index size.
477
+ - Reads and writes.
478
+ - Database connections.
479
+ - Connection pooling.
480
+ - Read replicas.
481
+ - High availability.
482
+ - Backup retention.
483
+ - Replication.
484
+ - Data transfer.
485
+ - Transaction volume.
486
+ - Query efficiency.
487
+ - Monitoring.
488
+
489
+ Investigate expensive queries and inefficient access patterns.
490
+
491
+ Avoid unnecessary database duplication.
492
+
493
+ Optimize data access before recommending expensive infrastructure upgrades.
494
+
495
+ Consult docs/data.md.
496
+
497
+ ## 16. Supabase Cost Engineering
498
+
499
+ For Supabase projects, review current applicable pricing dimensions.
500
+
501
+ Evaluate:
502
+
503
+ - Organization subscription.
504
+ - Project compute.
505
+ - Database size.
506
+ - Storage.
507
+ - Data egress.
508
+ - Authentication usage.
509
+ - Monthly active users.
510
+ - Edge Function usage.
511
+ - Realtime usage.
512
+ - Concurrent connections.
513
+ - Message volumes.
514
+ - Backup options.
515
+ - Point-in-time recovery.
516
+ - Additional projects.
517
+ - Optional services and add-ons.
518
+
519
+ Verify current limits and billing rules.
520
+
521
+ Review whether unused development projects create recurring charges.
522
+
523
+ Analyze expensive queries and inefficient realtime subscriptions.
524
+
525
+ Do not assume upgrading the plan is the correct response to every performance issue.
526
+
527
+ ## 17. Firebase Cost Engineering
528
+
529
+ For Firebase projects, evaluate relevant usage such as:
530
+
531
+ - Firestore reads.
532
+ - Firestore writes.
533
+ - Firestore deletes.
534
+ - Document storage.
535
+ - Index storage.
536
+ - Realtime Database usage.
537
+ - Network transfer.
538
+ - Cloud Functions or related compute.
539
+ - Authentication services.
540
+ - Storage.
541
+ - Hosting.
542
+ - Monitoring.
543
+
544
+ Understand the actual billing dimensions of the selected services.
545
+
546
+ Avoid unnecessary repeated reads and listeners.
547
+
548
+ Evaluate query design before increasing capacity.
549
+
550
+ Do not assume all Firebase services follow one pricing model.
551
+
552
+ ## 18. Object Storage Costs
553
+
554
+ Evaluate:
555
+
556
+ - Stored data volume.
557
+ - Object count where relevant.
558
+ - Upload operations.
559
+ - Download operations.
560
+ - Read/write requests.
561
+ - Retrieval charges.
562
+ - Storage classes.
563
+ - Retention.
564
+ - Replication.
565
+ - Versioning.
566
+ - Backup storage.
567
+ - Lifecycle transitions.
568
+ - Data transfer.
569
+
570
+ Use lifecycle policies where appropriate.
571
+
572
+ Avoid storing unnecessary duplicates.
573
+
574
+ Do not remove data required for legal, operational or recovery purposes.
575
+
576
+ Evaluate compression and media optimization.
577
+
578
+ ## 19. Image and Video Costs
579
+
580
+ For media-heavy applications, evaluate:
581
+
582
+ - Upload volume.
583
+ - Original files.
584
+ - Generated variants.
585
+ - Image resizing.
586
+ - Transcoding.
587
+ - Video processing.
588
+ - Streaming bandwidth.
589
+ - CDN delivery.
590
+ - Thumbnail generation.
591
+ - Storage retention.
592
+ - Media duplication.
593
+ - External media APIs.
594
+
595
+ Estimate average media size and consumption frequency.
596
+
597
+ Consider efficient formats, adaptive streaming and appropriate caching.
598
+
599
+ Prevent unlimited uploads or processing when abuse could create excessive charges.
600
+
601
+ ## 20. CDN and Network Costs
602
+
603
+ Evaluate:
604
+
605
+ - Internet egress.
606
+ - CDN delivery.
607
+ - Origin requests.
608
+ - Cache hit ratio.
609
+ - Cross-region transfer.
610
+ - Cross-zone transfer.
611
+ - Internal networking charges.
612
+ - Load balancing.
613
+ - NAT gateway usage where relevant.
614
+ - Private connectivity.
615
+ - Repeated downloads.
616
+
617
+ Do not assume internal cloud traffic is free.
618
+
619
+ Use appropriate caching to reduce origin load.
620
+
621
+ Never expose private content through public caching.
622
+
623
+ ## 21. Third-Party API Costs
624
+
625
+ Before integrating external APIs:
626
+
627
+ 1. Review pricing.
628
+ 2. Identify billing units.
629
+ 3. Estimate usage.
630
+ 4. Understand quotas.
631
+ 5. Evaluate retry behavior.
632
+ 6. Define timeouts.
633
+ 7. Define concurrency limits.
634
+ 8. Identify fallback behavior.
635
+ 9. Monitor consumption.
636
+ 10. Document ownership and business value.
637
+
638
+ Examples include:
639
+
640
+ - Geolocation.
641
+ - Maps.
642
+ - Search.
643
+ - Translation.
644
+ - Document processing.
645
+ - Identity verification.
646
+ - Weather.
647
+ - Financial data.
648
+ - Communications.
649
+ - Analytics.
650
+
651
+ Avoid excessive polling and duplicate requests.
652
+
653
+ Do not introduce paid dependencies without justification.
654
+
655
+ ## 22. AI Model and LLM Costs
656
+
657
+ For AI features, evaluate:
658
+
659
+ - Input tokens.
660
+ - Output tokens.
661
+ - Cached tokens where applicable.
662
+ - Context length.
663
+ - Model selection.
664
+ - Inference frequency.
665
+ - Tool calls.
666
+ - Retries.
667
+ - Agent loops.
668
+ - Batch processing.
669
+ - Image generation.
670
+ - Speech processing.
671
+ - Video generation.
672
+ - Provider-specific charges.
673
+
674
+ Model the cost of complete user workflows rather than isolated model calls.
675
+
676
+ Prevent unbounded agent execution.
677
+
678
+ Set appropriate request, token and spending limits.
679
+
680
+ Verify actual model pricing and capabilities.
681
+
682
+ Do not automatically select the largest model for every task.
683
+
684
+ ## 23. AI Agent Cost Controls
685
+
686
+ For agentic systems:
687
+
688
+ - Define maximum execution steps.
689
+ - Define tool-call limits.
690
+ - Limit unnecessary recursion.
691
+ - Detect repeated failed operations.
692
+ - Apply bounded retries.
693
+ - Estimate workflow costs.
694
+ - Monitor token usage.
695
+ - Prevent duplicate processing.
696
+ - Establish user or tenant quotas.
697
+ - Apply timeouts.
698
+ - Define human approval thresholds.
699
+
700
+ Evaluate the business value of each autonomous operation.
701
+
702
+ Avoid unnecessary multi-agent orchestration.
703
+
704
+ Never trade away required security validation solely to reduce inference costs.
705
+
706
+ Consult docs/ai-and-llm.md.
707
+
708
+ ## 24. RAG and Vector Search Costs
709
+
710
+ Evaluate:
711
+
712
+ - Document ingestion.
713
+ - Parsing.
714
+ - Chunking.
715
+ - Embedding generation.
716
+ - Embedding updates.
717
+ - Vector index size.
718
+ - Retrieval queries.
719
+ - Reranking.
720
+ - Storage.
721
+ - Database compute.
722
+ - Model inference.
723
+ - Data deletion.
724
+ - Reindexing.
725
+
726
+ Avoid repeatedly embedding unchanged documents.
727
+
728
+ Track source versions and processing status.
729
+
730
+ Use incremental ingestion where appropriate.
731
+
732
+ Do not duplicate vector collections unnecessarily.
733
+
734
+ Optimize retrieval quality and total workflow cost together.
735
+
736
+ ## 25. AI Model Routing
737
+
738
+ Evaluate whether different workloads require different model capabilities.
739
+
740
+ Possible approaches include:
741
+
742
+ - Smaller models for simpler operations.
743
+ - Larger models for complex reasoning.
744
+ - Deterministic code for straightforward tasks.
745
+ - Cached responses where safe.
746
+ - Batching where supported.
747
+ - Asynchronous processing.
748
+
749
+ Model routing must preserve:
750
+
751
+ - Required accuracy.
752
+ - Security.
753
+ - Privacy.
754
+ - Reliability.
755
+ - Explainability where applicable.
756
+ - Business constraints.
757
+
758
+ Validate quality before changing models.
759
+
760
+ Do not select cheaper models without assessing task-specific performance.
761
+
762
+ ## 26. Authentication Costs
763
+
764
+ Evaluate relevant costs associated with:
765
+
766
+ - Monthly active users.
767
+ - Enterprise identity providers.
768
+ - MFA.
769
+ - SMS verification.
770
+ - Email verification.
771
+ - External identity services.
772
+ - Authentication logs.
773
+ - Security monitoring.
774
+ - Session infrastructure.
775
+
776
+ Prevent unnecessary repeated verification requests.
777
+
778
+ Do not weaken authentication requirements to reduce spending.
779
+
780
+ Estimate costs under realistic user activity.
781
+
782
+ ## 27. SMS, Email and Notifications
783
+
784
+ Evaluate:
785
+
786
+ - Messages per user.
787
+ - Delivery region.
788
+ - Provider pricing.
789
+ - Retries.
790
+ - Failed deliveries.
791
+ - Transactional messages.
792
+ - Marketing messages.
793
+ - Push notification infrastructure.
794
+ - Abuse prevention.
795
+ - Logging.
796
+ - Retention.
797
+
798
+ Use notification preferences and appropriate batching.
799
+
800
+ Prevent unbounded automated messaging.
801
+
802
+ Do not suppress required security or operational notifications merely to reduce costs.
803
+
804
+ ## 28. Payment and Transaction Costs
805
+
806
+ For payment integrations, evaluate:
807
+
808
+ - Transaction fees.
809
+ - Fixed processing fees.
810
+ - International payment charges.
811
+ - Currency conversion.
812
+ - Refund fees where applicable.
813
+ - Dispute costs.
814
+ - Subscription billing.
815
+ - Payout charges.
816
+ - Fraud prevention services.
817
+
818
+ Distinguish payment processing fees from application infrastructure costs.
819
+
820
+ Verify pricing according to country, payment method and contractual terms.
821
+
822
+ Never compromise transaction integrity or compliance for cost optimization.
823
+
824
+ ## 29. Monitoring and Logging Costs
825
+
826
+ Evaluate:
827
+
828
+ - Log ingestion.
829
+ - Log storage.
830
+ - Retention.
831
+ - Metrics.
832
+ - Metric cardinality.
833
+ - Tracing.
834
+ - Sampling.
835
+ - Alerting.
836
+ - Dashboard usage.
837
+ - Data transfer.
838
+ - Incident tooling.
839
+
840
+ Avoid excessive high-cardinality metrics.
841
+
842
+ Use appropriate sampling and retention policies.
843
+
844
+ Do not disable essential security logs or operational alerts merely to reduce costs.
845
+
846
+ Never log secrets or unnecessary sensitive information.
847
+
848
+ Consult docs/observability.md.
849
+
850
+ ## 30. Backup and Disaster Recovery Costs
851
+
852
+ Evaluate:
853
+
854
+ - Backup storage.
855
+ - Backup frequency.
856
+ - Retention periods.
857
+ - Point-in-time recovery.
858
+ - Geographic replication.
859
+ - Recovery infrastructure.
860
+ - Restoration operations.
861
+ - Data transfer.
862
+ - Recovery testing.
863
+
864
+ Balance cost with approved Recovery Point Objectives and Recovery Time Objectives.
865
+
866
+ Do not eliminate required backups to reduce expenditure.
867
+
868
+ Recovery capability must be tested, not merely assumed.
869
+
870
+ ## 31. Development and Staging Costs
871
+
872
+ Review non-production infrastructure.
873
+
874
+ Evaluate:
875
+
876
+ - Unused environments.
877
+ - Idle databases.
878
+ - Duplicate cloud projects.
879
+ - Oversized staging resources.
880
+ - Persistent test clusters.
881
+ - Development storage.
882
+ - CI/CD usage.
883
+ - Build minutes.
884
+ - Artifact retention.
885
+ - Preview deployments.
886
+
887
+ Use scheduled shutdowns or appropriate lower-cost configurations where safe.
888
+
889
+ Avoid shutting down environments required for critical testing or team operations.
890
+
891
+ Never delete resources without verifying ownership and obtaining required approval.
892
+
893
+ ## 32. CI/CD Cost Engineering
894
+
895
+ Evaluate:
896
+
897
+ - Build frequency.
898
+ - Build duration.
899
+ - Parallel jobs.
900
+ - Test execution time.
901
+ - Artifact storage.
902
+ - Container image storage.
903
+ - Cache efficiency.
904
+ - Runner infrastructure.
905
+ - Deployment frequency.
906
+
907
+ Optimize redundant work without weakening quality gates.
908
+
909
+ Do not skip security scans, critical tests or required checks merely to save execution costs.
910
+
911
+ Use incremental processing where appropriate.
912
+
913
+ ## 33. Cost Attribution
914
+
915
+ Where possible, attribute costs to:
916
+
917
+ - Projects.
918
+ - Applications.
919
+ - Environments.
920
+ - Services.
921
+ - Teams.
922
+ - Tenants.
923
+ - Business workflows.
924
+ - AI models.
925
+ - Third-party providers.
926
+
927
+ Use supported resource tags, labels or equivalent metadata.
928
+
929
+ Avoid excessive telemetry that costs more than the insight it provides.
930
+
931
+ Identify shared costs clearly.
932
+
933
+ Do not expose one tenant's financial or usage information to another tenant.
934
+
935
+ ## 34. Budgets and Alerts
936
+
937
+ Recommend appropriate cost governance mechanisms.
938
+
939
+ Consider:
940
+
941
+ - Monthly budgets.
942
+ - Environment budgets.
943
+ - Project budgets.
944
+ - AI spending limits.
945
+ - Usage thresholds.
946
+ - Forecast alerts.
947
+ - Unexpected spending alerts.
948
+ - Resource quotas.
949
+ - Rate limits.
950
+ - Concurrency limits.
951
+
952
+ Verify which controls are advisory and which can actually enforce limits.
953
+
954
+ A budget alert does not necessarily prevent further charges.
955
+
956
+ Do not claim that spending is capped unless the relevant provider or application mechanism truly enforces the limit.
957
+
958
+ ## 35. Cost Anomaly Detection
959
+
960
+ Monitor for unusual changes such as:
961
+
962
+ - Sudden traffic increases.
963
+ - Unexpected database usage.
964
+ - Excessive AI token consumption.
965
+ - Retry loops.
966
+ - Storage growth.
967
+ - Network egress spikes.
968
+ - Realtime message explosions.
969
+ - Logging volume spikes.
970
+ - Unexpected compute activity.
971
+ - Abusive API requests.
972
+ - Compromised credentials.
973
+
974
+ Investigate anomalies before making changes.
975
+
976
+ Distinguish legitimate product growth from inefficient or malicious usage.
977
+
978
+ Apply protective limits where appropriate.
979
+
980
+ ## 36. Abuse and Financial Denial of Service
981
+
982
+ Evaluate whether attackers or abusive clients could generate large expenses.
983
+
984
+ Protect costly operations using appropriate:
985
+
986
+ - Authentication.
987
+ - Authorization.
988
+ - Rate limiting.
989
+ - Quotas.
990
+ - Spending controls.
991
+ - Bounded retries.
992
+ - Concurrency controls.
993
+ - Request validation.
994
+ - Abuse detection.
995
+ - Human approval for expensive operations.
996
+
997
+ Pay particular attention to:
998
+
999
+ - AI inference.
1000
+ - Video generation.
1001
+ - Image generation.
1002
+ - SMS.
1003
+ - Paid APIs.
1004
+ - Expensive searches.
1005
+ - Large file uploads.
1006
+ - Automated exports.
1007
+
1008
+ Never expose privileged API keys in client applications.
1009
+
1010
+ Avoid designs where unauthenticated users can trigger unlimited paid operations.
1011
+
1012
+ ## 37. Architectural Cost Trade-offs
1013
+
1014
+ Before recommending significant architectural changes, compare reasonable alternatives.
1015
+
1016
+ Examples:
1017
+
1018
+ - Modular monolith versus microservices.
1019
+ - Serverless versus continuously running compute.
1020
+ - Managed database versus self-hosted database.
1021
+ - Managed containers versus Kubernetes.
1022
+ - Shared infrastructure versus isolated infrastructure.
1023
+ - Single-region versus multi-region.
1024
+ - Hosted AI models versus self-hosted inference.
1025
+
1026
+ Evaluate:
1027
+
1028
+ - Cost.
1029
+ - Reliability.
1030
+ - Security.
1031
+ - Performance.
1032
+ - Operational complexity.
1033
+ - Scalability.
1034
+ - Migration risk.
1035
+ - Team capabilities.
1036
+
1037
+ Select technology according to evidence, not preference.
1038
+
1039
+ ## 38. Kubernetes Adoption Decision
1040
+
1041
+ Kubernetes must not be introduced automatically.
1042
+
1043
+ An adoption proposal must explain:
1044
+
1045
+ 1. Why existing infrastructure is insufficient.
1046
+ 2. Why simpler alternatives are insufficient.
1047
+ 3. Which workloads benefit.
1048
+ 4. Expected operational complexity.
1049
+ 5. Security implications.
1050
+ 6. Availability implications.
1051
+ 7. Expected monthly costs.
1052
+ 8. Migration costs.
1053
+ 9. Scaling behavior.
1054
+ 10. Rollback options.
1055
+
1056
+ Require explicit human approval before adoption.
1057
+
1058
+ Consult docs/architecture.md and docs/scalability.md.
1059
+
1060
+ ## 39. Vendor Lock-in and Migration Costs
1061
+
1062
+ Evaluate:
1063
+
1064
+ - Proprietary APIs.
1065
+ - Data export capabilities.
1066
+ - Service-specific dependencies.
1067
+ - Contractual commitments.
1068
+ - Data transfer charges.
1069
+ - Engineering migration work.
1070
+ - Testing.
1071
+ - Operational retraining.
1072
+ - Downtime risks.
1073
+ - Parallel infrastructure during migration.
1074
+
1075
+ Do not assume a lower monthly hosting quote justifies a migration.
1076
+
1077
+ Compare total financial and operational impact.
1078
+
1079
+ Avoid unnecessary provider abstraction when the abstraction itself creates greater complexity and cost.
1080
+
1081
+ ## 40. Cost Optimization Priority
1082
+
1083
+ Prioritize improvements according to:
1084
+
1085
+ 1. Financial impact.
1086
+ 2. Implementation effort.
1087
+ 3. Security risk.
1088
+ 4. Reliability risk.
1089
+ 5. User impact.
1090
+ 6. Reversibility.
1091
+ 7. Confidence in expected savings.
1092
+
1093
+ Prefer changes that eliminate clear waste before proposing major redesigns.
1094
+
1095
+ Examples:
1096
+
1097
+ - Removing confirmed unused resources after approval.
1098
+ - Fixing repeated unnecessary requests.
1099
+ - Optimizing expensive queries.
1100
+ - Improving cache effectiveness.
1101
+ - Reducing duplicate media processing.
1102
+ - Correcting uncontrolled retries.
1103
+ - Rightsizing overprovisioned services.
1104
+
1105
+ Never make destructive changes automatically.
1106
+
1107
+ ## 41. Existing Production Cost Audits
1108
+
1109
+ When auditing an existing production application:
1110
+
1111
+ 1. Inspect the actual technology stack.
1112
+ 2. Identify infrastructure providers.
1113
+ 3. Inventory paid services.
1114
+ 4. Review available billing data.
1115
+ 5. Review usage metrics.
1116
+ 6. Identify known cost drivers.
1117
+ 7. Assess growth-related risks.
1118
+ 8. Identify inefficient operations.
1119
+ 9. Evaluate existing budgets and alerts.
1120
+ 10. Recommend prioritized improvements.
1121
+ 11. Present evidence and assumptions.
1122
+ 12. Request approval before implementation.
1123
+
1124
+ The initial audit must be read-only.
1125
+
1126
+ Do not:
1127
+
1128
+ - Delete resources.
1129
+ - Downgrade plans.
1130
+ - Change production quotas.
1131
+ - Disable monitoring.
1132
+ - Modify billing settings.
1133
+ - Cancel subscriptions.
1134
+ - Migrate providers.
1135
+ - Change production configurations.
1136
+
1137
+ without explicit human approval.
1138
+
1139
+ If actual billing data is unavailable, state that the analysis is based on architecture and estimated usage.
1140
+
1141
+ Never invent observed spending.
1142
+
1143
+ ## 42. Cost Reporting
1144
+
1145
+ For significant cost assessments, provide:
1146
+
1147
+ ### Current State
1148
+
1149
+ - Known providers.
1150
+ - Relevant services.
1151
+ - Existing architecture.
1152
+ - Available usage data.
1153
+ - Verified current costs.
1154
+ - Unknown costs.
1155
+
1156
+ ### Cost Drivers
1157
+
1158
+ - Primary expenses.
1159
+ - Usage patterns.
1160
+ - Growth sensitivity.
1161
+ - Potential inefficiencies.
1162
+
1163
+ ### Recommendations
1164
+
1165
+ - Proposed optimization.
1166
+ - Technical justification.
1167
+ - Estimated savings when supportable.
1168
+ - Implementation effort.
1169
+ - Risks.
1170
+ - Dependencies.
1171
+ - Testing requirements.
1172
+
1173
+ ### Approval
1174
+
1175
+ - Changes requiring authorization.
1176
+ - Expected operational impact.
1177
+ - Rollback or recovery plan.
1178
+
1179
+ Separate facts from assumptions and estimates.
1180
+
1181
+ ## 43. Cost Review During Development
1182
+
1183
+ Before implementing features that may introduce significant recurring costs:
1184
+
1185
+ - Identify new paid dependencies.
1186
+ - Evaluate expected consumption.
1187
+ - Check free-tier limitations.
1188
+ - Evaluate growth costs.
1189
+ - Consider abuse scenarios.
1190
+ - Assess monitoring requirements.
1191
+ - Define usage limits.
1192
+ - Document the estimate.
1193
+ - Request approval when required.
1194
+
1195
+ Do not introduce hidden recurring financial obligations.
1196
+
1197
+ ## 44. Cost Review During Code Review
1198
+
1199
+ Where relevant, examine whether a change introduces:
1200
+
1201
+ - Additional database queries.
1202
+ - Unbounded API calls.
1203
+ - Repeated AI inference.
1204
+ - New background jobs.
1205
+ - Excessive polling.
1206
+ - Duplicate storage.
1207
+ - Expensive logs.
1208
+ - Unbounded retries.
1209
+ - Large network payloads.
1210
+ - Unexpected third-party charges.
1211
+
1212
+ Report meaningful risks before deployment.
1213
+
1214
+ Do not block harmless changes based on speculative or negligible costs.
1215
+
1216
+ ## 45. Cost Review Before Deployment
1217
+
1218
+ For financially significant deployments:
1219
+
1220
+ 1. Confirm expected usage.
1221
+ 2. Review new paid services.
1222
+ 3. Check infrastructure configuration.
1223
+ 4. Verify resource limits.
1224
+ 5. Verify authentication and authorization.
1225
+ 6. Review rate limits.
1226
+ 7. Check observability.
1227
+ 8. Confirm budget controls.
1228
+ 9. Evaluate rollback requirements.
1229
+ 10. Obtain explicit approval.
1230
+
1231
+ Never silently provision expensive production infrastructure.
1232
+
1233
+ ## 46. Financial Safety for AI Coding Agents
1234
+
1235
+ AI development agents must treat infrastructure and financial commitments as privileged operations.
1236
+
1237
+ Without explicit human approval, do not:
1238
+
1239
+ - Upgrade paid service plans.
1240
+ - Enable paid add-ons.
1241
+ - Provision expensive compute.
1242
+ - Create production Kubernetes clusters.
1243
+ - Increase production resource limits materially.
1244
+ - Purchase reserved capacity.
1245
+ - Commit to cloud contracts.
1246
+ - Enable high-cost AI models.
1247
+ - Remove financial safeguards.
1248
+ - Disable cost alerts.
1249
+ - Change payment methods.
1250
+ - Create recurring financial commitments.
1251
+
1252
+ Do not interpret repository access as authorization for spending.
1253
+
1254
+ A command that is technically executable may still require financial approval.
1255
+
1256
+ If financial impact is uncertain, present the risk and request authorization.
1257
+
1258
+ ## 47. Cost-Aware Architecture for Millions of Users
1259
+
1260
+ Plan for scalability without premature overinvestment.
1261
+
1262
+ For growth scenarios, evaluate:
1263
+
1264
+ - Unit cost trends.
1265
+ - Database scaling.
1266
+ - Compute scaling.
1267
+ - Storage growth.
1268
+ - Network costs.
1269
+ - Realtime costs.
1270
+ - AI consumption.
1271
+ - Third-party dependency costs.
1272
+ - Operational complexity.
1273
+ - Recovery costs.
1274
+
1275
+ Identify likely future bottlenecks.
1276
+
1277
+ Define measurable thresholds for architectural evolution.
1278
+
1279
+ Do not deploy enterprise-scale infrastructure before it is justified.
1280
+
1281
+ Never claim that a platform can support ten million users solely because it runs in the cloud.
1282
+
1283
+ ## 48. Cost Definition of Done
1284
+
1285
+ For significant changes with financial implications:
1286
+
1287
+ - Cost drivers identified.
1288
+ - Provider pricing verified where possible.
1289
+ - Workload assumptions documented.
1290
+ - Estimated cost impact assessed.
1291
+ - Security implications reviewed.
1292
+ - Privacy implications reviewed.
1293
+ - Reliability maintained.
1294
+ - Scalability considered.
1295
+ - Resource limits evaluated.
1296
+ - Abuse prevention considered.
1297
+ - Monitoring requirements defined.
1298
+ - Alternatives evaluated.
1299
+ - Risks documented.
1300
+ - Required human approvals obtained.
1301
+
1302
+ Cost optimization is incomplete if it introduces unacceptable operational or security risk.
1303
+
1304
+ ## 49. Final Cost Engineering Principles
1305
+
1306
+ Design for growth.
1307
+ Provision for reality.
1308
+ Measure before optimizing.
1309
+ Understand every paid dependency.
1310
+ Verify provider pricing.
1311
+ Estimate before committing.
1312
+ Monitor after deployment.
1313
+ Prevent unbounded consumption.
1314
+ Control AI inference costs.
1315
+ Control database and storage costs.
1316
+ Control network and CDN costs.
1317
+ Evaluate Kubernetes total ownership cost.
1318
+ Avoid unnecessary complexity.
1319
+ Preserve existing production systems.
1320
+ Never sacrifice security or data integrity.
1321
+ Never invent pricing or usage metrics.
1322
+ Require approval for significant financial changes.