AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
Vercel Optimize is a structured workflow designed to perform data-driven audits of Vercel-deployed projects. It prioritizes production metrics over static code analysis, ensuring that recommendations are grounded in real-world performance data. The tool integrates with the Vercel CLI to collect usage, metrics, and configuration data, which it then correlates with codebase scans to identify specific optimization candidates. It supports Next.js, SvelteKit, and Nuxt, with limited support for Astro, and enforces a strict, deterministic investigation process to ensure recommendations are accurate, version-aware, and actionable.
What it does
- Collects and merges Vercel production metrics with local codebase scans.
- Uses deterministic gates to identify high-impact performance and cost candidates.
- Performs deep-dive investigations into specific routes, files, or project settings.
- Verifies recommendations against framework-specific documentation and version constraints.
- Generates a ranked report of actionable optimizations.
- Provides a structured, repeatable pipeline for continuous performance improvement.
When to use it
- When you need to reduce Vercel bill costs related to function invocations or build minutes.
- When investigating slow or expensive routes in your application.
- When optimizing for Core Web Vitals or improving cache hit rates.
- When you need a data-backed audit of project configurations and deployment settings.
Advantages
- Reduces noise by focusing only on metric-backed candidates.
- Ensures recommendations are relevant to your specific framework version.
- Prevents speculative optimizations by requiring evidence from production signals.
- Provides a clear, step-by-step audit trail for every recommendation.
Usage examples
- “Run a Vercel optimization audit on this project.”
- The agent will initiate the collection of metrics and usage data, scan the codebase, and generate a report of ranked optimization candidates based on your project's actual traffic.
- “Why is my Vercel bill so high for function invocations?”
- The agent will analyze your function invocation metrics and identify specific routes or patterns that are driving costs, providing recommendations to optimize those areas.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/vercel-labs/vercel-optimize/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip vercel-optimize.zip -d .agents/skills
Documentation by Vercel
Vercel Optimize
Run an observability-first Vercel optimization audit. Do not inspect source files until signals.json exists and a deterministic gate points to a route, file, or project setting.
Core doctrine: read references/doctrine.md if any rule is unclear.
Metrics first. Recommendations start from Vercel production signals, not repo-wide grep.
Deterministic gates.
scripts/gate-investigations.mjsdecides what deserves investigation.Candidate-bound scope. Read only files named by a candidate or a route-local import chain.
Version-aware citations. Use only
references/docs-library.json; invalid or version-mismatched citations are stripped.Customer copy. Read references/voice.md before writing report text or chat output.
Prerequisites
Vercel CLI v53+ with
vercel metrics,vercel usage,vercel contract, andvercel api.Authenticated CLI session:
vercel login.Linked app directory:
vercel link.VERCEL_PROJECT_IDcan help resolve project config, butvercel metricsstill requires directory linkage. The link or environment must include the intended project org/team/user scope so the collector can resolve a CLI-safe--scopeand keepvercel metrics,vercel usage, andvercel contracton the same account.Node.js 20+.
Observability Plus for route-level metric-backed recommendations.
Never put auth tokens in shell commands. Do not type VERCEL_TOKEN=..., --token ..., or Authorization: Bearer ... into commands that may be echoed in chat.
Framework Support
The preflight reads package.json and sets expectations before metric fan-out.
| Framework | Status | Notes |
|---|---|---|
| Next.js App Router | supported | strongest route mapping, scanners, playbooks, citations |
| Next.js Pages Router | supported | scoped to Pages Router idioms when detected |
| SvelteKit | supported | route mapping for src/routes files and SvelteKit scanner |
| Nuxt | supported | route mapping plus generic/platform checks; fewer framework-specific recs |
| Astro | limited | route mapping plus generic checks; fewer framework-specific recs |
| Hono / Remix / unknown | blocked by default | continue only if the user accepts a limited platform/code-only audit |
If unsupported, stop and ask before scanning or gating:
This project uses <framework>. Vercel Optimize supports metric-backed code recommendations for Next.js, SvelteKit, and Nuxt. Astro support is limited. For <framework>, I can still run a limited platform/scanner audit, but route-level Vercel metrics may not map back to source files.
Do you want me to continue with the limited audit, or stop here?If the user continues, rerun collection with --continue-unsupported-framework.
Run Directory
Use a fresh run directory for every audit. Do not reuse briefs, sub-agent outputs, or reports across runs.
RUN_DIR="$(mktemp -d -t vercel-optimize-XXXXXX)"Pipeline
1. Collect, scan, and merge signals
Run from the linked app directory or pass --cwd where a script supports it. Keep stdout JSON separate from stderr logs. Do not combine streams.
node scripts/collect-signals.mjs [projectId] > "$RUN_DIR/vercel-signals.json" 2> "$RUN_DIR/collect.stderr"
node -e 'JSON.parse(require("fs").readFileSync(process.argv[1], "utf8"))' "$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"Collection details, schemas, metric IDs, and degradation behavior live in references/data-collection.md. The metric registry is lib/queries.mjs; keep all queries on the shared 14-day window.
collect-signals.mjs resolves the linked project owner to commandScope.cliScope and verifies that the resolved account can read the resolved project before it checks Observability Plus. Downstream scripts reuse that scope for every Vercel CLI command that accepts --scope. Do not run vercel usage, vercel metrics, or vercel contract manually without the same scope; unscoped usage can report the user's personal organization while route metrics come from the team project.
If project or scope resolution is ambiguous, stop and ask the user which Vercel project and team/personal scope they want audited. Do not infer the intended scope from the current vercel whoami team, and do not proceed with metrics, usage, or contract collection until the link, an exact project match in .vercel/repo.json, or VERCEL_PROJECT_ID + VERCEL_ORG_ID identifies the intended account.
Use this prompt for PROJECT_SCOPE_UNRESOLVED, SCOPE_UNRESOLVED, or PROJECT_SCOPE_MISMATCH:
I can't safely identify the Vercel project and account for this audit yet.
Please confirm the Vercel project name or ID and the team slug/name, or tell me it's under your personal account. Once confirmed, I'll relink or rerun collection against that exact scope before checking metrics.1.1 Stop on blockers
Check blockers before gating:
jq '{frameworkSupportBlocker, observabilityPlus, observabilityPlusUsable, observabilityPlusBlocker, observabilityPlusBlockerDetail}' "$RUN_DIR/signals.json"Required actions:
frameworkSupportBlocker === "unsupported_framework": use the unsupported-framework prompt above.PROJECT_SCOPE_UNRESOLVED,SCOPE_UNRESOLVED, orPROJECT_SCOPE_MISMATCH: stop and ask which Vercel project and team/personal scope the user wants audited. For team projects, rerun aftervercel link --yes --project <project-name-or-id> --team <team-slug>; for personal projects, rerun after linking under the intended user account or after setting bothVERCEL_PROJECT_IDandVERCEL_ORG_ID.observabilityPlusBlocker === null: continue.no_traffic: tell the user route metrics are sparse; continue only if they accept limited output.payment_requiredorno_oplus_probe: render references/observability-plus.md verbatim and ask.project_disabled: tell the user to enable Observability Plus for the project or accept a limited audit.daily_quota_exceeded: stop and tell the user the Observability query quota is exhausted; retry after the next UTC midnight reset, or ask whether to continue with a limited code-only audit.not_linked: link the app directory, then rerun Step 1. If app path and project are known:
vercel link --yes --project <project-name-or-id> --cwd <app-dir>
# add --team <team-id-or-slug> when knownforbiddenorproject_not_found: fix auth/team scope. Do not pitch Observability Plus.all_failed_other: show the raw error code and ask whether to continue in limited code-only mode.
Do not silently fall back to code-only mode. If the user accepts a limited audit, rerun collection with:
node scripts/collect-signals.mjs [projectId] --continue-without-observability > "$RUN_DIR/vercel-signals.json" 2> "$RUN_DIR/collect.stderr"Then scan and merge again.
2. Gate candidates
node scripts/gate-investigations.mjs "$RUN_DIR/signals.json" > "$RUN_DIR/gate.json"Output shape:
toLaunch: code-scope candidates to investigate.platform: project/account-scope recommendations.gated: skipped, covered, or disqualified candidates that must still appear in the report.budget: candidate budget and selection mode.
Default budget is 6 code-scope candidates with a diversity guardrail. To expand:
node scripts/gate-investigations.mjs "$RUN_DIR/signals.json" --max-candidates 12 > "$RUN_DIR/gate.json"
node scripts/gate-investigations.mjs "$RUN_DIR/signals.json" --max-candidates all > "$RUN_DIR/gate.json"Generated candidate docs: references/candidates.md.
2.1 Ask about audit scope when needed
Before deep-dive, run:
node scripts/budget-summary.mjs "$RUN_DIR/gate.json" --format json > "$RUN_DIR/budget-summary.json"If shouldAsk is false, continue.
If shouldAsk is true:
Print
exactChatMessage.bodyexactly as returned. Do not summarize, truncate, reorder, or rewrite it.Then ask
questionTextusingquestionPayloadwhen the host supports structured questions.If the user chooses a different number, rerun the gate with
--max-candidates <choice>.
Never put the long preview inside the question field. The preview and the question are separate surfaces.
2.2 Deep-dive and reconcile
node scripts/deep-dive.mjs "$RUN_DIR/signals.json" "$RUN_DIR/gate.json" --cwd <project-dir> > "$RUN_DIR/investigation-evidence.json"
node scripts/reconcile-candidates.mjs "$RUN_DIR/investigation-evidence.json" \
--gate "$RUN_DIR/gate.json" \
--out "$RUN_DIR/reconciled-investigation.json"--cwd must be the linked project directory so deep-dive.mjs can verify the same project link and reuse signals.json.commandScope.cliScope for any follow-up vercel metrics calls.
Reconciliation deterministically converts disproven candidates into observations before any source investigation:
metric_mismatcherror_stormdeployment_regressionscanner_only_no_metric
2.3 Generate briefs and investigate
List the work:
node scripts/prepare-investigation-brief.mjs "$RUN_DIR/signals.json" "$RUN_DIR/reconciled-investigation.json" --list > "$RUN_DIR/briefs-manifest.json"Generate one brief for every entry in briefs-manifest.json.briefs. The group can be toLaunch or platform; do not generate only toLaunch briefs.
mkdir -p "$RUN_DIR/briefs" "$RUN_DIR/sub-agent-outputs"
node scripts/prepare-investigation-brief.mjs "$RUN_DIR/signals.json" "$RUN_DIR/reconciled-investigation.json" \
--group <brief.group> --index <brief.index> --out "$RUN_DIR/briefs/<brief.group>-<brief.index>.md"Use briefs-manifest.json.briefs[].label for visible worker names, for example Low cache-hit route on /docs/llm-digest/[...slug], not toLaunch-7.
Fan-out rule:
1-2 briefs: investigate inline.
3+ briefs: spawn one sub-agent per brief when the host supports it.
Hosts without sub-agents: run inline serially.
Sub-agent contract:
The brief is the whole prompt.
Read only files listed in the brief, plus route-local imports when needed.
Emit one JSON recommendation or one JSON no-change finding using references/recommendations.md.
Do not cite URLs outside the provided citation subset.
Do not recommend framework features unavailable in the detected version.
If a sub-agent reaches for repo-wide grep, the candidate is malformed; drop or abstain rather than widening scope.
2.4 Collect outputs
Save each raw investigation result in $RUN_DIR/sub-agent-outputs/, then collect:
node scripts/collect-sub-agent-outputs.mjs \
--manifest "$RUN_DIR/briefs-manifest.json" \
--out "$RUN_DIR/recommendations.json" \
"$RUN_DIR/sub-agent-outputs/"The collector extracts JSON, prepends pre-resolved records, enforces manifest order, and fails on missing, duplicate, unknown, or mismatched candidateRef values.
3. Verify recommendations
node scripts/verify-and-regen.mjs "$RUN_DIR/recommendations.json" \
--signals "$RUN_DIR/signals.json" \
--repo-root <project-dir> \
--out "$RUN_DIR/verify.json"This script extracts claims, verifies files/citations/version fit, grades quality, applies sanitizers, emits verifiedRecommendations, withheldRecommendations, renderableRecommendations, and creates regenPlan for failed or unsafe recommendations.
Recommendation schema, writing rules, sanitizer order, and grading rules: references/recommendations.md. Verification rules: references/verification.md.
For each regenPlan entry, rerun the same brief with a Previous attempt failed these checks section listing topFailures. Keep the regenerated output only if verification improves without gutting citations.
4. Render report and final message
node scripts/render-report.mjs "$RUN_DIR/verify.json" "$RUN_DIR/gate.json" "$RUN_DIR/signals.json" \
--project <name> \
--out "$RUN_DIR/report.md" \
--message-out "$RUN_DIR/final-message.json"Use --debug-out "$RUN_DIR/debug.json" only when developing the skill. Customer Markdown and chat output must not expose passRate, quality, sanitizer trails, raw sub-agent names, or other implementation fields.
After rendering, print final-message.json.body verbatim and stop. Do not add highlights, debug notes, raw counts, sub-agent summaries, or extra explanation. Render-time dedupe, platform caps, and hard-safety drops can change the customer-visible count, so never summarize from raw verify.json.
Report structure and impact framing: references/scoring.md.
Recommendation Rules
Every recommendation must:
Trace to a launched candidate, platform candidate, pre-resolved observation, or verified traffic-independent scanner finding.
Include observed metric evidence from
signals.jsonorevidence.deepDive.Cite verified files with line numbers when code is involved.
Include at least one allowed citation that applies to the detected framework/version.
Use precise observed performance numbers.
Use cost magnitude phrases only; never customer-facing
$Nsavings.Do not recommend duration reductions for Vercel Workflow runtime endpoints (
/.well-known/workflow/v1/*). These are generated orchestration routes for durable step/flow execution and should be hard-gated before investigation.Workflow recommendations must name the boundary being changed. Valid examples: enqueue durable work and return a run ID instead of awaiting completion, fix stream replay/closure/locks, or reduce verified excess Workflow Steps/Storage. Do not infer cost savings from Workflow endpoint wall-clock duration.
For streaming, SSE, resumable chat, or other intentionally long-lived routes, do not frame wall-clock function duration as a problem by itself. Require evidence of avoidable pre-first-byte work, high active CPU, duplicate invocations, or post-response work that can move out of the user-visible path.
Name a specific cache policy when recommending caching.
Keep unsafe responses dynamic unless evidence proves they are safe to cache: auth-sensitive paths, errors, fallback responses, missing content, invalid requests, geolocation/device-varying output, and unversioned dynamic URLs.
Never recommend "verify X is on" for facts already present in signals.project, including Fluid compute status, memory tier, regions, in-function concurrency, and timeout.
Scanner Rules
Scanner findings are supplementary. Drop findings annotated COLD-PATH or NO-ROUTE-MAPPING unless the scanner declares metadata.trafficIndependent === true.
Traffic-independent examples: middleware matcher, source maps, React Compiler config, build settings. Route-local cache or data-fetch patterns need route-level traffic evidence.
Scanner docs: references/scanner-patterns.md.
Final Customer Terms
Use:
recommendations readyobservations from investigationinvestigated, no change recommendednot investigated in this run
Avoid:
sub-agentabstentionpassRatequality scoregateLLM
Failure Copy
Use these messages without adding sales copy or process detail.
No traffic in the last 14 days:
This project has no meaningful traffic in the last 14 days, so route-level metrics are sparse. I can still check traffic-independent scanner findings and project settings, but I cannot rank route fixes until traffic accumulates.
Route-level metrics unavailable:
Use the verbatim choice template in references/observability-plus.md. Do not silently fall back to code-only mode; present the two-path choice: enable Observability Plus and rerun the metric-backed audit, or accept a limited code-only run.
Project is not linked:
This worktree is not linked to a Vercel project. Run
vercel link --yes --project <project-name-or-id> --cwd <app-dir>and rerun the audit. If the team is known, add--team <team-id-or-slug>.
Most route-to-file mappings failed:
The route inventory matched fewer than half of the routes we saw in observability. This is common in monorepos with custom routing. I've surfaced what I can match; the rest appear in the "Not investigated in this run" section.
Files
- AGENTS.md1.9 KiB
- ATTRIBUTION.mdAdded by AutoGineer848 B
- CONTRIBUTING.md2.2 KiB
- README.md4.4 KiB
- SKILL.md16.9 KiB
- lib/auth-route.mjsScript807 B
- lib/budget-summary.mjsScript7.0 KiB
- lib/citations.mjsScript3.9 KiB
- lib/cost-coverage.mjsScript8.4 KiB
- lib/dedup-recs.mjsScript9.9 KiB
- lib/deep-dive.mjsScript10.2 KiB
- lib/display-labels.mjsScript7.4 KiB
- lib/extract-claims.mjsScript18.7 KiB
- lib/framework-support.mjsScript2.1 KiB
- lib/gates/build-minutes-fanout.mjsScript2.9 KiB
- lib/gates/cold-start.mjsScript2.7 KiB
- lib/gates/contract.mjsScript3.1 KiB
- lib/gates/cwv-poor.mjsScript3.3 KiB
- lib/gates/external-api-slow.mjsScript2.1 KiB
- lib/gates/hard-gates.mjsScript2.5 KiB
- lib/gates/index.mjsScript2.0 KiB
- lib/gates/isr-overrevalidation.mjsScript2.4 KiB
- lib/gates/middleware-heavy.mjsScript2.0 KiB
- lib/gates/observability-events-attribution.mjsScript2.2 KiB
- lib/gates/platform-bot-protection.mjsScript5.0 KiB
- lib/gates/platform-fluid-compute.mjsScript3.5 KiB
- lib/gates/region-misconfig.mjsScript3.0 KiB
- lib/gates/route-errors.mjsScript3.0 KiB
- lib/gates/scanner-driven.mjsScript5.1 KiB
- lib/gates/select-candidates.mjsScript4.6 KiB
- lib/gates/slow-route.mjsScript4.3 KiB
- lib/gates/types.d.tsScript893 B
- lib/gates/uncached-route.mjsScript3.9 KiB
- lib/gates/usage-spike-triage.mjsScript5.0 KiB
- lib/grade-recommendation.mjsScript6.7 KiB
- lib/impact-label.mjsScript5.2 KiB
- lib/impact-magnitude.mjsScript2.1 KiB
- lib/investigation-brief.mjsScript34.3 KiB
- lib/observation-safety.mjsScript9.3 KiB
- lib/project-facts.mjsScript4.3 KiB
- lib/queries.mjsScript10.1 KiB
- lib/reconcile-candidates.mjsScript15.6 KiB
- lib/render-report.mjsScript38.2 KiB
- lib/repo-root.mjsScript3.1 KiB
- lib/route-normalize.mjsScript8.4 KiB
- lib/sanitizers/bot-protection-certainty.mjsScript1.9 KiB
- lib/sanitizers/cache-tag-invalidation-certainty.mjsScript1.5 KiB
- lib/sanitizers/count-correct.mjsScript1.9 KiB
- lib/sanitizers/function-duration-invocations.mjsScript1.4 KiB
- lib/sanitizers/index.mjsScript3.0 KiB
- lib/sanitizers/middleware-conflict.mjsScript1.5 KiB
- lib/sanitizers/missing-citation.mjsScript497 B
- lib/sanitizers/pre-release.mjsScript2.2 KiB
- lib/sanitizers/rate-limit.mjsScript2.6 KiB
- lib/sanitizers/rendering-mode-mislabel.mjs1.6 KiB
- lib/sanitizers/undeclared-dep.mjs2.8 KiB
- lib/sanitizers/vercel-directive-strip.mjs1.4 KiB
- lib/sanitizers/window-units.mjs869 B
- lib/scanners/cache-components-suspense-dedupe.mjs4.3 KiB
- lib/scanners/edge-heavy-import.mjs3.7 KiB
- lib/scanners/force-dynamic.mjs1.5 KiB
- lib/scanners/headers-in-page.mjs1.5 KiB
- lib/scanners/index.mjs1.4 KiB
- lib/scanners/large-static-asset.mjs3.2 KiB
- lib/scanners/max-age-without-s-maxage.mjs1.6 KiB
- lib/scanners/middleware-broad-matcher.mjs1.9 KiB
- lib/scanners/missing-cache-headers.mjs3.8 KiB
- lib/scanners/prisma-include-tree.mjs1.5 KiB
- lib/scanners/region-pin-in-config.mjs3.4 KiB
- lib/scanners/source-maps-production.mjs1.3 KiB
- lib/scanners/sveltekit-prerender-missing.mjs2.1 KiB
- lib/scanners/turbo-force-bypass.mjs4.9 KiB
- lib/scanners/unoptimized-image.mjs4.4 KiB
- lib/scanners/use-cache-date-stamp.mjs3.9 KiB
- lib/support-topics.mjs12.5 KiB
- lib/throttle.mjs8.8 KiB
- lib/util.mjs544 B
- lib/vercel.mjs30.4 KiB
- lib/verify-claim.mjs59.6 KiB
- lib/workspace-resolver.mjs17.1 KiB
- metadata.json903 B
- references/candidates.md8.3 KiB
- references/data-collection.md20.4 KiB
- references/docs-library.json30.8 KiB
- references/doctrine.md9.3 KiB
- references/observability-plus.md5.2 KiB
- references/playbooks/README.md2.7 KiB
- references/playbooks/ai-application.md3.8 KiB
- references/playbooks/api-service.md2.4 KiB
- references/playbooks/content-site.md2.4 KiB
- references/playbooks/ecommerce.md2.7 KiB
- references/playbooks/marketing.md2.6 KiB
- references/playbooks/saas.md2.8 KiB
- references/playbooks/sveltekit.md3.9 KiB
- references/recommendations.md10.5 KiB
- references/scanner-patterns.md13.4 KiB
- references/scoring.md12.2 KiB
- references/support-topics/README.md1.7 KiB
- references/support-topics/astro-edge-middleware-scope.md1012 B
- references/support-topics/astro-output-mode-and-isr.md1.1 KiB
- references/support-topics/auth-preserving-parallelization.md1.2 KiB
- references/support-topics/bot-protection-product-guardrails.md1.1 KiB
- references/support-topics/build-minutes-monorepo-fanout.md1.2 KiB
- references/support-topics/cache-components-static-shell-boundaries.md1.1 KiB
- references/support-topics/cache-components-suspense-dedupe-pitfall.md1.3 KiB
- references/support-topics/cdn-cache-auth-safety.md1.0 KiB
- references/support-topics/cold-start-initialization-bundle.md1.1 KiB
- references/support-topics/core-web-vitals-client-bottlenecks.md1.0 KiB
- references/support-topics/database-egress-pooling-region.md1015 B
- references/support-topics/dynamic-rendering-traps.md1.1 KiB
- references/support-topics/external-api-critical-path-platform.md1.1 KiB
- references/support-topics/external-api-critical-path.md978 B
- references/support-topics/fast-data-transfer-payloads.md1.0 KiB
- references/support-topics/fluid-compute-caveats.md1.1 KiB
- references/support-topics/function-duration-io-and-after.md1.0 KiB
- references/support-topics/function-invocation-reduction.md1.2 KiB
- references/support-topics/function-region-misconfiguration-ttfb.md1.2 KiB
- references/support-topics/image-optimization-cost-control.md1.0 KiB
- references/support-topics/isr-revalidation-static-generation.md1.4 KiB
- references/support-topics/middleware-proxy-edge-cost.md991 B
- references/support-topics/next-fetch-revalidate-floor.md1.0 KiB
- references/support-topics/next-font-cls-self-hosting.md906 B
- references/support-topics/next-heavy-ui-lazy-load-boundaries.md1.0 KiB
- references/support-topics/next-image-lcp-preload-sizes.md1.0 KiB
- references/support-topics/next-route-handler-get-cache-defaults.md1.0 KiB
- references/support-topics/next-script-third-party-strategy.md1.0 KiB
- references/support-topics/nextjs-version-cache-semantics.md996 B
- references/support-topics/not-found-catchall-request-waste.md1.2 KiB
- references/support-topics/nuxt-route-rules-cache-isr.md1.2 KiB
- references/support-topics/observability-events-cost-attribution.md1.1 KiB
- references/support-topics/post-response-work-waituntil.md1009 B
- references/support-topics/route-error-durable-offload.md1.3 KiB
- references/support-topics/route-error-runtime-limits.md988 B
- references/support-topics/runtime-cache-reusable-data.md1.2 KiB
- references/support-topics/sveltekit-isr-prerender-safety.md1.1 KiB
- references/support-topics/sveltekit-split-cold-start-tradeoff.md1.0 KiB
- references/support-topics/usage-spike-triage.md1018 B
- references/support-topics/use-cache-date-stamp-isr-write-amplifier.md1.2 KiB
- references/support-topics/use-cache-remote-shared-origin-data.md1.1 KiB
- references/support-topics/workflow-resumable-stream-routes.md1.2 KiB
- references/verification.md8.8 KiB
- references/voice.md3.6 KiB
- scripts/budget-summary.mjs2.0 KiB
- scripts/build-docs.mjs3.3 KiB
- scripts/check-citations.mjs3.4 KiB
- scripts/check-docs-fresh.mjs3.8 KiB
- scripts/collect-signals.mjs21.1 KiB
- scripts/collect-sub-agent-outputs.mjs9.9 KiB
- scripts/deep-dive.mjs12.0 KiB
- scripts/gate-investigations.mjs6.2 KiB
- scripts/merge-signals.mjs6.2 KiB
- scripts/prepare-investigation-brief.mjs7.9 KiB
- scripts/reconcile-candidates.mjs2.4 KiB
- scripts/render-report.mjs17.0 KiB
- scripts/scan-codebase.mjs11.3 KiB
- scripts/verify-and-regen.mjs14.9 KiB
- scripts/verify-finding.mjs698 B
references/scoring.md
Step 4 — Score and report
This reference covers everything that happens after recommendations are drafted: quality floor, impact framing, sort order, the customer-facing report template, and the playbook selection matrix.
Table of contents
Quality floor and prune rules
Impact framing — the magnitude rule
impactLabelschemaSort order and platform-rec cap
The customer-facing report template
Playbook selection matrix
Quality floor and prune rules
| Rule | Value | Why |
|---|---|---|
Drop recommendations with quality.overall < 0.55 | Hard cutoff (raised from 0.4 in May 2026 audit) | Bad-grade recs erode trust faster than they help. 0.55 matches the Poor/Fair grade boundary; recs below this are "Poor" and shouldn't ship. |
| Prune cap on findings | 30% of input | Stops the pruner from wiping the report when LLM merit-grades are noisy |
| Platform-rec cap | 3 | Account-level recs (Fluid, Bot Protection, Speed Insights) only have room for the top three |
| Quick-wins definition | effort === 'low' AND priority > 40 | Surfaces fixes the user can ship in a single PR |
| Savings floor (internal ranking only) | $5/mo equivalent | Below this, even a "high" tier impact translates to "negligible" magnitude |
Impact framing — the magnitude rule
Performance: be precise. Use observed numbers. Example:
"Reduce /api/products p95 from 850ms toward ~250-400ms; cache hit would lift from 0% toward ~60% based on similar cached routes."
Performance numbers come from signals.json.metrics.* — they're observed, not extrapolated. Cite the exact route + metric value.
Dollar cost: never precise. Use MAGNITUDE BUCKETS via lib/impact-magnitude.mjs's impactMagnitude({currentCost, impactTier}):
| Estimated reduction (USD) | Magnitude | Customer-facing phrase |
|---|---|---|
| < $5 | negligible | "small cost impact at current traffic" |
| $5 – $50 | small | "low-tens of dollars per month at current traffic" |
| $50 – $500 | medium | "hundreds of dollars per month at current traffic" |
| $500 – $5,000 | large | "low-thousands of dollars per month at current traffic" |
| > $5,000 | very-large | "thousands+ of dollars per month at current traffic" |
Reduction is computed as currentCost × fraction where fraction = {high: 0.4, medium: 0.2, low: 0.1}[impactTier]. The fraction is intentionally conservative — we'd rather under-promise than mislead.
Discountable vs non-discountable SKUs
When the project is on a Flex Commit and the report frames savings against contract burndown, segment spend before phrasing. Field doctrine (May 2026): the Flex discount slider applies only to a subset of SKUs.
| Discountable (slider applies) | Non-discountable (raw rate) |
|---|---|
| Seats | Build CPU Minutes |
| Edge Requests | Fluid Active CPU |
| Fast Data Transfer | Fluid Provisioned Memory |
| Fast Origin Transfer | Raw Flex top-up |
| Image Optimization | |
| ISR Reads / Writes | |
| Observability Events |
A recommendation that targets a non-discountable SKU should never frame savings as a percentage of contract; frame as absolute magnitude only. Conversely, a discountable-SKU recommendation may surface "applies to contract burndown" in the magnitude phrase.
Why magnitudes:
Traffic varies. A "20% reduction in edge requests" is exact at today's traffic and meaningless next quarter.
Pricing changes. Vercel's billing rates move; precise dollar projections rot.
The user is smart. They'd rather see "hundreds of dollars per month" with a real metric backing it than
$340/mowith a hand-wave behind it.The
$-stripsanitizer enforces this at output time. Any$Nliteral that slips into customer-facing fields is replaced with "the billed cost" before rendering.
impactLabel schema
type ImpactLabel = {
// PRECISE: performance recs
performance?: string;
// MAGNITUDE: cost recs
costMagnitude?: 'negligible' | 'small' | 'medium' | 'large' | 'very-large';
costPhrase?: string;
billingDimension?: string; // 'Edge Requests' | 'Function Duration' | ...
fractionReduced?: number; // 0.2 = ~20% — internal only, NOT rendered
};Cost recs render costPhrase. Performance recs render performance. Reliability recs frame impact as observed error/timeout reduction (e.g., "Cuts 5xx rate from 0.4% to <0.1% based on current traffic").
When a rec spans buckets — e.g., a caching fix that reduces both cost AND latency — render both lines.
Sort order and platform-rec cap
Internal sort key (never rendered): priority = currentDimensionCost × fractionReduced × confidence.
The list of recs the customer sees is sorted by this priority. The platform recommendations section is capped at 3, sorted the same way.
The customer-facing report template
The agent renders this as the final output of Step 4. The shape is fixed; the content comes from the merged signals + verified recommendations + the gated[] list from Step 2.
# Vercel Optimization Report — {projectName}
**Stack**: {framework}@{frameworkVersion} | {router} | {orm}
**Plan**: {plan.plan} ({plan.reason})
**Period**: {usage.period.from} → {usage.period.to}
**Observability**: {observability status}
## Cost breakdown
| Service | Usage | Billed Cost |
|---|---|---|
| (non-zero rows from usage.services, sorted by billedCost desc) |
Total billed: {usage.totals.billedCost} (we render the precise current cost — we just don't project future precise savings)
Omit zero-cost service rows from the table at the same cent precision shown to customers. If every row has `$0.00` billed cost but `effectiveCost` / USD `pricingQuantity` is non-zero, explain that net billed cost is `$0.00` after included credits or allotments and show the effective usage cost table instead. If both billed and effective costs are `$0.00`, replace the table with a concise note that `vercel usage` returned a billing payload but every reported service cost was `$0.00` for the window.
If `vercel usage` was queried and unavailable, the cost breakdown is replaced by an observability-derived cost ranking from `metrics.fnGbHrByRoute` + `metrics.fnCpuMsByRoute` + `metrics.fdtByRoute` when those metrics exist. These don't translate directly to dollars — they show *which routes consume the billable units* so the user knows what to attack first. If `usageError` is `NOT_COLLECTED_OBSERVABILITY_BLOCKED` or another `NOT_COLLECTED_*` value, say usage was not collected; do not describe it as a billing-plan or Costs-feature finding.
Render Observability status from the actual collection state:
- `Observability Plus enabled — per-route metrics included` when `observabilityPlusUsable=true`.
- `Per-route metrics unavailable — audit paused before metric-backed route ranking` when an Observability Plus blocker stopped the run before billing/scanner collection.
- `Per-route metrics unavailable — analysis based on billing + scanner findings` when the user accepted a limited audit and billing/scanner signals were collected.
- `Per-route metrics unavailable — limited analysis based on scanner findings` when the user accepted a limited audit but billing usage was queried and unavailable.
- `Not checked — audit paused at unsupported-framework preflight` when framework support stopped the run before the Observability Plus check.
- `Not enabled — analysis based on billing + scanner findings` only for legacy/limited reports where Observability Plus is known false and billing/scanner signals exist.
## Highest-impact recommendations
For each high-priority rec, in order:
1. **{route or file}** — {o11ySignal}
1. **{readable candidate label}** — {readable metric labels}
- **What to do**: {rec.what}
- **Impact**: {impactLabel.performance ?? impactLabel.costPhrase}
- **Effort**: {rec.effort}
- **Citations**: {rec.citations}
## Recommendations
### High impact
| # | Bucket | What | Impact | Effort | Citations |
|---|---|---|---|---|---|
### Medium impact
### Low impact
## Platform recommendations
(account-level recs from gate, capped at 3)
## Observations from investigation
Non-recommendation findings from reconciliation or investigation: deployment regressions, route-error storms, metric mismatches, and other real signals that should not become speculative performance recommendations.
Observations must not contain implementation-grade actions. If the suggested action says to enable, add, wrap, apply, move, configure, challenge, deny, or otherwise change code or project settings, the renderer must hold it back until it passes the ready-to-apply recommendation evidence bar. Customer-visible observations can ask for narrower evidence collection: inspect logs, compare deployments, check headers, or confirm cacheability.
## Investigated, no change recommended
Candidates that were checked but did not produce a supported recommendation. Use plain reasons; do not use "abstain" in customer-facing copy.
| Candidate | Why no recommendation shipped |
|---|---|
| Slow route on /docs | Detailed metrics did not support a code change |
## Not investigated in this run
This section earns the user's trust. For every metric signal we considered but didn't act on, group by candidate type and reason:
| Candidate type | Why not investigated | Targets | Count |
|---|---|---|---:|
| Low cache-hit route | hitRate 0.65 above threshold | /api/orders | 1 |
| Slow route | left for a larger run | /api/docs<br>/api/learn | 2 |
## Strengths
(what the project is doing right — caching is healthy on routes X/Y/Z; Fluid Compute is enabled; etc.)
## Data gaps
(what we couldn't measure — Observability Plus disabled means no per-route latency, etc.)Common data gaps to call out when the underlying metric returned empty rows. If the metric query failed (ok=false), say the metric was not usable with the code; do not convert failed queries into "no measurements" or "not used" claims.
Core Web Vitals empty. The Speed Insights metric returned no measurements for the 14-day window. The
cwv_poorgate stayed dormant; no claims about LCP/INP/CLS are made.ISR empty. Project doesn't use Incremental Static Regeneration. The
isr_overrevalidationgate stayed dormant.Middleware empty. No
middleware.ts(or matcher excludes all observed traffic). Themiddleware_heavygate stayed dormant.Image transformations empty. No
next/imageusage or no images served in the window.BotID checks empty. BotID is disabled — see the
platform_bot_protectionrecommendation for the toggle.Cold-start data near-zero. Fluid Compute may already be enabled, or the project's traffic pattern keeps warm instances available; the
cold_startgate evaluates the data but emits no candidate.
The "Not investigated in this run" section is critical. It comes directly from gate.json produced by the gate. It tells the user we considered everything; we didn't just pick the easy targets.
Playbook selection matrix
The recommender selects 0-2 playbooks based on the project's stack.applicationProfile (inferred from frameworks + deps) and the top billing dimensions.
| Application profile | Likely top dimensions | Apply playbooks |
|---|---|---|
ai-application (AI SDK, AI Gateway, Sandbox usage) | AI Gateway, Sandbox Active Compute, Function Duration | playbooks/ai-application.md |
ecommerce (Stripe, Shopify, cart components) | Edge Requests, Function Duration | playbooks/ecommerce.md |
saas (auth, dashboards, multi-tenant) | Function Duration, Bandwidth | playbooks/saas.md |
api-service (mostly API routes, no UI) | Function Duration, Edge Requests | playbooks/api-service.md |
content-site (blog, docs, mostly static) | Edge Requests, Image Optimization | playbooks/content-site.md |
marketing (landing pages, A/B tests) | Edge Requests, ISR Reads | playbooks/marketing.md |
ai-application is checked first in inferPlaybook() — an AI-heavy SaaS or AI commerce app shares the AI playbook's billing shape (AI Gateway dominant) and gotchas, not the dashboard or cart-checkout patterns.
Playbooks shape phrasing and ordering of recommendations. They never invent claims — every rec must still trace back to verified findings.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Node.js
Security
What our scanner noticed· Low risk
- Instructions that use the network
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Vercel
- Publisher
- Vercel (Official)
- Source
- vercel-labs/agent-skills · skills/vercel-optimize · commit 1a2c79d
- Licence
- MIT License (redistribution allowed)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Vercel.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download vercel-optimize.zip