vercel-labs/agent-skills / skills/vercel-optimize
vercel-optimize
VerifiedUse for Vercel cost and performance optimization on deployed projects, especially Next.js, SvelteKit, Nuxt, and limited Astro apps. Collect Vercel metrics, usage, project config, and code scan results first; investigate only metric-backed candidates; produce ranked recommendations grounded in verified files and version-aware Vercel/framework docs. Trigger for Vercel bill reduction, slow or expensive routes, caching opportunities, Function Invocations, Build Minutes, Fast Data Transfer, Core Web Vitals, Bot Management, Fluid compute, or cost breakdown requests.
lib/gates/uncached-route.mjs
View on GitHub// getShare>0.20 filter WHY: a route that's >80% POST/PUT/DELETE is a mutation endpoint
// where 0% cache is correct — recommending caching there is wrong.
// cache_result values STALE/REVALIDATED/BYPASS fold into "total but not HIT" — matches the "uncached" framing.
import { withRouteShapeWarnings } from '../route-normalize.mjs';
const MIN_GET_SHARE = 0.20;
/** @type {import('./types.d.ts').GateMetadata} */
export const metadata = {
id: 'uncached_route',
threshold: `requests > 500 AND hitRate < 0.5 AND getShare > ${MIN_GET_SHARE} (missing getShare is gated)`,
billingDimension: 'edge-requests',
scope: 'route',
sourceCitation: 'vercel-optimize gate threshold',
description:
'Routes serving > 500 requests/period at < 50% cache hit AND at least 20% GET traffic. Each uncached GET request reaches the function, costing edge requests + function duration. Routes that are mostly POST/PUT/DELETE (Server Actions, mutations) are skipped — 0% cache is correct behavior there. Routes with missing method-share data are gated instead of launched. Auth-gated routes are disqualified separately.',
};
/**
* @param {import('./types.d.ts').Signals} signals
* @returns {import('./types.d.ts').Candidate[]}
*/
export function gate(signals) {
const rates = extractCacheHitRates(signals);
const methods = extractMethodShares(signals);
return rates
.map((r) => ({ ...r, getShare: methods.get(r.route) ?? null }))
.filter((r) => r.requests > 500 && r.hitRate < 0.5)
.filter((r) => r.getShare === null || r.getShare > MIN_GET_SHARE)
.map((r) => {
const candidate = withRouteShapeWarnings({
kind: metadata.id,
scope: 'route',
route: r.route,
files: [],
priority: Math.round(r.requests * (1 - r.hitRate)),
confidence: r.getShare === null ? 0.5 : 0.92,
o11ySignal: `requests=${r.requests},cache=${(r.hitRate * 100).toFixed(0)}%${r.getShare !== null ? `,get=${(r.getShare * 100).toFixed(0)}%` : ''}`,
reason: 'uncached high-traffic route',
question: `Why does ${r.route} have ${(r.hitRate * 100).toFixed(0)}% cache hit rate on ${r.requests} requests in this metrics window, and is it safe to cache at the edge?`,
evidence: { metric: 'requestsByRouteCache', route: r.route, requests: r.requests, hitRate: r.hitRate, getShare: r.getShare },
}, signals);
if (r.getShare !== null) return candidate;
return {
...candidate,
disqualified: true,
disqualifyReason: 'missing GET-share data — route method mix is required before recommending edge caching',
warnings: [...new Set([...(candidate.warnings ?? []), 'method-share:missing'])],
};
});
}
function extractCacheHitRates(signals) {
const m = signals.metrics?.requestsByRouteCache;
if (!m?.ok && !Array.isArray(m?.rows)) return [];
const perRoute = new Map();
for (const row of (m?.rows ?? [])) {
const route = row.route;
if (!route) continue;
const value = row.value ?? 0;
const prior = perRoute.get(route) ?? { route, hits: 0, total: 0 };
if (row.cache_result === 'HIT') prior.hits += value;
prior.total += value;
perRoute.set(route, prior);
}
return [...perRoute.values()].map((r) => ({
route: r.route,
requests: r.total,
hitRate: r.total > 0 ? r.hits / r.total : 0,
}));
}
function extractMethodShares(signals) {
const m = signals.metrics?.requestsByRouteMethod;
const out = new Map();
if (!Array.isArray(m?.rows)) return out;
const perRoute = new Map();
for (const row of m.rows) {
if (!row?.route) continue;
const v = row.value ?? 0;
const prior = perRoute.get(row.route) ?? { gets: 0, total: 0 };
if ((row.request_method ?? '').toUpperCase() === 'GET') prior.gets += v;
prior.total += v;
perRoute.set(row.route, prior);
}
for (const [route, r] of perRoute) {
if (r.total > 0) out.set(route, r.gets / r.total);
}
return out;
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |