AgentLint 实测验证 100/100实证最佳实践起步模板(基于 TypeScript 仓库规则)
SvelteKit(Svelte 5) CLAUDE.md & AGENTS.md 模板
Svelte 5 Runes($state/$derived)、svelte-check 类型检查与服务端私密模块边界。
# SvelteKit Project — Svelte 5 Harness SvelteKit + Svelte 5 + TypeScript web application verified with `svelte-check`, Vitest, and ESLint. ## Commands - Install: `pnpm install --frozen-lockfile` - Fast single test: `npx vitest run src/lib/server/billing.test.ts` - Full unit suite: `pnpm test` - Typecheck & lint: `pnpm exec svelte-check --tsconfig ./tsconfig.json && pnpm lint` - Production build: `pnpm build` ## Rules - Don't mix Svelte 4 `export let` or `$:` syntax into Svelte 5 runes components. Instead use `$props()`, `$state()`, and `$derived()`. Because mixing reactive paradigms breaks runes mode compilation. - Don't import database clients or `$env/static/private` inside universal `+page.ts` or `.svelte` files. Instead place secret logic inside `+page.server.ts` or `src/lib/server/`. Because universal modules bundle into client JavaScript. - Don't skip `svelte-check` after editing `+page.server.ts` load return types. Because generated `./$types` catches route contract breaks before build. - When editing form actions or hooks, read `docs/sveltekit-hooks.md` first. ## Continuity & Safety - Keep `.env*`, `.svelte-kit/`, and `CLAUDE.local.md` in `.gitignore`. - Record passing `svelte-check` and Vitest outputs in `HANDOFF.md`.
SvelteKit(Svelte 5) 开源生态中最常采用的工程规则
参考 4,533 仓库研究中对应主语言生态的高频工程规则采纳率,并结合框架核心防踩坑约束:
tailwindcss工具链
Tailwind CSS styling (measured in 1,533 TypeScript corpus repos)
38.8%595 个仓库
unit-tests测试
Server loader and component tests (1,533 TS corpus repos)
37.6%577 个仓库
eslint工具链
ESLint + eslint-plugin-svelte (1,533 TS corpus repos)
36.9%565 个仓库
vitest测试
Vitest for fast unit testing (1,533 TS corpus repos)
32.6%499 个仓库
必写验证命令(对应规则 W1 与 W7)
- 安装依赖
- pnpm install --frozen-lockfile
- 快速单测(秒级迭代)
- npx vitest run src/lib/server/auth.test.ts
- 全量测试
- pnpm test
- Lint 与静态检查
- pnpm exec svelte-check --tsconfig ./tsconfig.json && pnpm lint
- 生产构建
- pnpm build
SvelteKit(Svelte 5) 项目中 AI 代理常见踩坑
- 01在 Svelte 5 runes 组件里混写旧版 Svelte 4
export let与$:语法导致编译冲突。 - 02在通用
+page.ts或.svelte中误导入$env/static/private或数据库客户端,泄露服务端代码。 - 03改完
+page.server.ts返回结构后漏跑svelte-check,错过./$types契约破坏。