pattern-engineer-vite
Skill0 starsChanged 5 months agoMITView on GitHub
Vite implementation bullets: pick Vite for pure CSR (no SSR/SSG/SEO); env vars via `import.meta.env` with `VITE_` prefix (NOT a security boundary); `vite-plugin-checker` or `tsc --noEmit` in CI — `vite build` does not type-check; `vite-tsconfig-paths` over hand-rolled aliases; `build.sourcemap: false` in prod; `server.host: true` for containerized dev; avoid barrel files; route-boundary splitting via `lazy()` + `<Suspense>`. Activate when editing `vite.config.*` or scaffolding a Vite React app.
- Reads credentials
In this repository74 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- create-bug-issueSkill
- create-enhancement-issueSkill
- create-feature-issuesSkill
- dream-summary-memorySkill
- memory-conventionSkill
- operation-gitSkill
- pattern-architect-api-endpointSkill
- pattern-architect-data-modelSkill
- pattern-architect-deep-moduleSkill
- pattern-e2e-coding-standardSkill
- pattern-engineer-apiSkill
- pattern-engineer-backend-standardSkill
- pattern-engineer-coding-standardSkill
- pattern-engineer-containerSkill
- pattern-engineer-databaseSkill
- pattern-engineer-fastapiSkill
- pattern-engineer-frontend-standardSkill
- pattern-engineer-goSkill
- pattern-engineer-javaSkill
- pattern-engineer-kotlinSkill
- pattern-engineer-nodeSkill
- pattern-engineer-non-functionalSkill
- pattern-engineer-observabilitySkill
- pattern-engineer-pythonSkill
- pattern-engineer-rustSkill
- pattern-engineer-securitySkill
- pattern-engineer-ssrSkill
- pattern-engineer-swiftSkill
- pattern-engineer-typescriptSkill
- pattern-exploratory-testingSkill
- pattern-reviewer-apiSkill
- pattern-reviewer-backend-standardSkill
- pattern-reviewer-coding-standardSkill
- pattern-reviewer-containerSkill
- pattern-reviewer-contractSkill
- pattern-reviewer-databaseSkill
- pattern-reviewer-fastapiSkill
- pattern-reviewer-frontend-standardSkill
- pattern-reviewer-goSkill
- pattern-reviewer-javaSkill
- pattern-reviewer-kotlinSkill
- pattern-reviewer-nodeSkill
- pattern-reviewer-non-functionalSkill
- pattern-reviewer-observabilitySkill
- pattern-reviewer-pythonSkill
- pattern-reviewer-rustSkill
- pattern-reviewer-securitySkill
- pattern-reviewer-ssrSkill
- pattern-reviewer-swiftSkill
- pattern-reviewer-test-coverageSkill
- pattern-reviewer-typescriptSkill
- pattern-reviewer-viteSkill
- pattern-test-coverageSkill
- principle-engineer-tddSkill
- scaffold-projectSkill
- workflow-architect-interviewSkill
- workflow-designer-sample-pagesSkill
- workflow-design-interviewSkill
- workflow-e2e-authorSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
11 rules. About 0 are common, 2 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
After loading this skill, also check $MAIN_ROOT/.claude/memory/patterns/pattern-engineer-vite.md in the consuming project (resolve …
- Very specific: line 22
Don't reach for Next.js "just in case." If today's requirements are CSR-only, ship Vite.
- Very specific: line 28
Read each import.meta.env.VITE_* through a single typed accessor module so the call site doesn't repeat the prefix.
- Very specific: line 36
Don't put route-specific logic in vite.config — that belongs in the app code.
- Very specific: line 38
Use vite-tsconfig-paths instead of hand-rolling resolve.alias entries that already exist in tsconfig.json paths — one source of truth.
- Very specific: line 39
Add vite-plugin-checker (or run tsc --noEmit in CI).
- Very specific: line 46
Use Vitest for unit tests.
- Distinctive: line 56
Don't lazy-load the landing route — it pays cost on the critical path.
- Very specific: line 60
Import images / fonts as ES modules to get hashed URLs: import logoUrl from './logo.svg'.
- Very specific: line 66
Avoid barrel files (index.ts re-exporting everything from a directory) — importing one symbol forces Vite to load every re-export.
- Distinctive: line 72
Don't override the port via shell env to dodge a one-time conflict — that's the slice-isolation rule from the engineer-pre-push hook, not a …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
pattern-engineer-vite
When to activate
Activate when editing vite.config.ts / vite.config.js, vitest.config.ts, scaffolding a Vite-based React app, switching between Vite and Next.js, configuring dev-server proxy / plugins / aliases, or touching import.meta.env. Skip for Next.js apps (use Next-specific patterns instead) or non-frontend code.
Project memory overlay
After loading this skill, also check $MAIN_ROOT/.claude/memory/patterns/pattern-engineer-vite.md in the consuming project (resolve MAIN_ROOT="$(dirname "$(git rev-parse --path-format=absolute --git-common-dir)")"). If present, load it as an additive overlay to the rules below; if absent, skip silently. See memory-convention for the full contract (additivity, severity floor, conflict surfacing).
Patterns
Stack choice
- Pick Vite when the app is pure CSR: internal tools, dashboards behind auth, embedded widgets, prototypes, SPAs where SEO doesn't matter.
- Pick Next.js when the app needs SSR / SSG / ISR, edge runtime, file-based routing, server components, SEO-critical pages, image optimization, or first-class API routes.
- Don't reach for Next.js "just in case." If today's requirements are CSR-only, ship Vite; migrating later is straightforward.
Env vars
import.meta.env.VITE_<NAME>for env vars exposed to the client. TheVITE_prefix is mandatory — without it Vite won't inline the value.- Server-only secrets never get the
VITE_prefix (Vite refuses to expose them); they live in the backend. - Read each
import.meta.env.VITE_*through a single typed accessor module so the call site doesn't repeat the prefix. .env,.env.local,.env.<mode>.localare in.gitignore; only.env.example(placeholders) committed; mirror everyimport.meta.env.VITE_*key.loadEnv(mode, root, ['VITE_'])— always pass an explicit prefix list.loadEnv(mode, root, '')loads ALL env vars (including server secrets), and adefine: {...}mistake can then inline them into the client bundle.- The
VITE_prefix is NOT a security boundary. AnyVITE_*value is statically inlined into the shipped JS and trivially extractable; only public values (API URLs, feature flags, public keys) belong there.
Vite config
vite.config.tsowns: buildtarget(browser baseline),resolve.aliasfor@/..., dev-serverproxyto the backend,plugins(React, Tailwind, etc.),server.portif non-default needed.- Don't put route-specific logic in
vite.config— that belongs in the app code. - Proxy backend calls in dev:
server.proxy = { "/api": "http://localhost:8000" }so the SPA sees same-origin and cookies / CSRF work. - Use
vite-tsconfig-pathsinstead of hand-rollingresolve.aliasentries that already exist intsconfig.jsonpaths — one source of truth. - Add
vite-plugin-checker(or runtsc --noEmitin CI).vite buildtranspiles but does not type-check; type errors silently ship. build.sourcemap: falsefor production unless you upload to an error tracker (Sentry, Bugsnag). Public source maps leak the original code.- Containerized dev:
server.host: trueso the container binds0.0.0.0and the host can reach it. Defaultlocalhostbinding is unreachable from outside the container. - Clear
node_modules/.viteafter dep changes / branch switches with non-trivial dep diffs — the pre-bundle cache causes phantom errors when stale.
Vitest
- Use Vitest for unit tests; configure via
vitest.config.ts(or merge intovite.config.tswithdefineConfig). test.globals: trueif the project uses globals; matchingcompilerOptions.typesentry for TS.test.environment: 'jsdom'for component tests;'node'for pure-logic tests.- Setup file (
vitest.setup.ts) registers@testing-library/jest-dommatchers, MSW handlers, etc. vi.mock(...)only when there is no seam to inject a fake; prefer dependency injection.
Code splitting
- Split at route boundaries via
lazy(() => import('./pages/Settings'))paired with a meaningful<Suspense fallback={<PageSkeleton />}>. - Heavy conditional UI (modals, editors, charts) lazy-loads too; tiny components don't.
- Don't lazy-load the landing route — it pays cost on the critical path.
Static assets
- Import images / fonts as ES modules to get hashed URLs:
import logoUrl from './logo.svg'. - Public assets that need a stable URL go in
public/(served as-is, no hashing). ?url/?raw/?workerquery-suffix imports for explicit handling.
Module-resolution performance
- Avoid barrel files (
index.tsre-exporting everything from a directory) — importing one symbol forces Vite to load every re-export. This is the #1 dev-server slowdown. - Be explicit with import extensions (
./Component.tsx, not./Component); each implicit extension triggers up to 6 filesystem checks viaresolve.extensions.
Dev server
server.portdefaults to 5173; override invite.config.ts(committed) only if the standard collides with another local service.- Don't override the port via shell env to dodge a one-time conflict — that's the slice-isolation rule from the engineer-pre-push hook, not a permanent config change.
- HMR works out of the box; don't disable it.
Building for production
npm run buildproduces hashed assets indist/.- The container image's
finalstage copiesdist/into nginx. vite previewis for sanity-checking the built bundle locally; never servepreviewin production.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

