Vercel Optimize
Overview
Observability-first Vercel performance and cost reduction optimization skill. Evaluates deployed Next.js, SvelteKit, Nuxt, and Astro projects using production telemetry signals (signals.json), deterministic candidate gating, and code scanning to deliver ranked, verified architectural recommendations.
When to Use
- When tasked with reducing Vercel bills, Function Invocations, Fast Data Transfer, or Build Minutes.
- When diagnosing slow serverless routes, cold starts, or Edge vs Node runtime mismatches.
- When evaluating caching opportunities (
stale-while-revalidate, ISR, CDN edge caching) or Core Web Vitals degradation.
Rules & Patterns
1. Prerequisites & Framework Support
- Vercel CLI v53+ with
vercel metrics, vercel usage, vercel contract, and vercel api.
- Authenticated CLI session (
vercel login) and linked app directory (vercel link).
- Framework support: Next.js App Router (Full), Pages Router (Supported), SvelteKit (Supported), Nuxt (Supported), Astro (Limited).
- Security rule: Never put auth tokens in shell commands (
VERCEL_TOKEN=... is banned in chat/logs).
2. Core Doctrine & Gating Pipeline
- Metrics First: Recommendations start from Vercel production signals (14-day window), not repo-wide grep.
- Deterministic Gates:
scripts/gate-investigations.mjs selects code-scope and platform-scope candidates.
- Candidate-Bound Scope: Inspect only files named by a candidate or a route-local import chain.
- Version-Aware Citations: Use only verified citations matching the target framework version.
- Specific Cache Policies: When recommending caching, state the exact cache policy and headers; keep auth-sensitive and error responses dynamic.
3. Recommendation Rules
- Every recommendation must trace to a launched candidate and include observed metric evidence.
- Cite verified files with line numbers when code changes are proposed.
- Use precise observed performance numbers; avoid customer-facing speculative
$N savings formulas.
- Do not recommend duration reductions for Vercel Workflow runtime endpoints (
/.well-known/workflow/v1/*).
Code Examples
// [GOOD] Next.js Route Segment Config for Caching & Edge Runtime
export const dynamic = 'force-static';
export const revalidate = 3600; // Cache at Edge for 1 hour
export default async function CachedCatalogPage() {
const products = await getCatalogData();
return <CatalogGrid items={products} />;
}
# Running the signals collection and gate
node scripts/collect-signals.mjs [projectId] > "$RUN_DIR/vercel-signals.json"
node scripts/scan-codebase.mjs <repo-root> > "$RUN_DIR/codebase.json"
node scripts/merge-signals.mjs "$RUN_DIR/vercel-signals.json" "$RUN_DIR/codebase.json" --out "$RUN_DIR/signals.json"
node scripts/gate-investigations.mjs "$RUN_DIR/signals.json" > "$RUN_DIR/gate.json"
Validation Checklist
Common Mistakes
- Inspecting repository source code before metric signals exist.
- Hardcoding
VERCEL_TOKEN into terminal commands or prompt logs.
- Recommending duration reductions on long-lived streaming routes or workflow runners.
- Applying static caching to user-specific or authenticated routes.
Integration Notes
- Complements
nextjs and react-best-practices for server-side optimization.
- Pairs with
performance and security skills.
1---2name: vercel-optimize3description: Observability-first Vercel performance and cost reduction optimization skill.4---5# Vercel Optimize67## Overview89Observability-first Vercel performance and cost reduction optimization skill. Evaluates deployed Next.js, SvelteKit, Nuxt, and Astro projects using production telemetry signals (`signals.json`), deterministic candidate gating, and code scanning to deliver ranked, verified architectural recommendations.1011## When to Use1213- When tasked with reducing Vercel bills, Function Invocations, Fast Data Transfer, or Build Minutes.14- When diagnosing slow serverless routes, cold starts, or Edge vs Node runtime mismatches.15- When evaluating caching opportunities (`stale-while-revalidate`, ISR, CDN edge caching) or Core Web Vitals degradation.1617## Rules & Patterns1819### 1. Prerequisites & Framework Support2021- Vercel CLI v53+ with `vercel metrics`, `vercel usage`, `vercel contract`, and `vercel api`.22- Authenticated CLI session (`vercel login`) and linked app directory (`vercel link`).23- Framework support: Next.js App Router (Full), Pages Router (Supported), SvelteKit (Supported), Nuxt (Supported), Astro (Limited).24- Security rule: Never put auth tokens in shell commands (`VERCEL_TOKEN=...` is banned in chat/logs).2526### 2. Core Doctrine & Gating Pipeline2728- **Metrics First:** Recommendations start from Vercel production signals (14-day window), not repo-wide grep.29- **Deterministic Gates:** `scripts/gate-investigations.mjs` selects code-scope and platform-scope candidates.30- **Candidate-Bound Scope:** Inspect only files named by a candidate or a route-local import chain.31- **Version-Aware Citations:** Use only verified citations matching the target framework version.32- **Specific Cache Policies:** When recommending caching, state the exact cache policy and headers; keep auth-sensitive and error responses dynamic.3334### 3. Recommendation Rules3536- Every recommendation must trace to a launched candidate and include observed metric evidence.37- Cite verified files with line numbers when code changes are proposed.38- Use precise observed performance numbers; avoid customer-facing speculative `$N` savings formulas.39- Do not recommend duration reductions for Vercel Workflow runtime endpoints (`/.well-known/workflow/v1/*`).4041## Code Examples4243```typescript44// [GOOD] Next.js Route Segment Config for Caching & Edge Runtime45export const dynamic = 'force-static';46export const revalidate = 3600; // Cache at Edge for 1 hour4748export default async function CachedCatalogPage() {49 const products = await getCatalogData();50 return <CatalogGrid items={products} />;51}52```5354```bash55# Running the signals collection and gate56node scripts/collect-signals.mjs [projectId] > "$RUN_DIR/vercel-signals.json"57node scripts/scan-codebase.mjs <repo-root> > "$RUN_DIR/codebase.json"58node scripts/merge-signals.mjs "$RUN_DIR/vercel-signals.json" "$RUN_DIR/codebase.json" --out "$RUN_DIR/signals.json"59node scripts/gate-investigations.mjs "$RUN_DIR/signals.json" > "$RUN_DIR/gate.json"60```6162## Validation Checklist6364- [ ] Project is properly linked with valid team/personal scope (`vercel link`).65- [ ] Production metrics signals collected across 14-day window before inspecting code.66- [ ] No secrets or tokens passed in command line arguments.67- [ ] Recommendations grounded in specific verified file paths and line numbers.68- [ ] Unsafe or auth-sensitive paths kept strictly dynamic.6970## Common Mistakes7172- Inspecting repository source code before metric signals exist.73- Hardcoding `VERCEL_TOKEN` into terminal commands or prompt logs.74- Recommending duration reductions on long-lived streaming routes or workflow runners.75- Applying static caching to user-specific or authenticated routes.7677## Integration Notes7879- Complements `nextjs` and `react-best-practices` for server-side optimization.80- Pairs with `performance` and `security` skills.81