SvelteKit WebApp — SvelteKit 应用
v1.1.1SvelteKit Web 应用开发工具。
详细分析 ▾
运行时依赖
版本
Updated skill
安装命令 点击复制
技能文档
Scaffold production-ready SvelteKit PWAs with opinionated defaults and guided execution.
Quick 开始
- Describe app — Tell me 什么 您 want 到 build
- Review PRD — I'll generate plan 带有 用户 stories
- Approve — I build, test, 和 deploy 带有 oversight
- 已完成 — 获取 live URL + 管理员 documentation
"Build me a task tracker with due dates and priority labels"
That's all I need to start. I'll ask follow-up questions if needed.
Prerequisites
These CLIs must be available (the skill will verify during preflight):
| CLI | Purpose | Install |
|---|---|---|
sv | SvelteKit scaffolding | npm i -g sv (or use via pnpx) |
pnpm | Package manager | npm i -g pnpm |
gh | GitHub repo creation | cli.github.com |
vercel | Deployment | npm i -g vercel |
turso— Turso 数据库 CLI
Opinionated Defaults
This skill ships with sensible defaults that work well together. All defaults can be overridden via SKILL-CONFIG.json:
- 组件 库: Skeleton (Svelte 5 native) + Bits UI fallback
- 包 manager: pnpm
- Deployment: Vercel
- 添加-ons: ESLint, Prettier, Vitest, Playwright, mdsvex, MCP
- State: Svelte 5 runes ($state, $derived, $effect)
See User Configuration for override details.
用户 Configuration
Check ~/.openclaw/workspace/SKILL-CONFIG.json for user-specific defaults before using skill defaults. User config overrides skill defaults for:
- Deployment provider (e.g., vercel, cloudflare, netlify)
- 包 manager (pnpm, npm, yarn)
- 添加-ons 到 always include
- MCP IDE configuration
- 组件 库 preferences
Workflow Overview
- Gather: Freeform description + design references + targeted 关注-ups
- Plan: Generate complete PRD (scaffold, configure, features, tests 作为 stories)
- Iterate: Refine PRD 带有 用户 until confirmed
- Preflight: 验证 所有 必填 auths 和 credentials
- Execute: Guided build-deploy-验证 cycle 带有 用户 checkpoints (development → staging → production)
Phase 1: Gather Project Description
A conversational, iterative approach to understanding what the user wants.
1a. Freeform Opening
Start with an open question:
- "什么 做 您 want 到 build?"
- "Describe webapp 您 有 在...中 mind"
Let the user lead with what matters to them.
1b. Design References
Ask for inspiration:
Share 1-3 sites you'd like this to feel like
(design, functionality, or both).Examples:
- "Like Notion but simpler"
- "Fieldwire's mobile-first approach"
- "Linear's clean aesthetic"
"Show me what you like" communicates more than paragraphs of description.
1c. Visual Identity (可选)
If design references suggest custom branding, ask:
Any specific colors, fonts, or logos you want to use?
(I can pre-configure the Tailwind theme)
1d. Targeted 关注-ups
Based on gaps in the description, ask specifically:
| Gap | Question |
|---|---|
| Users unclear | "Who's the primary user? (role, context)" |
| Core action unclear | "What's the ONE thing they must be able to do?" |
| Content unknown | "Any existing content/assets to incorporate?" |
| Scale unknown | "How many users do you expect? (ballpark)" |
| Timeline | "Any deadline driving this?" |
1e. Structured Summary
Before proceeding, confirm understanding:
📝 PROJECT SUMMARY: [Name]Purpose: [one sentence]
Primary user: [who]
Core action: [what they do]
Design inspiration: [references]
Visual identity: [colors/fonts if specified]
Key features:
• [feature 1]
• [feature 2]
• [feature 3]
Technical signals detected:
• Database: [yes/no] — [reason]
• Authentication: [yes/no] — [reason]
• Internationalization: [yes/no] — [reason]
Does this capture it? [Yes / Adjust]
Iterate until the user confirms.
Phase 2: Plan (Generate PRD)
Generate a complete PRD with technical stack, user stories, and mock data strategy.
Technical Stack
Always Included:
CLI: pnpx sv (fallback: npx sv)
Template: minimal
TypeScript: yes
Package manager: pnpm (fallback: npm)Core add-ons (via sv add):
✓ eslint
✓ prettier
✓ mcp (claude-code)
✓ mdsvex
✓ tailwindcss (+ typography, forms plugins)
✓ vitest
✓ playwright
Post-scaffold:
✓ Skeleton (primary component library — Svelte 5 native, accessible)
✓ Bits UI (headless primitives — fallback for gaps/complex custom UI)
✓ vite-plugin-pwa (PWA support)
✓ Svelte 5 runes mode
✓ adapter-auto (auto-detects deployment target)
为什么 Skeleton + Bits UI?
- Skeleton: 满-featured 组件 库 built 对于 Svelte 5, accessible 由 默认
- Bits UI: Headless primitives 当...时 您 需要 更多 control 或 custom styling
- Both play well together — Skeleton 对于 speed, Bits 对于 flexibility
Inferred 从 Description:
drizzle → if needs database (ask: postgres/sqlite/turso)
lucia → if needs auth
paraglide → if needs i18n (ask: which languages)
State Management
Follow Svelte 5 best practices (see https://svelte.dev/docs/kit/state-management):
- 使用
$state()runes 对于 reactive state - 使用
$derived()对于 computed values - 使用 Svelte's context API (
setContext/getContext) 对于 cross-组件 state - Server state flows 通过
加载functions →dataprop - Never store 用户-specific state 在...中 模块-level variables (shared 穿过 requests)
Code 样式 Preferences
Check SKILL-CONFIG.json for user preferences. Common patterns:
- Prefer
bind:在...上 callbacks — 对于 child→parent data flow, 使用bind:值代替 的onchange回调 props. 更多 declarative, 更少 boilerplate. - Avoid
onMount— 使用$effect()对于 side effects. 's reactive 和 works 带有 SSR. - Runes everywhere —
$state(),$derived(),$effect()在...上 legacy stores 和 lifecycle hooks. - Small components — 默认 soft limit 的 ~200 lines per 组件 (configurable 在...中 SKILL-配置.json). 如果 growing larger, extract sub-components. Small beautiful. 🤩
Directory Structure
sv create generates:
src/
├── routes/ # SvelteKit routes
├── app.html # HTML template
├── app.d.ts # Type declarations
└── app.css # Global styles
static/ # Static assets
We add:
src/
├── lib/
│ ├── components/ # Reusable components (Skeleton + Bits UI)
│ ├── server/ # Server-only code (db client, auth)
│ ├── stores/ # Svelte stores (.svelte.ts for runes)
│ ├── utils/ # Helper functions
│ └── types/ # TypeScript types
static/
└── icons/ # PWA icons
用户 Stories (prd.json)
Story structure:
{
"project": "ProjectName",
"branchName": "dev",
"description": "Brief description",
"userStories": [
{
"id": "US-001",
"title": "Scaffold project",
"description": "Set up the base SvelteKit project.",
"acceptanceCriteria": [...],
"priority": 1,
"passes": false,
"blocked": false,
"notes": ""
}
]
}
Story sizing rule: 每个 story 必须 fit 在...中 one context window. 如果 feels big, split .
Standard story sequence:
- Scaffold —
pnpx sv 创建, 添加 core 添加-ons - Configure — Skeleton + Bits UI, PWA, directory structure, VSCode workspace, Tailwind 主题
- Mock Data — 设置 up mock 数据库/fixtures 对于 development
- Foundation — Root 布局, design tokens, home page (索引 PAGE CHECKPOINT)
- Features — Core features 从 gathered requirements
- Infrastructure — 数据库 schema, migrations, auth (如果 needed)
- Polish — PWA manifest, icons
- Tests — E2E tests 对于 critical flows
索引 Page Checkpoint: 之后 索引/home page built (但是 之前 其他 pages), 暂停 execution 和 请求 用户 review. 索引 page establishes visual direction—getting early feedback 这里 avoids wasted work 在...上 subsequent pages.
See references/scaffold-stories.md for story templates.
Mock Data Strategy
Development uses mock data; production uses real database.
Mock data approach:
- Generate mock data per-story as needed
- Store in src/lib/server/mocks/ or use MSW for API mocking
- E2E tests run against mock data locally
- Stage 2+ switches to real database
When drizzle is selected, include stories for:
- Initial schema creation
- Drizzle Kit configuration
- 第一个 migration
External Dependencies
Identify required credentials:
| Feature | Dependency | Required |
|---|---|---|
| Any project | GitHub CLI | Yes |
| Deployment | Vercel CLI or adapter-auto | Yes |
| Database (postgres) | DATABASE_URL | For staging |
| Database (turso) | Turso CLI | For staging |
| OAuth providers | Client ID/Secret | For staging |
| Payments | Stripe API keys | For staging |
Phase 3: Iterate Until Confirmed
Present the PRD and refine until the user approves.
Present PRD
📋 PRD: [Project Name]TECHNICAL STACK:
✅ Always: TypeScript, Tailwind, Skeleton + Bits UI, ESLint,
Prettier, Vitest, Playwright, PWA
🔍 Inferred:
[✓/✗] Database (drizzle) - [reason]
[✓/✗] Authentication (lucia) - [reason]
[✓/✗] Internationalization (paraglide) - [reason]
USER STORIES: [N] stories
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
US-001: Scaffold project (Setup)
US-002: Configure Skeleton + Bits UI (Setup)
US-003: Set up mock data (Setup)
US-004: Create root layout (Foundation)
[... feature stories ...]
US-XXX: Configure PWA manifest (Polish)
US-XXX: Add E2E tests (Tests)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔐 External dependencies:
• GitHub CLI (required now)
• Vercel CLI (required now)
• DATABASE_URL (required for staging)
• [others for staging]
[Approve / See full stories / Edit stories / Change stack]
Iteration 循环
Expect refinement. Common adjustments:
- 添加/移除/修改 用户 stories
- 更改 technical stack choices
- Adjust story priorities
- Split stories too large
- 添加 acceptance criteria
Continue iterating until 用户 explicitly approves.
Confirmation
When user approves:
✅ PRD CONFIRMED[N] user stories ready for execution.
Proceeding to preflight checks...
Phase 4: Preflight
Verify all dependencies. Development can start with mocks; staging needs real credentials.
Run Checks
Verify authentication for required CLIs (GitHub, pnpm, Vercel, and optionally Turso). See references/cli-commands.md for specific commands.
Present Status
┌─────────────────────────────────────────────┐
│ 🔐 PREFLIGHT CHECK │
├─────────────────────────────────────────────┤
│ For development (Stage 1): │
│ ✓ GitHub CLI authenticated │
│ ✓ pnpm installed │
│ ✓ Write access verified │
│ │
│ For staging (Stage 2): │
│ ✓ Vercel CLI authenticated │
│ ✗ DATABASE_URL not set │
│ │
│ ─────────────────────────────────────────── │
│ Development can start now. │
│ DATABASE_URL needed before Stage 2. │
│ │
│ [Start development / Resolve all first] │
└─────────────────────────────────────────────┘
Resolution
- Development 可以 proceed 带有 mock data
- Staging credentials 可以 resolved 期间 Stage 1
- Production credentials verified 之前 Stage 3
Phase 5: Execute
Guided build-deploy-verify cycle with user checkpoints and live progress updates.
EXECUTE
├── Stage 1: Development (local, dev branch, mock data)
│ └── Build all features, tests pass locally
│
├── Stage 2: Staging (main branch, preview URL, real data)
│ └── Deploy, fix environment issues, tests pass on preview
│
└── Stage 3: Production (permanent URL)
└── Connect domain, final verification, handoff
Live progress updates: 举报 每个 已完成 story:
✅ US-001: Scaffold project
✅ US-002: Configure Skeleton + Bits UI
✅ US-003: Set up mock data
⏳ US-004: Create root layout (in progress)
Stage 1: Development
Build everything locally with mock data.
Setup
Initialize a git repository on a dev branch and create a progress.txt tracking file. See references/cli-commands.md for commands.
Execute Stories 通过 Sub-Agents
Use sessions_spawn to execute stories in parallel where dependencies allow.
Wave structure:
- Wave 1: Scaffold (必须 complete 第一个)
- Wave 2: Configure (shadcn, PWA, directories) — parallel
- Wave 3: Mock data setup
- Wave 4+: Feature stories — parallel 在哪里 independent
- Final wave: E2E test stories
Sub-agent task 模板:
Implement user story [US-XXX] for SvelteKit project at [project_path].Story: [title]
Description: [description]
Acceptance Criteria:
- [criterion 1]
- [criterion 2]
- Typecheck passes
Instructions:
- Read progress.txt for codebase patterns
- Implement with minimal, focused changes
- Use Svelte 5 runes for state ($state, $derived, $effect)
- Use context API for cross-component state
- Follow Conventional Commits: "feat: [US-XXX] - [title]"
- Run
pnpm check to verify
- Update prd.json: passes: true
- Append learnings to progress.txt
Handling Blocked Stories
If a story cannot be completed:
- Mark 作为
blocked: 真在...中 prd.json - 添加 explanation 到
notes字段 - Continue 带有 其他 parallelizable stories
- 举报 blocked stories 在...中 final summary
Stage 1 Exit Criteria
All checks must pass before proceeding: TypeScript verification, unit tests, and E2E tests against the local dev server with mocks. See references/cli-commands.md for commands.
Stage 2: Staging
Push to main, deploy to preview, switch from mocks to real data.
验证 Staging Credentials
Before proceeding, ensure all staging credentials are set:
- DATABASE_URL (如果 使用 数据库)
- OAuth client ID/secret (如果 使用 auth)
- 其他 API keys
If missing, pause and request from user.
Deploy 通过 GitHub-Vercel Integration
One-时间 setup (recommended 在...上 CLI deploys):
Create a private GitHub repository, link to a Vercel project, and connect GitHub in the Vercel dashboard (Settings → Git → Connect Git Repository). Set the production branch to main. See references/cli-commands.md for commands.
Benefits 的 GitHub integration:
- 推送 到 deploy (否 CLI needed 之后 setup)
- Automatic 预览 URLs 对于 所有 branches
- Persistent branch URLs:
[project]-git-dev-[team].vercel.app - Better CI/CD visibility 在...中 both dashboards
Deploy 到 staging:
Merge the dev branch into main and push. The push triggers Vercel to build and deploy automatically. See references/cli-commands.md for commands.
Dev branch 预览 URL:
After connecting GitHub, the dev branch gets a persistent preview URL:
https://[project]-git-dev-[team].vercel.app
This URL stays the same across commits—great for sharing with stakeholders.
Fix Environment Issues
Common issues in deployed environments:
- OAuth 回调 URLs (必须 match deployed domain)
- CORS configuration
- Environment variables 不 设置 在...中 Vercel
- 数据库 连接 strings
- API endpoints 使用 localhost
Smart 重试 logic:
- Diagnose 错误 类型 从 stdout/stderr
- Attempt fix based 在...上 错误:
pnpm install
- 类型 错误 → analyze pnpm check 输出
- Test failure → re-run 带有 verbose logging
- Network/超时 → wait 30s, 重试
- Escalate 之后 3 失败 attempts
Stage 2 Exit Criteria
E2E tests must pass against the Vercel preview URL. See references/cli-commands.md for commands.
Stage 3: Production
Deploy to production URL and hand off to user.
Deploy Production
With GitHub-Vercel integration, production deploys automatically when you push to main. Custom domains can be configured via the Vercel dashboard (Settings → Domains) or CLI. See references/cli-commands.md for commands.
Final Verification
Run E2E tests against the production URL to confirm everything works. See references/cli-commands.md for commands.
Completion 举报
🚀 DEPLOYEDRepository: github.com/[user]/[project-name]
Live URL: https://[production-url]
Build Summary:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Stories completed: [N]/[N]
Blocked stories: [list if any]
Tests passing: [X] unit, [Y] E2E
Deployment: Vercel production
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
The app is live and ready for users.
Phase 6: Handoff
Provide lifecycle management documentation.
Generate 管理员 Manual
Create ADMIN.md in project root:
# [Project Name] — Administration GuideRunning Locally
\\\bash
pnpm install
pnpm dev # Start dev server at localhost:5173
\\\
Environment Variables
Copy .env.example to .env and configure:
- DATABASE_URL: [description]
- [other vars]
Set these in Vercel dashboard for production.
Project Structure
\\\
src/
├── routes/ # Pages and API routes
├── lib/components/ # UI components (Skeleton + Bits UI)
├── lib/server/ # Server-only code
└── lib/stores/ # State management
\\\
Adding New Pages
- Create
src/routes/[page-name]/+page.svelte
- Add server data loading in
+page.server.ts
- Run
pnpm check to verify types
Database Migrations
\\\bash
pnpm drizzle-kit generate # Generate migration
pnpm drizzle-kit push # Apply to database
\\\
Deployment
Push to main branch → auto-deploys to Vercel.
Troubleshooting
- Type errors: Run
pnpm check
- Test failures: Run
pnpm test:e2e --debug
- Build issues: Check Vercel deployment logs
举报 Handoff
📖 HANDOFF COMPLETEAdmin manual: ADMIN.md
- How to run locally
- Environment variable setup
- Project structure overview
- Adding new pages
- Database migrations
- Deployment workflow
- Troubleshooting guide
The project is ready for ongoing development.
错误 Handling
If any stage fails and cannot be automatically resolved:
- Diagnose: Analyze 错误 输出
- Categorize:
pnpm install
- 类型 错误 → show specific errors
- Test failure → show failing tests
- Network → 重试 带有 backoff
- 重试: Up 到 3 attempts 带有 appropriate fix
- Escalate: 举报 到 用户 带有:
Never leave project broken. 如果 Stage 2/3 fails, dev branch 仍然 works.
Quick Reference
For all CLI commands and auth checks, see references/cli-commands.md.
默认 Adapter
Use adapter-auto — automatically detects:
- Vercel → adapter-vercel
- Cloudflare → adapter-cloudflare
- Netlify → adapter-netlify
- 否则 → adapter-节点
数据库 Options (drizzle)
postgresql+postgres.js或neonsqlite+better-sqlite3或libsqlturso+@libsql/client
免费技能或插件可能存在安全风险,如需更匹配、更安全的方案,建议联系付费定制