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.
references/playbooks/sveltekit.md
View on GitHub# SvelteKit
Framework-specific playbook for SvelteKit projects on Vercel. Applies in
addition to whichever application-profile playbook fits (saas, ecommerce,
content-site, etc.). SvelteKit-on-Vercel ships through
`@sveltejs/adapter-vercel`, so most platform-level recs map to adapter
config rather than per-route framework APIs.
## Typical billing shape
Function Duration dominates server-rendered routes (every `+page.server.ts`
`load` + `+server.ts` POST handler runs as a function). Edge Requests grow
with API surface (`+server.ts` and form actions). ISR is supported via the
adapter; when enabled, it converts to a cache_result HIT after first render.
Image Optimization is rarely a SvelteKit-specific lever (it's the same
Vercel image service Next.js uses).
## Priority patterns
1. **Adapter ISR for cacheable content.** Routes that don't depend on
per-request data are still served as functions by default. The
adapter accepts an `isr: { expiration: 60 }` option per route (set
in `+page.server.ts` via `export const config`). This converts
function invocations to cache hits. Cite
`https://kit.svelte.dev/docs/adapter-vercel` +
`https://vercel.com/docs/incremental-static-regeneration`.
2. **Prerender what's static.** `export const prerender = true` in
`+page.server.ts` or `+page.ts` moves a route from function to CDN.
Cite `https://kit.svelte.dev/docs/page-options`.
3. **Parallel `load` fetches.** A `load` function with multiple
sequential `await fetch(...)` calls leaves wall-clock time on the
table — wrap them in `Promise.all` (or return promises directly
from `load`, which SvelteKit streams). Cite
`https://kit.svelte.dev/docs/load`.
4. **Move per-request work to `+server.ts` action handlers and run
them via `fetch` from the client.** Reduces SSR cost when only a
slice of the page actually needs server data on every request.
5. **`hooks.server.ts` matcher hygiene.** Like Next.js middleware, the
`handle` hook intercepts every request unless filtered. Heavy
`handle` code multiplies cost by request volume. Move work into the
specific route's `load` when only that route needs it.
6. **Adapter runtime + region config.** Single-region default; if the
project's users skew to a different region, set `regions: [...]` on
the adapter to reduce TTFB by 100-300ms.
## Frequent gotchas
- **Per-route SSR when prerender would do.** Marketing pages, docs,
blog posts often end up as functions because nobody added
`prerender = true`. The scanner flags these.
- **`+layout.server.ts` data fetches blocking every child route.**
Auth-check + user-load in a layout makes EVERY function invocation
wait on those queries — even routes that don't read user. Push
user-load into the routes that need it.
- **Adapter version drift.** `adapter-vercel@5` adds new options (ISR,
split). `adapter-vercel@3` doesn't. The recommender must check the
installed version before suggesting `isr: ...`.
- **`fetch` calls in `load` to your own SvelteKit routes.** SvelteKit
optimizes these into direct module calls during SSR, but only if
the URL is relative. A hardcoded `https://your-domain.tld/api/...`
defeats this optimization.
- **No connection pooling on serverless.** Same as Next.js — Postgres
without a pooler exhausts the database under load.
## Cross-references
- `https://kit.svelte.dev/docs/adapter-vercel` — adapter config (ISR, regions, runtime)
- `https://kit.svelte.dev/docs/page-options` — prerender, ssr, csr
- `https://kit.svelte.dev/docs/load` — parallel fetches in load
- `https://kit.svelte.dev/docs/routing` — file conventions
- `https://kit.svelte.dev/docs/hooks` — handle / handleFetch
- `https://kit.svelte.dev/docs/form-actions` — server-side form handling
- `https://kit.svelte.dev/docs/state-management` — request-scoped state
- `https://vercel.com/docs/incremental-static-regeneration` — ISR on Vercel
- `https://vercel.com/docs/fluid-compute` — Fluid Compute (framework-agnostic)
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 |