Observability-first Vercel optimization audit — pull production metrics, gate investigations deterministically, and emit version-aware cost/perf recommendations. USE WHEN auditing a deployed Vercel app for cost or performance issues.
Observability-first Vercel optimization audit — pull production metrics, gate investigations deterministically, and emit version-aware cost/perf recommendations. USE WHEN auditing a deployed Vercel app for cost or performance issues.
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.
Metrics first. Recommendations start from Vercel production signals, not repo-wide grep.
Deterministic gates. scripts/gate-investigations.mjs decides 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.
When to Use
Use this skill when the task matches this description: Audit deployed Vercel apps for cost and performance issues using metrics, project config, code scans, and version-aware recommendations.
Prerequisites
Vercel CLI v53+ with vercel metrics, vercel usage, vercel contract, and vercel api.
Authenticated CLI session: vercel login.
Linked app directory: vercel link. VERCEL_PROJECT_ID can help resolve project config, but vercel metrics still requires directory linkage. The link or environment must include the intended project org/team/user scope so the collector can resolve a CLI-safe --scope and keep vercel metrics, vercel usage, and vercel contract on 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.
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.
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.
frameworkSupportBlocker === "unsupported_framework": use the unsupported-framework prompt above.
PROJECT_SCOPE_UNRESOLVED, SCOPE_UNRESOLVED, or PROJECT_SCOPE_MISMATCH: stop and ask which Vercel project and team/personal scope the user wants audited. For team projects, rerun after vercel link --yes --project <project-name-or-id> --team <team-slug>; for personal projects, rerun after linking under the intended user account or after setting both VERCEL_PROJECT_ID and VERCEL_ORG_ID.
observabilityPlusBlocker === null: continue.
no_traffic: tell the user route metrics are sparse; continue only if they accept limited output.
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 known
forbidden or project_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:
--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:
The collector extracts JSON, prepends pre-resolved records, enforces manifest order, and fails on missing, duplicate, unknown, or mismatched candidateRef values.
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.
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.
Trace to a launched candidate, platform candidate, pre-resolved observation, or verified traffic-independent scanner finding.
Include observed metric evidence from signals.json or evidence.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 $N savings.
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.
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.
Limitations
Use this skill only when the task clearly matches the scope described above.
Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.