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/contract.mjs
View on GitHubconst VALID_SCOPES = new Set(['route', 'file', 'account']);
export class CandidateContractError extends Error {
constructor(errors) {
super(`gate candidate contract failed:\n${errors.map((e) => `- ${e}`).join('\n')}`);
this.name = 'CandidateContractError';
this.errors = errors;
}
}
export function validateCandidates(candidates, ctx = {}) {
if (!Array.isArray(candidates)) {
throw new CandidateContractError([`${ctx.source ?? 'gate'}: expected candidate array`]);
}
const errors = [];
for (let i = 0; i < candidates.length; i++) {
errors.push(...validateCandidate(candidates[i], { ...ctx, index: i }).errors);
}
if (errors.length > 0) throw new CandidateContractError(errors);
return candidates;
}
export function validateCandidate(candidate, ctx = {}) {
const label = candidateLabel(candidate, ctx);
const errors = [];
if (!candidate || typeof candidate !== 'object' || Array.isArray(candidate)) {
return { ok: false, errors: [`${label}: candidate must be an object`] };
}
if (!nonEmptyString(candidate.kind)) errors.push(`${label}: kind must be a non-empty string`);
if (!VALID_SCOPES.has(candidate.scope)) {
errors.push(`${label}: scope must be one of route, file, account`);
}
if (!Number.isFinite(candidate.priority)) errors.push(`${label}: priority must be a finite number`);
if (!Number.isFinite(candidate.confidence)) errors.push(`${label}: confidence must be a finite number`);
if (Array.isArray(candidate.files)) {
if (!candidate.files.every((f) => typeof f === 'string' && f.length > 0)) {
errors.push(`${label}: files must contain only non-empty strings`);
}
} else {
errors.push(`${label}: files must be an array`);
}
if (!nonEmptyString(candidate.reason)) errors.push(`${label}: reason must be a non-empty string`);
if (!nonEmptyString(candidate.question)) errors.push(`${label}: question must be a non-empty string`);
if (candidate.scope === 'route') {
const hasRoute = nonEmptyString(candidate.route);
const hasHostname = nonEmptyString(candidate.hostname);
if (!hasRoute && !hasHostname) {
errors.push(`${label}: route-scoped candidates must set route or hostname`);
}
}
if (candidate.scope === 'file') {
if (candidate.route != null || candidate.hostname != null) {
errors.push(`${label}: file-scoped candidates must not set route or hostname`);
}
if (!Array.isArray(candidate.files) || candidate.files.length === 0) {
errors.push(`${label}: file-scoped candidates must include at least one file`);
}
}
if (candidate.scope === 'account') {
if (candidate.route != null || candidate.hostname != null) {
errors.push(`${label}: account-scoped candidates must not set route or hostname`);
}
}
return { ok: errors.length === 0, errors };
}
function candidateLabel(candidate, ctx) {
const source = ctx.source ?? 'gate';
const index = ctx.index == null ? '?' : ctx.index;
const kind = candidate?.kind ?? '?';
return `${source}[${index}] ${kind}`;
}
function nonEmptyString(value) {
return typeof value === 'string' && value.trim().length > 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 |