Sveltekit routing load review
Skill Raishin/vanguard-frontier-agentic/skills/frontend/sveltekit-routing-load-review
Statically review SvelteKit route files (+page.js, +page.server.js, +layout.js, +layout.server.js, +server.ts) to verify universal-vs-server load placement, catching server-only secrets, database clients, or privileged API access that would leak into or execute inside the browser.From its SKILL.md
npx -y skills add Raishin/vanguard-frontier-agentic --skill sveltekit-routing-load-reviewAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 20 stars20 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
6.4 KB, ~1.4k tokens by cl100k_base, as published. Nobody here has run it
SvelteKit Routing & Load Function Review
Purpose
Review SvelteKit route files for correct universal-vs-server load function placement without re-litigating progressive-enhancement UX, form-action design, or component styling in every response. This skill exists because SvelteKit's universal load functions (+page.js / +layout.js) run on the server for the initial SSR render and again in the browser on every subsequent client-side navigation — a fact that is routinely missed and turns a misplaced database call or secret reference into a client-side credential exposure, not just a style defect.
When to use
Use this skill when the user asks to:
- review a new or changed SvelteKit route's
loadfunctions before merge, - investigate a secret, database error, or unexpected network call surfacing in the browser console or network tab for a SvelteKit route,
- determine whether data-fetching for a given route is placed in the correct file (
+page.jsvs+page.server.js,+layout.jsvs+layout.server.js), - audit
+layout/+page/+serverfile precedence for a route tree.
Do not use this skill for:
- progressive-enhancement or
<form>action /use:enhanceUX review — usesveltekit-progressive-enhancement-reviewinstead, - pure component-internal state with no
loadfunction involved, - live performance profiling of load waterfalls — that needs runtime tracing, not static review.
Context7 Documentation Protocol
- Resolve the library ID with
resolve-library-id(matched result:/sveltejs/kit) before citing any SvelteKit-specific claim. - Before asserting the universal-vs-server execution model, call
query-docsagainst/sveltejs/kitfor "load functions" and quote the precise rule: a universalload(+page.js/+layout.js) runs on the server during SSR and hydration, then runs again in the browser on every subsequent client-side navigation (or always in the browser if SSR is disabled / the route is a SPA); a serverload(+page.server.js/+layout.server.js) always runs only on the server. If both exist for a route, the serverloadruns first and its return value becomes thedataproperty passed into the universalload. - Verify the SvelteKit major version installed in the repo (
package.json) before asserting version-specific behavior of$env/static/private/$env/dynamic/privateenforcement or server-only module protection — this has evolved across releases (private$env/*client-side imports were blocked starting in a 1.0-pre release). - If Context7 is unavailable, fall back to the
official_docsURLs in this skill'smetadata.jsonand label the claimdocumentation-based, unverified against current release. - Never assume a repo's SvelteKit config (
kit.env.privatePrefix, adapter,ssr/csrpage options) matches defaults without readingsvelte.config.jsand any per-route page-option exports — page options change when/whether a universalloadever runs on the server at all.
Lean operating rules
- First classify every load-bearing route file as universal (
+page.js,+layout.js) or server (+page.server.js,+layout.server.js) by filename suffix alone — never by guessing from content or route name. - Treat every universal
loadfunction as browser-reachable code, full stop. It is not "mostly server-side" or "server-side on first load" — SvelteKit re-runs it client-side on every subsequent navigation by default. - Do not assume SvelteKit's build-time
$env/static/private/$env/dynamic/privateimport guard catches every leak. It blocks direct imports of those modules from client-reachable files, but it does not catch manualprocess.envreads, a$lib/server-protected module re-exporting a secret through a non-.servermodule, or a secret being copied into the plain object a serverloadreturns. - Trace secrets and DB clients through the full import graph, including transitive
$libimports — a universalloadthat imports an innocuous-looking$lib/utils.jswhich itself imports$lib/server/db.jsis still a leak path (and SvelteKit's server-only module protection should catch that specific case at build time; verify it does, do not assume). - Treat any private value present in the plain object a server
load(or+layout.server.js) returns as a candidate leak the moment a universalload, a client component, orpage.data/$page.datacan read it — serverloadoutput crosses the server/client boundary via devalue serialization, it is not automatically safe just because it originated server-side. - Never mark a
+page.server.jsor+layout.server.jsfile itself as a browser-exposure risk for containing secrets or DB calls — those files are always server-only by SvelteKit's routing contract; the risk is in what they choose to return, not that they execute. - Do not flag deep or repeated
+layout.server.jslogic as a leak; flag it as a MEDIUM duplication/maintainability finding only, distinct from HIGH-severity leak findings. - Never execute, build, or run application code as part of this review; this is a static-review skill (Read/Grep/Glob only).
References
Load these only when needed:
- Review workflow and findings contract — use for the step-by-step review procedure, the leak-tracing decision tree, and the required output shape.
- Routing conventions — load only when
+layout/+page/+serverfile precedence or route-tree structure (not just load placement) is in question.
Response minimum
Return, at minimum:
- the route(s) and file(s) in scope, each labeled universal or server load,
- ranked findings with file:line evidence and the full import/data-flow trace for any leak finding,
- evidence level per finding (
repo evidence,documentation-based, orinference), - verdict (approve / approve-with-notes / block),
- open questions or scope the review could not cover (e.g., unverified
svelte.config.jsenv prefix, unread transitive$libmodule).
What ships with it: 3 files
13.0 KB alongside SKILL.md
references/
- routing-conventions.md4.4 KB
- workflow-and-output.md7.5 KB
- metadata.json1.1 KB