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/select-candidates.mjs
View on GitHub// Deterministic launch selection for the code-scope investigation budget.
//
// Raw priority still orders candidates inside each pass. The default budget is
// impact-first, with failure-mode diversity when a kind's top signal is large
// enough to justify taking a first-pass slot.
const DEFAULT_KIND_CAPS = new Map([
['slow_route', 2],
['uncached_route', 2],
['route_errors', 2],
]);
const DIVERSITY_ELIGIBILITY = new Map([
// A handful of 5xx errors can pass the route_errors gate because the rate is
// high, but that should not displace much larger cost/performance signals in
// the default six-candidate pass.
['route_errors', (candidate) => numberFromEvidence(candidate, 'count') >= 1000],
// Scanner-driven cache findings are valuable, but the default pass should
// spend a slot only when observability shows meaningful route traffic or a
// very slow route handler.
['cache_header_gap', (candidate) => {
const invocations = numberFromSignal(candidate?.o11ySignal, 'inv');
const p95Ms = durationMsFromSignal(candidate?.o11ySignal, 'p95');
return invocations >= 50_000 || p95Ms >= 2000;
}],
['rendering_candidate', (candidate) => numberFromSignal(candidate?.o11ySignal, 'inv') >= 50_000],
]);
export function selectLaunchCandidates(candidates, budget, { diversify = false } = {}) {
const pool = Array.isArray(candidates) ? candidates : [];
if (budget === Infinity) {
return { selected: pool, skipped: [], selectionMode: 'all' };
}
if (!Number.isInteger(budget) || budget < 1) {
throw new TypeError('selectLaunchCandidates budget must be a positive integer or Infinity');
}
if (!diversify) {
return {
selected: pool.slice(0, budget),
skipped: pool.slice(budget),
selectionMode: 'priority',
};
}
const selected = [];
const selectedKeys = new Set();
const countsByKind = new Map();
const add = (candidate) => {
const key = candidateIdentity(candidate);
if (selectedKeys.has(key)) return false;
selectedKeys.add(key);
selected.push(candidate);
const kind = candidate.kind ?? '<unknown>';
countsByKind.set(kind, (countsByKind.get(kind) ?? 0) + 1);
return true;
};
// First pass: one candidate per failure mode, preserving the existing sorted
// order. This is where the default run gets broad coverage, but only for
// kinds whose signal is strong enough for a default slot.
for (const candidate of pool) {
if (selected.length >= budget) break;
const kind = candidate.kind ?? '<unknown>';
if ((countsByKind.get(kind) ?? 0) > 0) continue;
if (!isDiversityEligible(candidate)) continue;
add(candidate);
}
// Second pass: allow a second entry for high-frequency families, but avoid
// letting slow_route consume the entire default budget when other kinds exist.
for (const candidate of pool) {
if (selected.length >= budget) break;
const kind = candidate.kind ?? '<unknown>';
const cap = DEFAULT_KIND_CAPS.get(kind) ?? 1;
if ((countsByKind.get(kind) ?? 0) >= cap) continue;
if (!isDiversityEligible(candidate)) continue;
add(candidate);
}
// Final fill: if the project only has one or two candidate kinds, use the
// whole requested budget rather than leaving slots empty.
for (const candidate of pool) {
if (selected.length >= budget) break;
add(candidate);
}
return {
selected,
skipped: pool.filter((candidate) => !selectedKeys.has(candidateIdentity(candidate))),
selectionMode: 'diverse-default',
};
}
function candidateIdentity(candidate) {
return [
candidate?.kind ?? '',
candidate?.route ?? '',
candidate?.hostname ?? '',
candidate?.scope ?? '',
candidate?.o11ySignal ?? '',
].join('\u0000');
}
function isDiversityEligible(candidate) {
const fn = DIVERSITY_ELIGIBILITY.get(candidate?.kind);
return fn ? fn(candidate) : true;
}
function numberFromEvidence(candidate, key) {
const value = candidate?.evidence?.[key];
return typeof value === 'number' && Number.isFinite(value) ? value : 0;
}
function numberFromSignal(signal, key) {
if (typeof signal !== 'string') return 0;
const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const re = new RegExp(`(?:^|,)${escaped}=([\\d.]+)`);
const m = re.exec(signal);
if (!m) return 0;
const n = Number(m[1]);
return Number.isFinite(n) ? n : 0;
}
function durationMsFromSignal(signal, key) {
if (typeof signal !== 'string') return 0;
const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const re = new RegExp(`(?:^|,)${escaped}=([\\d.]+)ms`);
const m = re.exec(signal);
if (!m) return 0;
const n = Number(m[1]);
return Number.isFinite(n) ? n : 0;
}
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 |