@patricio0312rev/skillset 0.1.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.
- package/CHANGELOG.md +29 -0
- package/LICENSE +21 -0
- package/README.md +176 -0
- package/bin/cli.js +37 -0
- package/package.json +55 -0
- package/src/commands/init.js +301 -0
- package/src/index.js +168 -0
- package/src/lib/config.js +200 -0
- package/src/lib/generator.js +166 -0
- package/src/utils/display.js +95 -0
- package/src/utils/readme.js +196 -0
- package/src/utils/tool-specific.js +233 -0
- package/templates/ai-engineering/agent-orchestration-planner/ SKILL.md +266 -0
- package/templates/ai-engineering/cost-latency-optimizer/ SKILL.md +270 -0
- package/templates/ai-engineering/doc-to-vector-dataset-generator/ SKILL.md +239 -0
- package/templates/ai-engineering/evaluation-harness/ SKILL.md +219 -0
- package/templates/ai-engineering/guardrails-safety-filter-builder/ SKILL.md +226 -0
- package/templates/ai-engineering/llm-debugger/ SKILL.md +283 -0
- package/templates/ai-engineering/prompt-regression-tester/ SKILL.md +216 -0
- package/templates/ai-engineering/prompt-template-builder/ SKILL.md +393 -0
- package/templates/ai-engineering/rag-pipeline-builder/ SKILL.md +244 -0
- package/templates/ai-engineering/tool-function-schema-designer/ SKILL.md +219 -0
- package/templates/architecture/adr-writer/ SKILL.md +250 -0
- package/templates/architecture/api-versioning-deprecation-planner/ SKILL.md +331 -0
- package/templates/architecture/domain-model-boundaries-mapper/ SKILL.md +300 -0
- package/templates/architecture/migration-planner/ SKILL.md +376 -0
- package/templates/architecture/performance-budget-setter/ SKILL.md +318 -0
- package/templates/architecture/reliability-strategy-builder/ SKILL.md +286 -0
- package/templates/architecture/rfc-generator/ SKILL.md +362 -0
- package/templates/architecture/scalability-playbook/ SKILL.md +279 -0
- package/templates/architecture/system-design-generator/ SKILL.md +339 -0
- package/templates/architecture/tech-debt-prioritizer/ SKILL.md +329 -0
- package/templates/backend/api-contract-normalizer/ SKILL.md +487 -0
- package/templates/backend/api-endpoint-generator/ SKILL.md +415 -0
- package/templates/backend/auth-module-builder/ SKILL.md +99 -0
- package/templates/backend/background-jobs-designer/ SKILL.md +166 -0
- package/templates/backend/caching-strategist/ SKILL.md +190 -0
- package/templates/backend/error-handling-standardizer/ SKILL.md +174 -0
- package/templates/backend/rate-limiting-abuse-protection/ SKILL.md +147 -0
- package/templates/backend/rbac-permissions-builder/ SKILL.md +158 -0
- package/templates/backend/service-layer-extractor/ SKILL.md +269 -0
- package/templates/backend/webhook-receiver-hardener/ SKILL.md +211 -0
- package/templates/ci-cd/artifact-sbom-publisher/ SKILL.md +236 -0
- package/templates/ci-cd/caching-strategy-optimizer/ SKILL.md +195 -0
- package/templates/ci-cd/deployment-checklist-generator/ SKILL.md +381 -0
- package/templates/ci-cd/github-actions-pipeline-creator/ SKILL.md +348 -0
- package/templates/ci-cd/monorepo-ci-optimizer/ SKILL.md +298 -0
- package/templates/ci-cd/preview-environments-builder/ SKILL.md +187 -0
- package/templates/ci-cd/quality-gates-enforcer/ SKILL.md +342 -0
- package/templates/ci-cd/release-automation-builder/ SKILL.md +281 -0
- package/templates/ci-cd/rollback-workflow-builder/ SKILL.md +372 -0
- package/templates/ci-cd/secrets-env-manager/ SKILL.md +242 -0
- package/templates/db-management/backup-restore-runbook-generator/ SKILL.md +505 -0
- package/templates/db-management/data-integrity-auditor/ SKILL.md +505 -0
- package/templates/db-management/data-retention-archiving-planner/ SKILL.md +430 -0
- package/templates/db-management/data-seeding-fixtures-builder/ SKILL.md +375 -0
- package/templates/db-management/db-performance-watchlist/ SKILL.md +425 -0
- package/templates/db-management/etl-sync-job-builder/ SKILL.md +457 -0
- package/templates/db-management/multi-tenant-safety-checker/ SKILL.md +398 -0
- package/templates/db-management/prisma-migration-assistant/ SKILL.md +379 -0
- package/templates/db-management/schema-consistency-checker/ SKILL.md +440 -0
- package/templates/db-management/sql-query-optimizer/ SKILL.md +324 -0
- package/templates/foundation/changelog-writer/ SKILL.md +431 -0
- package/templates/foundation/code-formatter-installer/ SKILL.md +320 -0
- package/templates/foundation/codebase-summarizer/ SKILL.md +360 -0
- package/templates/foundation/dependency-doctor/ SKILL.md +163 -0
- package/templates/foundation/dev-environment-bootstrapper/ SKILL.md +259 -0
- package/templates/foundation/dev-onboarding-builder/ SKILL.md +556 -0
- package/templates/foundation/docs-starter-kit/ SKILL.md +574 -0
- package/templates/foundation/explaining-code/SKILL.md +13 -0
- package/templates/foundation/git-hygiene-enforcer/ SKILL.md +455 -0
- package/templates/foundation/project-scaffolder/ SKILL.md +65 -0
- package/templates/foundation/project-scaffolder/references/templates.md +126 -0
- package/templates/foundation/repo-structure-linter/ SKILL.md +0 -0
- package/templates/foundation/repo-structure-linter/references/conventions.md +98 -0
- package/templates/frontend/animation-micro-interaction-pack/ SKILL.md +41 -0
- package/templates/frontend/component-scaffold-generator/ SKILL.md +562 -0
- package/templates/frontend/design-to-component-translator/ SKILL.md +547 -0
- package/templates/frontend/form-wizard-builder/ SKILL.md +553 -0
- package/templates/frontend/frontend-refactor-planner/ SKILL.md +37 -0
- package/templates/frontend/i18n-frontend-implementer/ SKILL.md +44 -0
- package/templates/frontend/modal-drawer-system/ SKILL.md +377 -0
- package/templates/frontend/page-layout-builder/ SKILL.md +630 -0
- package/templates/frontend/state-ux-flow-builder/ SKILL.md +23 -0
- package/templates/frontend/table-builder/ SKILL.md +350 -0
- package/templates/performance/alerting-dashboard-builder/ SKILL.md +162 -0
- package/templates/performance/backend-latency-profiler-helper/ SKILL.md +108 -0
- package/templates/performance/caching-cdn-strategy-planner/ SKILL.md +150 -0
- package/templates/performance/capacity-planning-helper/ SKILL.md +242 -0
- package/templates/performance/core-web-vitals-tuner/ SKILL.md +126 -0
- package/templates/performance/incident-runbook-generator/ SKILL.md +162 -0
- package/templates/performance/load-test-scenario-builder/ SKILL.md +256 -0
- package/templates/performance/observability-setup/ SKILL.md +232 -0
- package/templates/performance/postmortem-writer/ SKILL.md +203 -0
- package/templates/performance/structured-logging-standardizer/ SKILL.md +122 -0
- package/templates/security/auth-security-reviewer/ SKILL.md +428 -0
- package/templates/security/dependency-vulnerability-triage/ SKILL.md +495 -0
- package/templates/security/input-validation-sanitization-auditor/ SKILL.md +76 -0
- package/templates/security/pii-redaction-logging-policy-builder/ SKILL.md +65 -0
- package/templates/security/rbac-policy-tester/ SKILL.md +80 -0
- package/templates/security/secrets-scanner/ SKILL.md +462 -0
- package/templates/security/secure-headers-csp-builder/ SKILL.md +404 -0
- package/templates/security/security-incident-playbook-generator/ SKILL.md +76 -0
- package/templates/security/security-pr-checklist-skill/ SKILL.md +62 -0
- package/templates/security/threat-model-generator/ SKILL.md +394 -0
- package/templates/testing/contract-testing-builder/ SKILL.md +492 -0
- package/templates/testing/coverage-strategist/ SKILL.md +436 -0
- package/templates/testing/e2e-test-builder/ SKILL.md +382 -0
- package/templates/testing/flaky-test-detective/ SKILL.md +416 -0
- package/templates/testing/integration-test-builder/ SKILL.md +525 -0
- package/templates/testing/mocking-assistant/ SKILL.md +383 -0
- package/templates/testing/snapshot-test-refactorer/ SKILL.md +375 -0
- package/templates/testing/test-data-factory-builder/ SKILL.md +449 -0
- package/templates/testing/test-reporting-triage-skill/ SKILL.md +469 -0
- package/templates/testing/unit-test-generator/ SKILL.md +548 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: caching-cdn-strategy-planner
|
|
3
|
+
description: Designs multi-layer caching strategy with edge CDN, server-side caching, cache invalidation, and CDN configuration. Use for "caching strategy", "CDN setup", "cache invalidation", or "performance optimization".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Caching & CDN Strategy Planner
|
|
7
|
+
|
|
8
|
+
Design effective caching at all layers.
|
|
9
|
+
|
|
10
|
+
## Caching Layers
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
Client → CDN (Edge) → Server Cache → Database
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## CDN Configuration (CloudFront)
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
const distribution = {
|
|
20
|
+
Origins: [
|
|
21
|
+
{
|
|
22
|
+
DomainName: "api.example.com",
|
|
23
|
+
CustomHeaders: [
|
|
24
|
+
{
|
|
25
|
+
HeaderName: "X-CDN-Secret",
|
|
26
|
+
HeaderValue: process.env.CDN_SECRET,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
DefaultCacheBehavior: {
|
|
32
|
+
ViewerProtocolPolicy: "redirect-to-https",
|
|
33
|
+
AllowedMethods: ["GET", "HEAD", "OPTIONS"],
|
|
34
|
+
CachedMethods: ["GET", "HEAD"],
|
|
35
|
+
Compress: true,
|
|
36
|
+
DefaultTTL: 86400, // 1 day
|
|
37
|
+
MaxTTL: 31536000, // 1 year
|
|
38
|
+
MinTTL: 0,
|
|
39
|
+
ForwardedValues: {
|
|
40
|
+
QueryString: true,
|
|
41
|
+
Cookies: { Forward: "none" },
|
|
42
|
+
Headers: ["Accept", "Accept-Encoding"],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
CacheBehaviors: [
|
|
46
|
+
{
|
|
47
|
+
PathPattern: "/api/static/*",
|
|
48
|
+
DefaultTTL: 31536000, // 1 year - never changes
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
PathPattern: "/api/dynamic/*",
|
|
52
|
+
DefaultTTL: 300, // 5 min - changes frequently
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Server-side Caching (Redis)
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import Redis from 'ioredis';
|
|
62
|
+
|
|
63
|
+
const redis = new Redis(process.env.REDIS_URL);
|
|
64
|
+
|
|
65
|
+
async function getCachedOrFetch<T>(
|
|
66
|
+
key: string,
|
|
67
|
+
fetcher: () => Promise<T>,
|
|
68
|
+
ttl: number = 3600
|
|
69
|
+
): Promise<T> {
|
|
70
|
+
// Try cache
|
|
71
|
+
const cached = await redis.get(key);
|
|
72
|
+
if (cached) {
|
|
73
|
+
return JSON.parse(cached);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Fetch and cache
|
|
77
|
+
const data = await fetcher();
|
|
78
|
+
await redis.setex(key, ttl, JSON.stringify(data));
|
|
79
|
+
|
|
80
|
+
return data;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Usage
|
|
84
|
+
app.get('/api/user/:id', async (req, res) => {
|
|
85
|
+
const user = await getCachedOrFetch(
|
|
86
|
+
\`user:\${req.params.id}\`,
|
|
87
|
+
() => prisma.user.findUnique({ where: { id: req.params.id } }),
|
|
88
|
+
3600
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
res.json(user);
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Cache Invalidation
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
// Invalidate on update
|
|
99
|
+
app.put('/api/user/:id', async (req, res) => {
|
|
100
|
+
const user = await prisma.user.update({
|
|
101
|
+
where: { id: req.params.id },
|
|
102
|
+
data: req.body,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// Invalidate cache
|
|
106
|
+
await redis.del(\`user:\${req.params.id}\`);
|
|
107
|
+
|
|
108
|
+
// Invalidate CDN
|
|
109
|
+
await cloudfront.createInvalidation({
|
|
110
|
+
DistributionId: DISTRIBUTION_ID,
|
|
111
|
+
InvalidationBatch: {
|
|
112
|
+
Paths: { Items: [\`/api/user/\${req.params.id}\`] },
|
|
113
|
+
CallerReference: Date.now().toString(),
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
res.json(user);
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Cache Headers
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
app.get("/api/products", (req, res) => {
|
|
125
|
+
res.set({
|
|
126
|
+
"Cache-Control": "public, max-age=3600", // Browser + CDN: 1h
|
|
127
|
+
ETag: generateETag(products),
|
|
128
|
+
"Last-Modified": new Date(products.updatedAt).toUTCString(),
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
res.json(products);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
app.get("/api/user/profile", (req, res) => {
|
|
135
|
+
res.set({
|
|
136
|
+
"Cache-Control": "private, no-cache", // No caching (sensitive)
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
res.json(profile);
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Output Checklist
|
|
144
|
+
|
|
145
|
+
- [ ] CDN configured
|
|
146
|
+
- [ ] Server cache implemented
|
|
147
|
+
- [ ] Invalidation strategy
|
|
148
|
+
- [ ] Cache headers set
|
|
149
|
+
- [ ] Monitoring configured
|
|
150
|
+
ENDFILE
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: capacity-planning-helper
|
|
3
|
+
description: Estimates infrastructure needs based on traffic forecasts, workload analysis, and performance requirements with sizing recommendations and cost trade-offs. Use for "capacity planning", "infrastructure sizing", "resource estimation", or "scalability planning".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Capacity Planning Helper
|
|
7
|
+
|
|
8
|
+
Right-size infrastructure for current and future needs.
|
|
9
|
+
|
|
10
|
+
## Traffic Forecasting
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
interface TrafficForecast {
|
|
14
|
+
current: {
|
|
15
|
+
dailyUsers: number;
|
|
16
|
+
peakRPS: number;
|
|
17
|
+
avgRPS: number;
|
|
18
|
+
};
|
|
19
|
+
projected: {
|
|
20
|
+
timeframe: "6m" | "12m" | "24m";
|
|
21
|
+
dailyUsers: number;
|
|
22
|
+
peakRPS: number;
|
|
23
|
+
avgRPS: number;
|
|
24
|
+
growthRate: number;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const forecast: TrafficForecast = {
|
|
29
|
+
current: {
|
|
30
|
+
dailyUsers: 100000,
|
|
31
|
+
peakRPS: 500,
|
|
32
|
+
avgRPS: 200,
|
|
33
|
+
},
|
|
34
|
+
projected: {
|
|
35
|
+
timeframe: "12m",
|
|
36
|
+
dailyUsers: 500000, // 5x growth
|
|
37
|
+
peakRPS: 2500,
|
|
38
|
+
avgRPS: 1000,
|
|
39
|
+
growthRate: 4.0, // 400% growth
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Resource Estimation
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
interface ResourceNeeds {
|
|
48
|
+
compute: {
|
|
49
|
+
instanceType: string;
|
|
50
|
+
instanceCount: number;
|
|
51
|
+
cpu: number;
|
|
52
|
+
memory: number;
|
|
53
|
+
};
|
|
54
|
+
database: {
|
|
55
|
+
instanceType: string;
|
|
56
|
+
instanceCount: number;
|
|
57
|
+
storage: number;
|
|
58
|
+
iops: number;
|
|
59
|
+
};
|
|
60
|
+
cache: {
|
|
61
|
+
instanceType: string;
|
|
62
|
+
nodes: number;
|
|
63
|
+
memory: number;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function estimateResources(forecast: TrafficForecast): ResourceNeeds {
|
|
68
|
+
const { peakRPS } = forecast.projected;
|
|
69
|
+
|
|
70
|
+
// Rule of thumb: 100 RPS per instance (with headroom)
|
|
71
|
+
const instanceCount = Math.ceil(peakRPS / 100);
|
|
72
|
+
|
|
73
|
+
// Database: 1000 connections per 2vCPU
|
|
74
|
+
const dbInstances = Math.ceil((peakRPS * 2) / 1000);
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
compute: {
|
|
78
|
+
instanceType: "t3.large",
|
|
79
|
+
instanceCount: instanceCount * 1.5, // 50% headroom
|
|
80
|
+
cpu: 2 * instanceCount,
|
|
81
|
+
memory: 8 * instanceCount,
|
|
82
|
+
},
|
|
83
|
+
database: {
|
|
84
|
+
instanceType: "db.r6g.xlarge",
|
|
85
|
+
instanceCount: dbInstances,
|
|
86
|
+
storage: 1000, // GB
|
|
87
|
+
iops: 10000,
|
|
88
|
+
},
|
|
89
|
+
cache: {
|
|
90
|
+
instanceType: "cache.r6g.large",
|
|
91
|
+
nodes: 2, // Primary + replica
|
|
92
|
+
memory: 12, // GB
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Cost Estimation
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
interface CostEstimate {
|
|
102
|
+
monthly: {
|
|
103
|
+
compute: number;
|
|
104
|
+
database: number;
|
|
105
|
+
cache: number;
|
|
106
|
+
storage: number;
|
|
107
|
+
bandwidth: number;
|
|
108
|
+
total: number;
|
|
109
|
+
};
|
|
110
|
+
annual: number;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const pricing = {
|
|
114
|
+
"t3.large": 0.0832, // $/hour
|
|
115
|
+
"db.r6g.xlarge": 0.336,
|
|
116
|
+
"cache.r6g.large": 0.226,
|
|
117
|
+
storage: 0.1, // $/GB/month
|
|
118
|
+
bandwidth: 0.09, // $/GB
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
function estimateCost(
|
|
122
|
+
resources: ResourceNeeds,
|
|
123
|
+
trafficGB: number
|
|
124
|
+
): CostEstimate {
|
|
125
|
+
const hoursPerMonth = 730;
|
|
126
|
+
|
|
127
|
+
const monthly = {
|
|
128
|
+
compute:
|
|
129
|
+
resources.compute.instanceCount * pricing["t3.large"] * hoursPerMonth,
|
|
130
|
+
database:
|
|
131
|
+
resources.database.instanceCount *
|
|
132
|
+
pricing["db.r6g.xlarge"] *
|
|
133
|
+
hoursPerMonth,
|
|
134
|
+
cache: resources.cache.nodes * pricing["cache.r6g.large"] * hoursPerMonth,
|
|
135
|
+
storage: resources.database.storage * pricing.storage,
|
|
136
|
+
bandwidth: trafficGB * pricing.bandwidth,
|
|
137
|
+
total: 0,
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
monthly.total = Object.values(monthly).reduce((sum, cost) => sum + cost, 0);
|
|
141
|
+
|
|
142
|
+
return {
|
|
143
|
+
monthly,
|
|
144
|
+
annual: monthly.total * 12,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Scale Triggers
|
|
150
|
+
|
|
151
|
+
```yaml
|
|
152
|
+
# auto-scaling-config.yml
|
|
153
|
+
scaling:
|
|
154
|
+
triggers:
|
|
155
|
+
- metric: cpu_utilization
|
|
156
|
+
threshold: 70%
|
|
157
|
+
action: scale_up
|
|
158
|
+
cooldown: 5m
|
|
159
|
+
|
|
160
|
+
- metric: cpu_utilization
|
|
161
|
+
threshold: 30%
|
|
162
|
+
action: scale_down
|
|
163
|
+
cooldown: 15m
|
|
164
|
+
|
|
165
|
+
- metric: request_queue_depth
|
|
166
|
+
threshold: 1000
|
|
167
|
+
action: scale_up
|
|
168
|
+
cooldown: 1m
|
|
169
|
+
|
|
170
|
+
limits:
|
|
171
|
+
min_instances: 2
|
|
172
|
+
max_instances: 20
|
|
173
|
+
|
|
174
|
+
schedule:
|
|
175
|
+
# Pre-scale for known traffic patterns
|
|
176
|
+
- time: "08:00"
|
|
177
|
+
target_instances: 10
|
|
178
|
+
- time: "22:00"
|
|
179
|
+
target_instances: 4
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Cost/Performance Tradeoffs
|
|
183
|
+
|
|
184
|
+
```markdown
|
|
185
|
+
# Infrastructure Options
|
|
186
|
+
|
|
187
|
+
## Option 1: Cost-Optimized ($2,500/mo)
|
|
188
|
+
|
|
189
|
+
- Compute: 4x t3.large
|
|
190
|
+
- Database: 1x db.r6g.large
|
|
191
|
+
- Cache: 1x cache.r6g.medium
|
|
192
|
+
- **Pros:** Lowest cost
|
|
193
|
+
- **Cons:** Limited headroom, potential latency issues
|
|
194
|
+
|
|
195
|
+
## Option 2: Balanced ($5,000/mo)
|
|
196
|
+
|
|
197
|
+
- Compute: 8x t3.large
|
|
198
|
+
- Database: 2x db.r6g.xlarge
|
|
199
|
+
- Cache: 2x cache.r6g.large
|
|
200
|
+
- **Pros:** Good headroom, redundancy
|
|
201
|
+
- **Cons:** Moderate cost
|
|
202
|
+
|
|
203
|
+
## Option 3: Performance-Optimized ($10,000/mo)
|
|
204
|
+
|
|
205
|
+
- Compute: 12x c6g.xlarge
|
|
206
|
+
- Database: 3x db.r6g.2xlarge
|
|
207
|
+
- Cache: 3x cache.r6g.xlarge
|
|
208
|
+
- **Pros:** Maximum performance, high availability
|
|
209
|
+
- **Cons:** Higher cost
|
|
210
|
+
|
|
211
|
+
## Recommendation
|
|
212
|
+
|
|
213
|
+
Start with Option 2, monitor for 1 month, adjust based on:
|
|
214
|
+
|
|
215
|
+
- Actual CPU/memory utilization
|
|
216
|
+
- Database query performance
|
|
217
|
+
- Cache hit rates
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Capacity Planning Spreadsheet
|
|
221
|
+
|
|
222
|
+
```
|
|
223
|
+
| Metric | Current | 6mo Proj | 12mo Proj | Notes |
|
|
224
|
+
|---------------------|---------|----------|-----------|--------------------------|
|
|
225
|
+
| Daily Users | 100k | 250k | 500k | 5x growth expected |
|
|
226
|
+
| Peak RPS | 500 | 1250 | 2500 | Linear w/ users |
|
|
227
|
+
| DB Connections | 100 | 250 | 500 | 2 per instance |
|
|
228
|
+
| Storage (GB) | 100 | 300 | 1000 | User data + logs |
|
|
229
|
+
| Bandwidth (TB) | 1 | 3 | 10 | Images + video |
|
|
230
|
+
| Instance Count | 4 | 10 | 20 | Auto-scaling |
|
|
231
|
+
| Monthly Cost | $2k | $5k | $10k | AWS estimate |
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Output Checklist
|
|
235
|
+
|
|
236
|
+
- [ ] Traffic forecast
|
|
237
|
+
- [ ] Resource estimates
|
|
238
|
+
- [ ] Cost analysis
|
|
239
|
+
- [ ] Scale triggers
|
|
240
|
+
- [ ] Performance targets
|
|
241
|
+
- [ ] Growth plan
|
|
242
|
+
ENDFILE
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: core-web-vitals-tuner
|
|
3
|
+
description: Systematically improves Largest Contentful Paint (LCP), Interaction to Next Paint (INP), and Cumulative Layout Shift (CLS) with prioritized fixes and verification. Use for "Core Web Vitals", "performance", "LCP", "INP", or "CLS".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Core Web Vitals Tuner
|
|
7
|
+
|
|
8
|
+
Improve LCP, INP, and CLS systematically.
|
|
9
|
+
|
|
10
|
+
## LCP Optimization (<2.5s)
|
|
11
|
+
|
|
12
|
+
**Prioritized Fixes:**
|
|
13
|
+
|
|
14
|
+
1. **Optimize images** (Biggest impact)
|
|
15
|
+
|
|
16
|
+
```html
|
|
17
|
+
<!-- Before -->
|
|
18
|
+
<img src="hero.jpg" />
|
|
19
|
+
|
|
20
|
+
<!-- After -->
|
|
21
|
+
<img
|
|
22
|
+
src="hero.jpg"
|
|
23
|
+
srcset="hero-400.webp 400w, hero-800.webp 800w, hero-1200.webp 1200w"
|
|
24
|
+
sizes="(max-width: 600px) 400px, (max-width: 1200px) 800px, 1200px"
|
|
25
|
+
loading="eager"
|
|
26
|
+
fetchpriority="high"
|
|
27
|
+
/>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
2. **Preload LCP resource**
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
<link rel="preload" as="image" href="/hero.webp" fetchpriority="high" />
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
3. **Inline critical CSS**
|
|
37
|
+
|
|
38
|
+
```html
|
|
39
|
+
<style>
|
|
40
|
+
/* Above-the-fold styles */
|
|
41
|
+
.hero {
|
|
42
|
+
display: flex;
|
|
43
|
+
height: 100vh;
|
|
44
|
+
}
|
|
45
|
+
</style>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
4. **Use CDN**
|
|
49
|
+
- Serve images from CloudFront/Cloudflare
|
|
50
|
+
- Enable HTTP/2 or HTTP/3
|
|
51
|
+
|
|
52
|
+
## INP Optimization (<200ms)
|
|
53
|
+
|
|
54
|
+
**Fixes:**
|
|
55
|
+
|
|
56
|
+
1. **Debounce expensive interactions**
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { debounce } from "lodash";
|
|
60
|
+
|
|
61
|
+
const handleSearch = debounce((query) => {
|
|
62
|
+
fetchResults(query);
|
|
63
|
+
}, 300);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
2. **Use Web Workers for heavy tasks**
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
const worker = new Worker("processor.js");
|
|
70
|
+
worker.postMessage(largeData);
|
|
71
|
+
worker.onmessage = (e) => console.log(e.data);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
3. **Code splitting**
|
|
75
|
+
```typescript
|
|
76
|
+
const HeavyComponent = lazy(() => import("./HeavyComponent"));
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## CLS Optimization (<0.1)
|
|
80
|
+
|
|
81
|
+
**Fixes:**
|
|
82
|
+
|
|
83
|
+
1. **Reserve space for images/ads**
|
|
84
|
+
|
|
85
|
+
```html
|
|
86
|
+
<img src="banner.jpg" width="1200" height="600" />
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
2. **Use CSS aspect-ratio**
|
|
90
|
+
|
|
91
|
+
```css
|
|
92
|
+
.video-container {
|
|
93
|
+
aspect-ratio: 16 / 9;
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
3. **Avoid injecting content above existing**
|
|
98
|
+
```css
|
|
99
|
+
.notification {
|
|
100
|
+
position: fixed;
|
|
101
|
+
top: 0;
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Verification
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Lighthouse CI
|
|
109
|
+
npm run lighthouse -- --url=https://example.com
|
|
110
|
+
|
|
111
|
+
# Web Vitals in production
|
|
112
|
+
import { getCLS, getFID, getLCP } from 'web-vitals';
|
|
113
|
+
|
|
114
|
+
getCLS(console.log);
|
|
115
|
+
getFID(console.log);
|
|
116
|
+
getLCP(console.log);
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Output Checklist
|
|
120
|
+
|
|
121
|
+
- [ ] LCP optimized (<2.5s)
|
|
122
|
+
- [ ] INP optimized (<200ms)
|
|
123
|
+
- [ ] CLS optimized (<0.1)
|
|
124
|
+
- [ ] Monitoring in place
|
|
125
|
+
- [ ] Performance regression tests
|
|
126
|
+
ENDFILE
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: incident-runbook-generator
|
|
3
|
+
description: Creates step-by-step incident response runbooks for common outages with actions, owners, rollback procedures, and communication templates. Use for "incident runbook", "outage response", "incident management", or "on-call procedures".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Incident Runbook Generator
|
|
7
|
+
|
|
8
|
+
Create actionable runbooks for common incidents.
|
|
9
|
+
|
|
10
|
+
## Runbook Template
|
|
11
|
+
|
|
12
|
+
````markdown
|
|
13
|
+
# Runbook: Database Connection Pool Exhausted
|
|
14
|
+
|
|
15
|
+
**Severity:** P1 (Critical)
|
|
16
|
+
**Estimated Time to Resolve:** 15-30 minutes
|
|
17
|
+
**Owner:** Database Team (On-call)
|
|
18
|
+
|
|
19
|
+
## Symptoms
|
|
20
|
+
|
|
21
|
+
- Application errors: "connection pool exhausted"
|
|
22
|
+
- Increased API latency (>5s)
|
|
23
|
+
- Failed health checks
|
|
24
|
+
- CloudWatch alarm: `DatabaseConnectionsHigh`
|
|
25
|
+
|
|
26
|
+
## Detection
|
|
27
|
+
|
|
28
|
+
- Alert: DatabaseConnectionPoolExhausted
|
|
29
|
+
- Metrics: `active_connections > max_connections * 0.9`
|
|
30
|
+
- Logs: "Error: connect ETIMEDOUT"
|
|
31
|
+
|
|
32
|
+
## Immediate Actions (5 min)
|
|
33
|
+
|
|
34
|
+
1. **Verify the issue**
|
|
35
|
+
```bash
|
|
36
|
+
# Check current connections
|
|
37
|
+
SELECT count(*) FROM pg_stat_activity;
|
|
38
|
+
```
|
|
39
|
+
````
|
|
40
|
+
|
|
41
|
+
2. **Identify long-running queries**
|
|
42
|
+
|
|
43
|
+
```sql
|
|
44
|
+
SELECT pid, now() - pg_stat_activity.query_start AS duration, query
|
|
45
|
+
FROM pg_stat_activity
|
|
46
|
+
WHERE state = 'active'
|
|
47
|
+
ORDER BY duration DESC
|
|
48
|
+
LIMIT 10;
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
3. **Kill blocking queries** (if safe)
|
|
52
|
+
```sql
|
|
53
|
+
SELECT pg_terminate_backend(pid)
|
|
54
|
+
FROM pg_stat_activity
|
|
55
|
+
WHERE state = 'idle in transaction'
|
|
56
|
+
AND now() - state_change > interval '5 minutes';
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Mitigation (10 min)
|
|
60
|
+
|
|
61
|
+
1. **Scale up connection pool** (temporary)
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Update RDS parameter group
|
|
65
|
+
aws rds modify-db-parameter-group \
|
|
66
|
+
--db-parameter-group-name prod-params \
|
|
67
|
+
--parameters "ParameterName=max_connections,ParameterValue=200"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
2. **Restart application** (if needed)
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
kubectl rollout restart deployment/api
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
3. **Monitor recovery**
|
|
77
|
+
```bash
|
|
78
|
+
watch -n 5 'psql -c "SELECT count(*) FROM pg_stat_activity;"'
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Root Cause Investigation
|
|
82
|
+
|
|
83
|
+
Check for:
|
|
84
|
+
|
|
85
|
+
- [ ] Recent deployment (new code with connection leaks)
|
|
86
|
+
- [ ] Traffic spike (legitimate or DDoS)
|
|
87
|
+
- [ ] Slow queries holding connections
|
|
88
|
+
- [ ] Connection pool configuration too small
|
|
89
|
+
- [ ] Application not releasing connections
|
|
90
|
+
|
|
91
|
+
## Rollback Steps
|
|
92
|
+
|
|
93
|
+
If caused by deployment:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# Rollback to previous version
|
|
97
|
+
kubectl rollout undo deployment/api
|
|
98
|
+
|
|
99
|
+
# Verify
|
|
100
|
+
kubectl rollout status deployment/api
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Communication Template
|
|
104
|
+
|
|
105
|
+
**Initial (within 5 min):**
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
🚨 INCIDENT: Database connection pool exhausted
|
|
109
|
+
Status: Investigating
|
|
110
|
+
Impact: API errors and slowness
|
|
111
|
+
ETA: 15-30 min
|
|
112
|
+
Next update: 10 min
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Update (every 10 min):**
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
UPDATE: Killed long-running queries
|
|
119
|
+
Status: Mitigating
|
|
120
|
+
Impact: Still degraded, improving
|
|
121
|
+
Actions: Scaling connection pool
|
|
122
|
+
Next update: 10 min
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Resolution:**
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
✅ RESOLVED: Database connections normalized
|
|
129
|
+
Duration: 25 minutes
|
|
130
|
+
Root cause: Connection leak in v2.3.4
|
|
131
|
+
Fix: Rolled back to v2.3.3
|
|
132
|
+
Follow-up: Bug fix PR #1234
|
|
133
|
+
Postmortem: [link]
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Prevention
|
|
137
|
+
|
|
138
|
+
- [ ] Add connection pool metrics to dashboards
|
|
139
|
+
- [ ] Implement connection timeout (30s)
|
|
140
|
+
- [ ] Add connection leak detection in tests
|
|
141
|
+
- [ ] Set up pre-deployment load testing
|
|
142
|
+
- [ ] Review connection pool sizing
|
|
143
|
+
|
|
144
|
+
## Related Runbooks
|
|
145
|
+
|
|
146
|
+
- Database High CPU
|
|
147
|
+
- Slow Database Queries
|
|
148
|
+
- Application OOM
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Output Checklist
|
|
153
|
+
|
|
154
|
+
- [ ] Symptoms documented
|
|
155
|
+
- [ ] Detection criteria
|
|
156
|
+
- [ ] Step-by-step actions
|
|
157
|
+
- [ ] Owner assigned
|
|
158
|
+
- [ ] Rollback procedure
|
|
159
|
+
- [ ] Communication templates
|
|
160
|
+
- [ ] Prevention measures
|
|
161
|
+
ENDFILE
|
|
162
|
+
```
|