specweave 0.23.16 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/.claude-plugin/marketplace.json +93 -38
  2. package/CLAUDE.md +159 -11
  3. package/dist/plugins/specweave-github/lib/github-spec-content-sync.d.ts.map +1 -1
  4. package/dist/plugins/specweave-github/lib/github-spec-content-sync.js +57 -0
  5. package/dist/plugins/specweave-github/lib/github-spec-content-sync.js.map +1 -1
  6. package/dist/src/cli/commands/sync-spec-content.js +3 -0
  7. package/dist/src/cli/commands/sync-spec-content.js.map +1 -1
  8. package/dist/src/cli/helpers/ado-area-path-mapper.d.ts +89 -0
  9. package/dist/src/cli/helpers/ado-area-path-mapper.d.ts.map +1 -0
  10. package/dist/src/cli/helpers/ado-area-path-mapper.js +213 -0
  11. package/dist/src/cli/helpers/ado-area-path-mapper.js.map +1 -0
  12. package/dist/src/cli/helpers/issue-tracker/ado-auto-discover.d.ts +29 -0
  13. package/dist/src/cli/helpers/issue-tracker/ado-auto-discover.d.ts.map +1 -0
  14. package/dist/src/cli/helpers/issue-tracker/ado-auto-discover.js +109 -0
  15. package/dist/src/cli/helpers/issue-tracker/ado-auto-discover.js.map +1 -0
  16. package/dist/src/cli/helpers/issue-tracker/ado.d.ts +1 -0
  17. package/dist/src/cli/helpers/issue-tracker/ado.d.ts.map +1 -1
  18. package/dist/src/cli/helpers/issue-tracker/ado.js +2 -0
  19. package/dist/src/cli/helpers/issue-tracker/ado.js.map +1 -1
  20. package/dist/src/cli/helpers/smart-filter.d.ts +83 -0
  21. package/dist/src/cli/helpers/smart-filter.d.ts.map +1 -0
  22. package/dist/src/cli/helpers/smart-filter.js +265 -0
  23. package/dist/src/cli/helpers/smart-filter.js.map +1 -0
  24. package/dist/src/core/progress/progress-tracker.d.ts +4 -1
  25. package/dist/src/core/progress/progress-tracker.d.ts.map +1 -1
  26. package/dist/src/core/progress/progress-tracker.js +33 -4
  27. package/dist/src/core/progress/progress-tracker.js.map +1 -1
  28. package/dist/src/core/qa/quality-gate-decider.d.ts +1 -1
  29. package/dist/src/core/qa/quality-gate-decider.js +2 -2
  30. package/dist/src/core/qa/quality-gate-decider.js.map +1 -1
  31. package/dist/src/core/qa/risk-calculator.d.ts +2 -2
  32. package/dist/src/core/qa/risk-calculator.js +2 -2
  33. package/dist/src/core/spec-content-sync.d.ts +1 -1
  34. package/dist/src/core/spec-content-sync.d.ts.map +1 -1
  35. package/dist/src/core/validators/ac-presence-validator.d.ts +56 -0
  36. package/dist/src/core/validators/ac-presence-validator.d.ts.map +1 -0
  37. package/dist/src/core/validators/ac-presence-validator.js +149 -0
  38. package/dist/src/core/validators/ac-presence-validator.js.map +1 -0
  39. package/dist/src/integrations/ado/ado-dependency-loader.d.ts +1 -1
  40. package/dist/src/integrations/ado/ado-dependency-loader.d.ts.map +1 -1
  41. package/dist/src/integrations/ado/ado-dependency-loader.js +39 -7
  42. package/dist/src/integrations/ado/ado-dependency-loader.js.map +1 -1
  43. package/dist/src/integrations/ado/area-path-mapper.d.ts +137 -0
  44. package/dist/src/integrations/ado/area-path-mapper.d.ts.map +1 -0
  45. package/dist/src/integrations/ado/area-path-mapper.js +267 -0
  46. package/dist/src/integrations/ado/area-path-mapper.js.map +1 -0
  47. package/dist/src/integrations/jira/filter-processor.d.ts +126 -0
  48. package/dist/src/integrations/jira/filter-processor.d.ts.map +1 -0
  49. package/dist/src/integrations/jira/filter-processor.js +207 -0
  50. package/dist/src/integrations/jira/filter-processor.js.map +1 -0
  51. package/dist/src/integrations/jira/jira-client.d.ts +13 -0
  52. package/dist/src/integrations/jira/jira-client.d.ts.map +1 -1
  53. package/dist/src/integrations/jira/jira-client.js +33 -0
  54. package/dist/src/integrations/jira/jira-client.js.map +1 -1
  55. package/dist/src/utils/ac-embedder.d.ts +63 -0
  56. package/dist/src/utils/ac-embedder.d.ts.map +1 -0
  57. package/dist/src/utils/ac-embedder.js +217 -0
  58. package/dist/src/utils/ac-embedder.js.map +1 -0
  59. package/dist/src/utils/env-manager.d.ts +86 -0
  60. package/dist/src/utils/env-manager.d.ts.map +1 -0
  61. package/dist/src/utils/env-manager.js +188 -0
  62. package/dist/src/utils/env-manager.js.map +1 -0
  63. package/package.json +1 -1
  64. package/plugins/specweave/.claude-plugin/plugin.json +1 -1
  65. package/plugins/specweave/agents/AGENTS-INDEX.md +1 -1
  66. package/plugins/specweave/agents/increment-quality-judge-v2/AGENT.md +9 -9
  67. package/plugins/specweave/commands/specweave-do.md +37 -0
  68. package/plugins/specweave/commands/specweave-done.md +159 -0
  69. package/plugins/specweave/commands/specweave-embed-acs.md +446 -0
  70. package/plugins/specweave/commands/specweave-next.md +148 -3
  71. package/plugins/specweave/commands/specweave-qa.md +2 -2
  72. package/plugins/specweave/hooks/lib/migrate-increment-work.sh +1 -1
  73. package/plugins/specweave/hooks/lib/migrate-increment-work.sh.bak +245 -0
  74. package/plugins/specweave/hooks/lib/sync-spec-content.sh +2 -2
  75. package/plugins/specweave/hooks/lib/sync-spec-content.sh.bak +149 -0
  76. package/plugins/specweave/hooks/lib/update-status-line.sh +34 -4
  77. package/plugins/specweave/hooks/lib/validate-spec-status.sh +1 -1
  78. package/plugins/specweave/hooks/lib/validate-spec-status.sh.bak +163 -0
  79. package/plugins/specweave/hooks/post-first-increment.sh +1 -1
  80. package/plugins/specweave/hooks/post-first-increment.sh.bak +61 -0
  81. package/plugins/specweave/hooks/post-spec-update.sh +1 -1
  82. package/plugins/specweave/hooks/post-spec-update.sh.bak +158 -0
  83. package/plugins/specweave/hooks/post-user-story-complete.sh +1 -1
  84. package/plugins/specweave/hooks/post-user-story-complete.sh.bak +179 -0
  85. package/plugins/specweave/hooks/pre-command-deduplication.sh +1 -1
  86. package/plugins/specweave/hooks/pre-command-deduplication.sh.bak +83 -0
  87. package/plugins/specweave/hooks/pre-increment-start.sh +168 -0
  88. package/plugins/specweave/hooks/user-prompt-submit.sh +1 -1
  89. package/plugins/specweave/hooks/user-prompt-submit.sh.bak +386 -0
  90. package/plugins/specweave/skills/SKILLS-INDEX.md +1 -1
  91. package/plugins/specweave/skills/specweave-framework/SKILL.md +1 -1
  92. package/plugins/specweave-ado/.claude-plugin/plugin.json +1 -1
  93. package/plugins/specweave-ado/agents/ado-manager/AGENT.md +23 -0
  94. package/plugins/specweave-ado/agents/ado-multi-project-mapper/AGENT.md +23 -0
  95. package/plugins/specweave-ado/agents/ado-sync-judge/AGENT.md +23 -0
  96. package/plugins/specweave-ado/commands/specweave-ado-import-projects.md +331 -0
  97. package/plugins/specweave-alternatives/.claude-plugin/plugin.json +10 -0
  98. package/plugins/specweave-alternatives/commands/alternatives-analyze.md +336 -0
  99. package/plugins/specweave-alternatives/skills/architecture-alternatives/SKILL.md +651 -0
  100. package/plugins/specweave-alternatives/skills/bmad-method/SKILL.md +420 -0
  101. package/plugins/specweave-alternatives/skills/spec-kit-expert/SKILL.md +487 -0
  102. package/plugins/specweave-backend/agents/database-optimizer/AGENT.md +23 -0
  103. package/plugins/specweave-backend/commands/api-scaffold.md +80 -0
  104. package/plugins/specweave-backend/commands/crud-generate.md +109 -0
  105. package/plugins/specweave-backend/commands/migration-generate.md +139 -0
  106. package/plugins/specweave-confluent/agents/confluent-architect/AGENT.md +23 -0
  107. package/plugins/specweave-confluent/commands/connector-deploy.md +154 -0
  108. package/plugins/specweave-confluent/commands/ksqldb-query.md +179 -0
  109. package/plugins/specweave-confluent/commands/schema-register.md +123 -0
  110. package/plugins/specweave-core/.claude-plugin/plugin.json +21 -0
  111. package/plugins/specweave-core/commands/architecture-review.md +288 -0
  112. package/plugins/specweave-core/commands/code-review.md +213 -0
  113. package/plugins/specweave-core/commands/refactor-plan.md +249 -0
  114. package/plugins/specweave-core/skills/code-quality/SKILL.md +157 -0
  115. package/plugins/specweave-core/skills/design-patterns/SKILL.md +244 -0
  116. package/plugins/specweave-core/skills/software-architecture/SKILL.md +83 -0
  117. package/plugins/specweave-cost-optimizer/.claude-plugin/plugin.json +22 -0
  118. package/plugins/specweave-cost-optimizer/commands/cost-analyze.md +360 -0
  119. package/plugins/specweave-cost-optimizer/commands/cost-optimize.md +480 -0
  120. package/plugins/specweave-cost-optimizer/skills/aws-cost-expert/SKILL.md +416 -0
  121. package/plugins/specweave-cost-optimizer/skills/cloud-pricing/SKILL.md +325 -0
  122. package/plugins/specweave-cost-optimizer/skills/cost-optimization/SKILL.md +337 -0
  123. package/plugins/specweave-diagrams/.claude-plugin/plugin.json +1 -1
  124. package/plugins/specweave-diagrams/agents/diagrams-architect/AGENT.md +23 -0
  125. package/plugins/specweave-diagrams/commands/diagrams-generate.md +168 -0
  126. package/plugins/specweave-docs/.claude-plugin/plugin.json +10 -0
  127. package/plugins/specweave-docs/commands/docs-generate.md +441 -0
  128. package/plugins/specweave-docs/commands/docs-init.md +334 -0
  129. package/plugins/specweave-docs/skills/docusaurus/SKILL.md +581 -0
  130. package/plugins/specweave-docs/skills/spec-driven-brainstorming/SKILL.md +689 -0
  131. package/plugins/specweave-docs/skills/technical-writing/SKILL.md +1039 -0
  132. package/plugins/specweave-docs-preview/.claude-plugin/plugin.json +1 -1
  133. package/plugins/specweave-figma/.claude-plugin/plugin.json +23 -0
  134. package/plugins/specweave-figma/commands/figma-import.md +690 -0
  135. package/plugins/specweave-figma/commands/figma-to-react.md +834 -0
  136. package/plugins/specweave-figma/commands/figma-tokens.md +815 -0
  137. package/plugins/specweave-frontend/.claude-plugin/plugin.json +21 -0
  138. package/plugins/specweave-frontend/agents/frontend-architect/AGENT.md +387 -0
  139. package/plugins/specweave-frontend/agents/frontend-architect/README.md +385 -0
  140. package/plugins/specweave-frontend/agents/frontend-architect/examples.md +590 -0
  141. package/plugins/specweave-frontend/agents/frontend-architect/templates/component-template.tsx +152 -0
  142. package/plugins/specweave-frontend/agents/frontend-architect/templates/hook-template.ts +311 -0
  143. package/plugins/specweave-frontend/agents/frontend-architect/templates/page-template.tsx +228 -0
  144. package/plugins/specweave-frontend/commands/component-generate.md +510 -0
  145. package/plugins/specweave-frontend/commands/design-system-init.md +494 -0
  146. package/plugins/specweave-frontend/commands/frontend-scaffold.md +207 -0
  147. package/plugins/specweave-frontend/commands/nextjs-setup.md +396 -0
  148. package/plugins/specweave-frontend/skills/design-system-architect/SKILL.md +278 -0
  149. package/plugins/specweave-frontend/skills/frontend/SKILL.md +420 -0
  150. package/plugins/specweave-frontend/skills/nextjs/SKILL.md +546 -0
  151. package/plugins/specweave-github/.claude-plugin/plugin.json +1 -1
  152. package/plugins/specweave-github/agents/github-manager/AGENT.md +23 -0
  153. package/plugins/specweave-github/agents/github-task-splitter/AGENT.md +25 -0
  154. package/plugins/specweave-github/agents/user-story-updater/AGENT.md +25 -0
  155. package/plugins/specweave-github/hooks/.specweave/logs/hooks-debug.log +194 -0
  156. package/plugins/specweave-github/lib/github-spec-content-sync.js +49 -0
  157. package/plugins/specweave-github/lib/github-spec-content-sync.ts +67 -0
  158. package/plugins/specweave-infrastructure/.claude-plugin/plugin.json +1 -1
  159. package/plugins/specweave-infrastructure/agents/devops/AGENT.md +26 -0
  160. package/plugins/specweave-infrastructure/agents/network-engineer/AGENT.md +26 -0
  161. package/plugins/specweave-infrastructure/agents/observability-engineer/AGENT.md +26 -0
  162. package/plugins/specweave-infrastructure/agents/performance-engineer/AGENT.md +26 -0
  163. package/plugins/specweave-infrastructure/agents/sre/AGENT.md +26 -0
  164. package/plugins/specweave-jira/.claude-plugin/plugin.json +1 -1
  165. package/plugins/specweave-jira/agents/jira-manager/AGENT.md +26 -0
  166. package/plugins/specweave-jira/commands/import-projects.js +183 -0
  167. package/plugins/specweave-jira/commands/import-projects.md +97 -0
  168. package/plugins/specweave-jira/commands/import-projects.ts +288 -0
  169. package/plugins/specweave-jira/commands/specweave-jira-import-projects.md +298 -0
  170. package/plugins/specweave-kafka/.claude-plugin/plugin.json +1 -1
  171. package/plugins/specweave-kafka/agents/kafka-architect/AGENT.md +26 -0
  172. package/plugins/specweave-kafka/agents/kafka-devops/AGENT.md +26 -0
  173. package/plugins/specweave-kafka/agents/kafka-observability/AGENT.md +26 -0
  174. package/plugins/specweave-kafka-streams/.claude-plugin/plugin.json +1 -1
  175. package/plugins/specweave-kubernetes/agents/kubernetes-architect/AGENT.md +26 -0
  176. package/plugins/specweave-kubernetes/commands/cluster-setup.md +262 -0
  177. package/plugins/specweave-kubernetes/commands/deployment-generate.md +242 -0
  178. package/plugins/specweave-kubernetes/commands/helm-scaffold.md +333 -0
  179. package/plugins/specweave-ml/.claude-plugin/plugin.json +3 -3
  180. package/plugins/specweave-ml/agents/data-scientist/AGENT.md +26 -0
  181. package/plugins/specweave-ml/agents/ml-engineer/AGENT.md +26 -0
  182. package/plugins/specweave-ml/agents/mlops-engineer/AGENT.md +26 -0
  183. package/plugins/specweave-mobile/agents/mobile-architect/AGENT.md +26 -0
  184. package/plugins/specweave-mobile/commands/app-scaffold.md +233 -0
  185. package/plugins/specweave-mobile/commands/build-config.md +256 -0
  186. package/plugins/specweave-mobile/commands/screen-generate.md +289 -0
  187. package/plugins/specweave-n8n/.claude-plugin/plugin.json +1 -1
  188. package/plugins/specweave-payments/agents/payment-integration/AGENT.md +26 -0
  189. package/plugins/specweave-plugin-dev/.claude-plugin/plugin.json +20 -0
  190. package/plugins/specweave-plugin-dev/commands/plugin-create.md +333 -0
  191. package/plugins/specweave-plugin-dev/commands/plugin-publish.md +339 -0
  192. package/plugins/specweave-plugin-dev/commands/plugin-test.md +293 -0
  193. package/plugins/specweave-plugin-dev/skills/claude-sdk/SKILL.md +162 -0
  194. package/plugins/specweave-plugin-dev/skills/marketplace-publishing/SKILL.md +263 -0
  195. package/plugins/specweave-plugin-dev/skills/plugin-development/SKILL.md +316 -0
  196. package/plugins/specweave-release/.claude-plugin/plugin.json +1 -1
  197. package/plugins/specweave-release/agents/release-manager/AGENT.md +27 -0
  198. package/plugins/specweave-release/commands/specweave-release-npm.md +110 -0
  199. package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +168 -0
  200. package/plugins/specweave-testing/.claude-plugin/plugin.json +21 -0
  201. package/plugins/specweave-testing/agents/qa-engineer/AGENT.md +797 -0
  202. package/plugins/specweave-testing/agents/qa-engineer/README.md +443 -0
  203. package/plugins/specweave-testing/agents/qa-engineer/templates/playwright-e2e-test.ts +470 -0
  204. package/plugins/specweave-testing/agents/qa-engineer/templates/test-data-factory.ts +507 -0
  205. package/plugins/specweave-testing/agents/qa-engineer/templates/vitest-unit-test.ts +400 -0
  206. package/plugins/specweave-testing/agents/qa-engineer/test-strategies.md +726 -0
  207. package/plugins/specweave-testing/commands/e2e-setup.md +1081 -0
  208. package/plugins/specweave-testing/commands/test-coverage.md +979 -0
  209. package/plugins/specweave-testing/commands/test-generate.md +1156 -0
  210. package/plugins/specweave-testing/commands/test-init.md +409 -0
  211. package/plugins/specweave-testing/skills/e2e-playwright/SKILL.md +769 -0
  212. package/plugins/specweave-testing/skills/tdd-expert/SKILL.md +934 -0
  213. package/plugins/specweave-testing/skills/unit-testing-expert/SKILL.md +1011 -0
  214. package/plugins/specweave-tooling/.claude-plugin/plugin.json +22 -0
  215. package/plugins/specweave-tooling/commands/specweave-tooling-skill-create.md +691 -0
  216. package/plugins/specweave-tooling/commands/specweave-tooling-skill-package.md +751 -0
  217. package/plugins/specweave-tooling/commands/specweave-tooling-skill-validate.md +858 -0
  218. package/plugins/specweave-ui/.claude-plugin/plugin.json +10 -0
  219. package/plugins/specweave-ui/commands/ui-automate.md +199 -0
  220. package/plugins/specweave-ui/commands/ui-inspect.md +70 -0
  221. package/plugins/specweave-ui/skills/browser-automation/SKILL.md +314 -0
  222. package/plugins/specweave-ui/skills/ui-testing/SKILL.md +716 -0
  223. package/plugins/specweave-ui/skills/visual-regression/SKILL.md +728 -0
  224. package/plugins/specweave/commands/check-hooks.md +0 -257
  225. package/plugins/specweave/commands/specweave-archive-increments.md +0 -82
  226. package/plugins/specweave/skills/plugin-expert/SKILL.md +0 -340
  227. /package/plugins/specweave/{agents/code-reviewer.md → skills/code-reviewer/SKILL.md} +0 -0
