specweave 0.23.18 → 0.24.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/.claude-plugin/marketplace.json +144 -45
- package/CLAUDE.md +137 -4
- package/dist/src/cli/helpers/ado-area-path-mapper.d.ts +89 -0
- package/dist/src/cli/helpers/ado-area-path-mapper.d.ts.map +1 -0
- package/dist/src/cli/helpers/ado-area-path-mapper.js +213 -0
- package/dist/src/cli/helpers/ado-area-path-mapper.js.map +1 -0
- package/dist/src/cli/helpers/issue-tracker/ado-auto-discover.d.ts +29 -0
- package/dist/src/cli/helpers/issue-tracker/ado-auto-discover.d.ts.map +1 -0
- package/dist/src/cli/helpers/issue-tracker/ado-auto-discover.js +109 -0
- package/dist/src/cli/helpers/issue-tracker/ado-auto-discover.js.map +1 -0
- package/dist/src/cli/helpers/issue-tracker/ado.d.ts +1 -0
- package/dist/src/cli/helpers/issue-tracker/ado.d.ts.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/ado.js +2 -0
- package/dist/src/cli/helpers/issue-tracker/ado.js.map +1 -1
- package/dist/src/cli/helpers/smart-filter.d.ts +83 -0
- package/dist/src/cli/helpers/smart-filter.d.ts.map +1 -0
- package/dist/src/cli/helpers/smart-filter.js +265 -0
- package/dist/src/cli/helpers/smart-filter.js.map +1 -0
- package/dist/src/core/qa/quality-gate-decider.d.ts +1 -1
- package/dist/src/core/qa/quality-gate-decider.js +2 -2
- package/dist/src/core/qa/quality-gate-decider.js.map +1 -1
- package/dist/src/core/qa/risk-calculator.d.ts +2 -2
- package/dist/src/core/qa/risk-calculator.js +2 -2
- package/dist/src/core/repo-structure/repo-structure-manager.d.ts.map +1 -1
- package/dist/src/core/repo-structure/repo-structure-manager.js +76 -43
- package/dist/src/core/repo-structure/repo-structure-manager.js.map +1 -1
- package/dist/src/core/validators/ac-presence-validator.d.ts +56 -0
- package/dist/src/core/validators/ac-presence-validator.d.ts.map +1 -0
- package/dist/src/core/validators/ac-presence-validator.js +149 -0
- package/dist/src/core/validators/ac-presence-validator.js.map +1 -0
- package/dist/src/integrations/ado/area-path-mapper.d.ts +137 -0
- package/dist/src/integrations/ado/area-path-mapper.d.ts.map +1 -0
- package/dist/src/integrations/ado/area-path-mapper.js +267 -0
- package/dist/src/integrations/ado/area-path-mapper.js.map +1 -0
- package/dist/src/integrations/jira/filter-processor.d.ts +126 -0
- package/dist/src/integrations/jira/filter-processor.d.ts.map +1 -0
- package/dist/src/integrations/jira/filter-processor.js +207 -0
- package/dist/src/integrations/jira/filter-processor.js.map +1 -0
- package/dist/src/integrations/jira/jira-client.d.ts +13 -0
- package/dist/src/integrations/jira/jira-client.d.ts.map +1 -1
- package/dist/src/integrations/jira/jira-client.js +33 -0
- package/dist/src/integrations/jira/jira-client.js.map +1 -1
- package/dist/src/utils/ac-embedder.d.ts +63 -0
- package/dist/src/utils/ac-embedder.d.ts.map +1 -0
- package/dist/src/utils/ac-embedder.js +217 -0
- package/dist/src/utils/ac-embedder.js.map +1 -0
- package/dist/src/utils/env-manager.d.ts +86 -0
- package/dist/src/utils/env-manager.d.ts.map +1 -0
- package/dist/src/utils/env-manager.js +188 -0
- package/dist/src/utils/env-manager.js.map +1 -0
- package/package.json +1 -1
- package/plugins/specweave/.claude-plugin/plugin.json +1 -1
- package/plugins/specweave/agents/AGENTS-INDEX.md +1 -1
- package/plugins/specweave/agents/increment-quality-judge-v2/AGENT.md +9 -9
- package/plugins/specweave/commands/specweave-do.md +37 -0
- package/plugins/specweave/commands/specweave-done.md +159 -0
- package/plugins/specweave/commands/specweave-embed-acs.md +446 -0
- package/plugins/specweave/commands/specweave-next.md +148 -3
- package/plugins/specweave/commands/specweave-qa.md +2 -2
- package/plugins/specweave/hooks/pre-increment-start.sh +168 -0
- package/plugins/specweave/skills/SKILLS-INDEX.md +1 -1
- package/plugins/specweave-ado/.claude-plugin/plugin.json +1 -1
- package/plugins/specweave-ado/commands/specweave-ado-import-projects.md +331 -0
- package/plugins/specweave-alternatives/.claude-plugin/plugin.json +10 -0
- package/plugins/specweave-alternatives/commands/alternatives-analyze.md +336 -0
- package/plugins/specweave-alternatives/skills/architecture-alternatives/SKILL.md +651 -0
- package/plugins/specweave-alternatives/skills/bmad-method/SKILL.md +420 -0
- package/plugins/specweave-alternatives/skills/spec-kit-expert/SKILL.md +487 -0
- package/plugins/specweave-backend/commands/api-scaffold.md +80 -0
- package/plugins/specweave-backend/commands/crud-generate.md +109 -0
- package/plugins/specweave-backend/commands/migration-generate.md +139 -0
- package/plugins/specweave-confluent/commands/connector-deploy.md +154 -0
- package/plugins/specweave-confluent/commands/ksqldb-query.md +179 -0
- package/plugins/specweave-confluent/commands/schema-register.md +123 -0
- package/plugins/specweave-core/.claude-plugin/plugin.json +21 -0
- package/plugins/specweave-core/commands/architecture-review.md +288 -0
- package/plugins/specweave-core/commands/code-review.md +213 -0
- package/plugins/specweave-core/commands/refactor-plan.md +249 -0
- package/plugins/specweave-core/skills/code-quality/SKILL.md +157 -0
- package/plugins/specweave-core/skills/design-patterns/SKILL.md +244 -0
- package/plugins/specweave-core/skills/software-architecture/SKILL.md +83 -0
- package/plugins/specweave-cost-optimizer/.claude-plugin/plugin.json +22 -0
- package/plugins/specweave-cost-optimizer/commands/cost-analyze.md +360 -0
- package/plugins/specweave-cost-optimizer/commands/cost-optimize.md +480 -0
- package/plugins/specweave-cost-optimizer/skills/aws-cost-expert/SKILL.md +416 -0
- package/plugins/specweave-cost-optimizer/skills/cloud-pricing/SKILL.md +325 -0
- package/plugins/specweave-cost-optimizer/skills/cost-optimization/SKILL.md +337 -0
- package/plugins/specweave-diagrams/.claude-plugin/plugin.json +1 -1
- package/plugins/specweave-diagrams/commands/diagrams-generate.md +168 -0
- package/plugins/specweave-docs/.claude-plugin/plugin.json +10 -0
- package/plugins/specweave-docs/commands/docs-generate.md +441 -0
- package/plugins/specweave-docs/commands/docs-init.md +334 -0
- package/plugins/specweave-docs/skills/docusaurus/SKILL.md +581 -0
- package/plugins/specweave-docs/skills/spec-driven-brainstorming/SKILL.md +689 -0
- package/plugins/specweave-docs/skills/technical-writing/SKILL.md +1039 -0
- package/plugins/specweave-docs-preview/.claude-plugin/plugin.json +1 -1
- package/plugins/specweave-figma/.claude-plugin/plugin.json +23 -0
- package/plugins/specweave-figma/commands/figma-import.md +690 -0
- package/plugins/specweave-figma/commands/figma-to-react.md +834 -0
- package/plugins/specweave-figma/commands/figma-tokens.md +815 -0
- package/plugins/specweave-frontend/.claude-plugin/plugin.json +21 -0
- package/plugins/specweave-frontend/agents/frontend-architect/AGENT.md +408 -0
- package/plugins/specweave-frontend/agents/frontend-architect/README.md +385 -0
- package/plugins/specweave-frontend/agents/frontend-architect/examples.md +590 -0
- package/plugins/specweave-frontend/agents/frontend-architect/templates/component-template.tsx +152 -0
- package/plugins/specweave-frontend/agents/frontend-architect/templates/hook-template.ts +311 -0
- package/plugins/specweave-frontend/agents/frontend-architect/templates/page-template.tsx +228 -0
- package/plugins/specweave-frontend/commands/component-generate.md +510 -0
- package/plugins/specweave-frontend/commands/design-system-init.md +494 -0
- package/plugins/specweave-frontend/commands/frontend-scaffold.md +207 -0
- package/plugins/specweave-frontend/commands/nextjs-setup.md +396 -0
- package/plugins/specweave-frontend/skills/design-system-architect/SKILL.md +278 -0
- package/plugins/specweave-frontend/skills/frontend/SKILL.md +420 -0
- package/plugins/specweave-frontend/skills/nextjs/SKILL.md +546 -0
- package/plugins/specweave-github/.claude-plugin/plugin.json +1 -1
- package/plugins/specweave-github/hooks/.specweave/logs/hooks-debug.log +212 -0
- package/plugins/specweave-infrastructure/.claude-plugin/plugin.json +1 -1
- package/plugins/specweave-jira/.claude-plugin/plugin.json +1 -1
- package/plugins/specweave-jira/commands/import-projects.js +183 -0
- package/plugins/specweave-jira/commands/import-projects.md +97 -0
- package/plugins/specweave-jira/commands/import-projects.ts +288 -0
- package/plugins/specweave-jira/commands/specweave-jira-import-projects.md +298 -0
- package/plugins/specweave-kafka/.claude-plugin/plugin.json +1 -1
- package/plugins/specweave-kafka-streams/.claude-plugin/plugin.json +1 -1
- package/plugins/specweave-kubernetes/commands/cluster-setup.md +262 -0
- package/plugins/specweave-kubernetes/commands/deployment-generate.md +242 -0
- package/plugins/specweave-kubernetes/commands/helm-scaffold.md +333 -0
- package/plugins/specweave-ml/.claude-plugin/plugin.json +1 -1
- package/plugins/specweave-mobile/commands/app-scaffold.md +233 -0
- package/plugins/specweave-mobile/commands/build-config.md +256 -0
- package/plugins/specweave-mobile/commands/screen-generate.md +289 -0
- package/plugins/specweave-n8n/.claude-plugin/plugin.json +1 -1
- package/plugins/specweave-payments/commands/stripe-setup.md +931 -0
- package/plugins/specweave-payments/commands/subscription-flow.md +1193 -0
- package/plugins/specweave-payments/commands/subscription-manage.md +386 -0
- package/plugins/specweave-payments/commands/webhook-setup.md +295 -0
- package/plugins/specweave-plugin-dev/.claude-plugin/plugin.json +13 -12
- package/plugins/specweave-plugin-dev/commands/plugin-create.md +333 -0
- package/plugins/specweave-plugin-dev/commands/plugin-publish.md +339 -0
- package/plugins/specweave-plugin-dev/commands/plugin-test.md +293 -0
- package/plugins/specweave-plugin-dev/skills/claude-sdk/SKILL.md +162 -0
- package/plugins/specweave-plugin-dev/skills/marketplace-publishing/SKILL.md +263 -0
- package/plugins/specweave-plugin-dev/skills/plugin-development/SKILL.md +316 -0
- package/plugins/specweave-release/.claude-plugin/plugin.json +1 -1
- package/plugins/specweave-release/commands/specweave-release-npm.md +110 -0
- package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +168 -0
- package/plugins/specweave-testing/.claude-plugin/plugin.json +21 -0
- package/plugins/specweave-testing/agents/qa-engineer/AGENT.md +818 -0
- package/plugins/specweave-testing/agents/qa-engineer/README.md +443 -0
- package/plugins/specweave-testing/agents/qa-engineer/templates/playwright-e2e-test.ts +470 -0
- package/plugins/specweave-testing/agents/qa-engineer/templates/test-data-factory.ts +507 -0
- package/plugins/specweave-testing/agents/qa-engineer/templates/vitest-unit-test.ts +400 -0
- package/plugins/specweave-testing/agents/qa-engineer/test-strategies.md +726 -0
- package/plugins/specweave-testing/commands/e2e-setup.md +1081 -0
- package/plugins/specweave-testing/commands/test-coverage.md +979 -0
- package/plugins/specweave-testing/commands/test-generate.md +1156 -0
- package/plugins/specweave-testing/commands/test-init.md +409 -0
- package/plugins/specweave-testing/skills/e2e-playwright/SKILL.md +769 -0
- package/plugins/specweave-testing/skills/tdd-expert/SKILL.md +934 -0
- package/plugins/specweave-testing/skills/unit-testing-expert/SKILL.md +1011 -0
- package/plugins/specweave-tooling/.claude-plugin/plugin.json +22 -0
- package/plugins/specweave-tooling/commands/specweave-tooling-skill-create.md +691 -0
- package/plugins/specweave-tooling/commands/specweave-tooling-skill-package.md +751 -0
- package/plugins/specweave-tooling/commands/specweave-tooling-skill-validate.md +858 -0
- package/plugins/specweave-ui/.claude-plugin/plugin.json +10 -0
- package/plugins/specweave-ui/commands/ui-automate.md +199 -0
- package/plugins/specweave-ui/commands/ui-inspect.md +70 -0
- package/plugins/specweave-ui/skills/browser-automation/SKILL.md +314 -0
- package/plugins/specweave-ui/skills/ui-testing/SKILL.md +716 -0
- package/plugins/specweave-ui/skills/visual-regression/SKILL.md +728 -0
- package/plugins/specweave/commands/check-hooks.md +0 -257
- package/plugins/specweave/commands/specweave-archive-increments.md +0 -82
- package/plugins/specweave-plugin-dev/skills/plugin-expert/SKILL.md +0 -1231
- /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!
|