@@ -0,0 +1,83 @@
1
+ ---
2
+ name: software-architecture
3
+ description: Expert software architecture covering architectural patterns (microservices, monolith, event-driven, CQRS), scalability, distributed systems, CAP theorem, database architecture, API design, system design, domain-driven design (DDD), hexagonal architecture, and architecture decision records (ADRs). Activates for software architecture, system design, microservices, monolith, event-driven, CQRS, scalability, distributed systems, CAP theorem, DDD, hexagonal architecture, ADR.
4
+ ---
5
+
6
+ # Software Architecture Expert
7
+
8
+ Master of architectural patterns, system design, and scalability.
9
+
10
+ ## Architectural Patterns
11
+
12
+ **Layered Architecture**:
13
+ ```
14
+ Presentation Layer (UI)
15
+
16
+ Business Logic Layer (Services)
17
+
18
+ Data Access Layer (Repositories)
19
+
20
+ Database
21
+ ```
22
+
23
+ **Hexagonal Architecture (Ports & Adapters)**:
24
+ ```typescript
25
+ // Core Domain (business logic, no dependencies)
26
+ interface PaymentPort {
27
+ process(amount: number): Promise<void>;
28
+ }
29
+
30
+ // Adapter (infrastructure)
31
+ class StripeAdapter implements PaymentPort {
32
+ async process(amount: number) { /* Stripe API */ }
33
+ }
34
+
35
+ // Application uses port, not concrete implementation
36
+ class CheckoutService {
37
+ constructor(private payment: PaymentPort) {}
38
+ }
39
+ ```
40
+
41
+ **Event-Driven Architecture**:
42
+ ```typescript
43
+ // Producer
44
+ eventBus.publish({ type: 'OrderPlaced', orderId: '123' });
45
+
46
+ // Consumers (decoupled)
47
+ eventBus.subscribe('OrderPlaced', inventoryService.reserve);
48
+ eventBus.subscribe('OrderPlaced', emailService.notify);
49
+ ```
50
+
51
+ **CQRS** (Command Query Responsibility Segregation):
52
+ - Commands: Write operations, change state
53
+ - Queries: Read operations, no side effects
54
+ - Separate models for read/write optimization
55
+
56
+ ## Scalability Patterns
57
+
58
+ **Horizontal Scaling**: Add more servers
59
+ **Vertical Scaling**: Bigger server
60
+ **Caching**: Redis, CDN, application cache
61
+ **Database Sharding**: Partition by key (user_id, region)
62
+ **Read Replicas**: Offload read traffic
63
+ **Load Balancing**: Distribute traffic evenly
64
+
65
+ ## CAP Theorem
66
+
67
+ **Consistency**: All nodes see same data
68
+ **Availability**: Every request gets response
69
+ **Partition Tolerance**: System works despite network failures
70
+
71
+ Can only guarantee 2 of 3:
72
+ - **CP**: Consistent + Partition-tolerant (sacrifice availability)
73
+ - **AP**: Available + Partition-tolerant (eventual consistency)
74
+ - **CA**: Consistent + Available (no partition tolerance, single node)
75
+
76
+ ## Domain-Driven Design
77
+
78
+ **Ubiquitous Language**: Shared vocabulary
79
+ **Bounded Contexts**: Explicit boundaries
80
+ **Aggregates**: Consistency boundaries
81
+ **Entities**: Objects with identity
82
+ **Value Objects**: Immutable, no identity
83
+ **Domain Events**: Business occurrences
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "specweave-cost-optimizer",
3
+ "description": "Cloud cost optimization and analysis for AWS, Azure, GCP, and serverless platforms. Provides cost analysis, optimization recommendations, pricing comparisons, budget alerts, and serverless cost modeling with 2024/2025 pricing.",
4
+ "version": "0.24.0",
5
+ "author": {
6
+ "name": "Anton Abyzov",
7
+ "email": "anton.abyzov@gmail.com"
8
+ },
9
+ "homepage": "https://spec-weave.com",
10
+ "repository": "https://github.com/anton-abyzov/specweave",
11
+ "license": "MIT",
12
+ "keywords": [
13
+ "cost-optimization",
14
+ "cloud-costs",
15
+ "aws-pricing",
16
+ "azure-costs",
17
+ "gcp-pricing",
18
+ "serverless-costs",
19
+ "finops",
20
+ "specweave"
21
+ ]
22
+ }
@@ -0,0 +1,360 @@
1
+ # /specweave-cost-optimizer:cost-analyze
2
+
3
+ Analyze cloud infrastructure costs and identify optimization opportunities across AWS, Azure, and GCP.
4
+
5
+ You are an expert FinOps engineer who performs comprehensive cost analysis for cloud infrastructure.
6
+
7
+ ## Your Task
8
+
9
+ Perform deep cost analysis of cloud resources and generate actionable optimization recommendations.
10
+
11
+ ### 1. Cost Analysis Scope
12
+
13
+ **Multi-Cloud Support**:
14
+ - AWS (EC2, Lambda, S3, RDS, DynamoDB, ECS/EKS, CloudFront)
15
+ - Azure (VMs, Functions, Storage, SQL, Cosmos DB, AKS, CDN)
16
+ - GCP (Compute Engine, Cloud Functions, Cloud Storage, Cloud SQL, GKE, Cloud CDN)
17
+
18
+ **Analysis Dimensions**:
19
+ - Resource utilization vs capacity
20
+ - Reserved vs on-demand pricing
21
+ - Right-sizing opportunities
22
+ - Idle resource detection
23
+ - Storage lifecycle policies
24
+ - Data transfer costs
25
+ - Region pricing differences
26
+
27
+ ### 2. Data Collection Methods
28
+
29
+ **AWS Cost Explorer**:
30
+ ```bash
31
+ # Get cost and usage data
32
+ aws ce get-cost-and-usage \
33
+ --time-period Start=2025-01-01,End=2025-01-31 \
34
+ --granularity DAILY \
35
+ --metrics BlendedCost \
36
+ --group-by Type=SERVICE
37
+
38
+ # Get right-sizing recommendations
39
+ aws ce get-rightsizing-recommendation \
40
+ --service AmazonEC2 \
41
+ --page-size 100
42
+ ```
43
+
44
+ **Azure Cost Management**:
45
+ ```bash
46
+ # Get cost details
47
+ az consumption usage list \
48
+ --start-date 2025-01-01 \
49
+ --end-date 2025-01-31
50
+
51
+ # Get advisor recommendations
52
+ az advisor recommendation list \
53
+ --category Cost
54
+ ```
55
+
56
+ **GCP Billing API**:
57
+ ```bash
58
+ # Export billing to BigQuery
59
+ # Then query:
60
+ SELECT
61
+ service.description as service,
62
+ SUM(cost) as total_cost
63
+ FROM `project.dataset.gcp_billing_export`
64
+ WHERE _PARTITIONDATE >= '2025-01-01'
65
+ GROUP BY service
66
+ ORDER BY total_cost DESC
67
+ ```
68
+
69
+ ### 3. Analysis Framework
70
+
71
+ **Step 1: Resource Inventory**
72
+ - List all compute instances (EC2, VMs, Compute Engine)
73
+ - Identify database resources (RDS, SQL, Cloud SQL)
74
+ - Catalog storage (S3, Blob, Cloud Storage)
75
+ - Map serverless functions (Lambda, Functions, Cloud Functions)
76
+ - Document networking (Load Balancers, NAT Gateways, VPN)
77
+
78
+ **Step 2: Utilization Analysis**
79
+ ```typescript
80
+ interface ResourceUtilization {
81
+ resourceId: string;
82
+ resourceType: string;
83
+ cpu: {
84
+ average: number;
85
+ peak: number;
86
+ p95: number;
87
+ };
88
+ memory: {
89
+ average: number;
90
+ peak: number;
91
+ p95: number;
92
+ };
93
+ recommendation: 'downsize' | 'rightsize' | 'optimal' | 'upsize';
94
+ }
95
+
96
+ // Example thresholds
97
+ const THRESHOLDS = {
98
+ cpu: {
99
+ idle: 5, // < 5% CPU = idle
100
+ underused: 20, // < 20% CPU = undersized
101
+ optimal: 70, // 20-70% = optimal
102
+ overused: 85, // > 85% = needs upsize
103
+ },
104
+ memory: {
105
+ idle: 10,
106
+ underused: 30,
107
+ optimal: 75,
108
+ overused: 90,
109
+ },
110
+ };
111
+ ```
112
+
113
+ **Step 3: Cost Breakdown**
114
+ ```typescript
115
+ interface CostBreakdown {
116
+ total: number;
117
+ byService: Record<string, number>;
118
+ byEnvironment: Record<string, number>;
119
+ byTeam: Record<string, number>;
120
+ trends: {
121
+ mom: number; // month-over-month %
122
+ yoy: number; // year-over-year %
123
+ };
124
+ }
125
+ ```
126
+
127
+ ### 4. Optimization Opportunities
128
+
129
+ **Compute Optimization**:
130
+ - **Idle Resources**: Instances with < 5% CPU for 7+ days
131
+ - **Right-sizing**: Over-provisioned instances (< 20% utilization)
132
+ - **Reserved Instances**: Steady-state workloads (> 70% usage)
133
+ - **Spot/Preemptible**: Fault-tolerant, stateless workloads
134
+ - **Auto-scaling**: Variable workloads with predictable patterns
135
+
136
+ **Storage Optimization**:
137
+ - **Lifecycle Policies**: Move to cheaper tiers (S3 IA, Glacier, Archive)
138
+ - **Compression**: Enable compression for text/logs
139
+ - **Deduplication**: Remove duplicate data
140
+ - **Snapshots**: Delete old AMIs, EBS snapshots, disk snapshots
141
+ - **Data Transfer**: Use CDN, optimize cross-region transfers
142
+
143
+ **Database Optimization**:
144
+ - **Right-sizing**: Analyze IOPS, connections, memory usage
145
+ - **Reserved Capacity**: RDS/SQL Reserved Instances
146
+ - **Serverless Options**: Aurora Serverless, Cosmos DB serverless
147
+ - **Read Replicas**: Offload read traffic
148
+ - **Backup Retention**: Optimize backup storage costs
149
+
150
+ **Serverless Optimization**:
151
+ - **Memory Allocation**: Lambda/Functions memory vs execution time
152
+ - **Concurrency**: Optimize for cold starts vs cost
153
+ - **VPC Configuration**: Avoid VPC Lambda unless needed (adds NAT costs)
154
+ - **Invocation Patterns**: Batch vs streaming, sync vs async
155
+
156
+ ### 5. Savings Calculations
157
+
158
+ **Reserved Instance Savings**:
159
+ ```typescript
160
+ interface RISavings {
161
+ currentOnDemandCost: number;
162
+ riCost: number;
163
+ upfrontCost: number;
164
+ monthlySavings: number;
165
+ annualSavings: number;
166
+ paybackPeriod: number; // months
167
+ roi: number; // %
168
+ }
169
+
170
+ // Example: AWS EC2 Reserved Instance
171
+ const onDemandCost = 0.096 * 730; // t3.large on-demand/month
172
+ const ri1Year = 0.062 * 730; // t3.large 1-year RI
173
+ const savings = onDemandCost - ri1Year; // $24.82/month = $297.84/year
174
+ const savingsPercent = (savings / onDemandCost) * 100; // 35%
175
+ ```
176
+
177
+ **Spot Instance Savings**:
178
+ ```typescript
179
+ // Spot instances can save 50-90%
180
+ const onDemand = 0.096; // t3.large
181
+ const spot = 0.0288; // typical spot price (70% discount)
182
+ const savings = 1 - (spot / onDemand); // 70% savings
183
+ ```
184
+
185
+ **Storage Tier Savings**:
186
+ ```typescript
187
+ // S3 pricing (us-east-1, per GB/month)
188
+ const pricing = {
189
+ standard: 0.023,
190
+ ia: 0.0125, // Infrequent Access (54% cheaper)
191
+ glacier: 0.004, // Glacier (83% cheaper)
192
+ deepArchive: 0.00099, // Deep Archive (96% cheaper)
193
+ };
194
+
195
+ // For 1TB rarely accessed data
196
+ const cost_standard = 1024 * 0.023; // $23.55/month
197
+ const cost_ia = 1024 * 0.0125; // $12.80/month
198
+ const savings = cost_standard - cost_ia; // $10.75/month = $129/year
199
+ ```
200
+
201
+ ### 6. Report Structure
202
+
203
+ **Executive Summary**:
204
+ ```markdown
205
+ ## Cost Analysis Summary (January 2025)
206
+
207
+ **Current Monthly Cost**: $45,320
208
+ **Projected Annual Cost**: $543,840
209
+
210
+ **Optimization Potential**:
211
+ - Immediate savings: $12,450/month (27%)
212
+ - 12-month savings: $18,900/month (42%)
213
+
214
+ **Top 3 Opportunities**:
215
+ 1. Right-size EC2 instances: $6,200/month
216
+ 2. Purchase RDS Reserved Instances: $4,800/month
217
+ 3. Implement S3 lifecycle policies: $1,450/month
218
+ ```
219
+
220
+ **Detailed Recommendations**:
221
+ ```markdown
222
+ ### 1. Compute Optimization ($6,200/month savings)
223
+
224
+ #### Idle EC2 Instances (15 instances, $2,100/month)
225
+ - **prod-app-server-7**: $140/month (< 2% CPU for 30 days)
226
+ - **dev-test-server-3**: $96/month (stopped 28/30 days)
227
+ - [See full list...]
228
+
229
+ **Action**: Terminate or stop unused instances
230
+
231
+ #### Over-provisioned Instances (32 instances, $4,100/month)
232
+ - **prod-web-01**: c5.2xlarge → c5.xlarge (saves $145/month)
233
+ - Current: 8 vCPU, 16GB RAM, 15% CPU avg
234
+ - Recommended: 4 vCPU, 8GB RAM
235
+ - **prod-api-05**: m5.4xlarge → m5.2xlarge (saves $280/month)
236
+ - Current: 16 vCPU, 64GB RAM, 22% CPU avg, 35% memory avg
237
+ - Recommended: 8 vCPU, 32GB RAM
238
+
239
+ **Action**: Resize instances during next maintenance window
240
+ ```
241
+
242
+ ### 7. Cost Forecasting
243
+
244
+ **Trend Analysis**:
245
+ ```typescript
246
+ interface CostForecast {
247
+ historical: Array<{ month: string; cost: number }>;
248
+ forecast: Array<{ month: string; cost: number; confidence: number }>;
249
+ assumptions: string[];
250
+ }
251
+
252
+ // Simple linear regression for trend
253
+ function forecastCost(historicalData: number[]): number {
254
+ const n = historicalData.length;
255
+ const sumX = (n * (n + 1)) / 2;
256
+ const sumY = historicalData.reduce((a, b) => a + b, 0);
257
+ const sumXY = historicalData.reduce((sum, y, x) => sum + (x + 1) * y, 0);
258
+ const sumX2 = (n * (n + 1) * (2 * n + 1)) / 6;
259
+
260
+ const slope = (n * sumXY - sumX * sumY) / (n * sumX2 - sumX * sumX);
261
+ const intercept = (sumY - slope * sumX) / n;
262
+
263
+ return slope * (n + 1) + intercept; // next month
264
+ }
265
+ ```
266
+
267
+ ### 8. Budget Alerts
268
+
269
+ **Threshold-based Alerts**:
270
+ ```yaml
271
+ budgets:
272
+ - name: "Production Environment"
273
+ monthly_budget: 30000
274
+ alerts:
275
+ - threshold: 80% # $24,000
276
+ action: "Email team leads"
277
+ - threshold: 90% # $27,000
278
+ action: "Email engineering + finance"
279
+ - threshold: 100% # $30,000
280
+ action: "Alert on-call + freeze non-critical deploys"
281
+
282
+ - name: "Development Environment"
283
+ monthly_budget: 5000
284
+ alerts:
285
+ - threshold: 100%
286
+ action: "Auto-stop non-essential instances"
287
+ ```
288
+
289
+ ### 9. Tagging Strategy
290
+
291
+ **Cost Allocation Tags**:
292
+ ```yaml
293
+ required_tags:
294
+ - Environment: [prod, staging, dev, test]
295
+ - Team: [platform, api, frontend, data]
296
+ - Project: [project-alpha, project-beta]
297
+ - CostCenter: [engineering, product, ops]
298
+ - Owner: [email]
299
+
300
+ enforcement:
301
+ - Deny instance launch without tags (AWS Config rule)
302
+ - Monthly report of untagged resources
303
+ - Auto-tag based on stack/subnet (Terraform)
304
+ ```
305
+
306
+ ### 10. FinOps Best Practices
307
+
308
+ **Cost Visibility**:
309
+ - Daily cost dashboard (Grafana, CloudWatch, Azure Monitor)
310
+ - Weekly cost review with team leads
311
+ - Monthly FinOps meeting with stakeholders
312
+ - Quarterly budget planning
313
+
314
+ **Cost Accountability**:
315
+ - Chargeback model per team/project
316
+ - Show-back reports for visibility
317
+ - Cost-aware deployment pipelines (estimate before deploy)
318
+ - Engineer access to cost dashboard
319
+
320
+ **Continuous Optimization**:
321
+ - Automated right-sizing recommendations (weekly)
322
+ - Savings plan utilization review (monthly)
323
+ - Spot instance adoption tracking
324
+ - Reserved instance coverage reports
325
+
326
+ ## Workflow
327
+
328
+ 1. **Collect Data**: Pull cost/usage data from cloud providers (last 30-90 days)
329
+ 2. **Analyze Utilization**: Calculate CPU, memory, disk, network metrics
330
+ 3. **Identify Waste**: Find idle, over-provisioned, orphaned resources
331
+ 4. **Calculate Savings**: Quantify potential savings per recommendation
332
+ 5. **Prioritize**: Rank by savings potential and implementation effort
333
+ 6. **Generate Report**: Create executive summary + detailed action plan
334
+ 7. **Track Progress**: Monitor adoption of recommendations
335
+
336
+ ## Example Usage
337
+
338
+ **User**: "Analyze our AWS costs for January 2025"
339
+
340
+ **Response**:
341
+ - Pulls AWS Cost Explorer data
342
+ - Analyzes EC2, RDS, S3, Lambda usage
343
+ - Identifies $12K/month in optimization opportunities:
344
+ - $6K: Right-size EC2 instances (15 instances)
345
+ - $4K: Purchase RDS Reserved Instances (3 databases)
346
+ - $1.5K: S3 lifecycle policies (200GB → Glacier)
347
+ - $500: Delete orphaned EBS snapshots
348
+ - Provides detailed implementation plan
349
+ - Estimates 12-month savings: $144K
350
+
351
+ ## When to Use
352
+
353
+ - Monthly/quarterly cost reviews
354
+ - Budget overrun investigations
355
+ - Pre-purchase Reserved Instance planning
356
+ - Architecture cost optimization
357
+ - New project cost estimation
358
+ - Post-incident cost spike analysis
359
+
360
+ Analyze cloud costs like a FinOps expert!