SvelteKit Webapp Skill
Scaffold production-ready SvelteKit PWAs with opinionated defaults and guided execution.
Quick Start
- 1. Describe your app — Tell me what you want to build
- Review the PRD — I'll generate a plan with user stories
- Approve — I build, test, and deploy with your oversight
- Done — Get a live URL + admin 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 |
|---|
| INLINECODE0 | SvelteKit scaffolding | INLINECODE1 (or use via pnpx) |
| INLINECODE3 |
Package manager |
npm i -g pnpm |
|
gh | GitHub repo creation |
cli.github.com |
|
vercel | Deployment |
npm i -g vercel |
Optional (if features require):
- -
turso — Turso database CLI
Opinionated Defaults
This skill ships with sensible defaults that work well together. All defaults can be overridden via SKILL-CONFIG.json:
- - Component library: Skeleton (Svelte 5 native) + Bits UI fallback
- Package manager: pnpm
- Deployment: Vercel
- Add-ons: ESLint, Prettier, Vitest, Playwright, mdsvex, MCP
- State: Svelte 5 runes ($state, $derived, $effect)
See User Configuration for override details.
User 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)
- Package manager (pnpm, npm, yarn)
- Add-ons to always include
- MCP IDE configuration
- Component library preferences
Workflow Overview
- 1. Gather: Freeform description + design references + targeted follow-ups
- Plan: Generate complete PRD (scaffold, configure, features, tests as stories)
- Iterate: Refine PRD with user until confirmed
- Preflight: Verify all required auths and credentials
- Execute: Guided build-deploy-verify cycle with user 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:
- - "What do you want to build?"
- "Describe the webapp you have in mind"
Let the user lead with what matters to them.
1b. Design References
Ask for inspiration:
CODEBLOCK0
"Show me what you like" communicates more than paragraphs of description.
1c. Visual Identity (Optional)
If design references suggest custom branding, ask:
CODEBLOCK1
1d. Targeted Follow-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?" |
Only ask what's missing—don't interrogate.
1e. Structured Summary
Before proceeding, confirm understanding:
CODEBLOCK2
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:
CODEBLOCK3
Why Skeleton + Bits UI?
- - Skeleton: Full-featured component library built for Svelte 5, accessible by default
- Bits UI: Headless primitives when you need more control or custom styling
- Both play well together — Skeleton for speed, Bits for flexibility
Inferred from Description:
CODEBLOCK4
State Management
Follow Svelte 5 best practices (see https://svelte.dev/docs/kit/state-management):
- - Use
$state() runes for reactive state - Use
$derived() for computed values - Use Svelte's context API (
setContext/getContext) for cross-component state - Server state flows through
load functions → data prop - Never store user-specific state in module-level variables (shared across requests)
Code Style Preferences
Check SKILL-CONFIG.json for user preferences. Common patterns:
- - Prefer
bind: over callbacks — For child→parent data flow, use bind:value instead of onchange callback props. More declarative, less boilerplate. - Avoid
onMount — Use $effect() for side effects. It's reactive and works with SSR. - Runes everywhere —
$state(), $derived(), $effect() over legacy stores and lifecycle hooks. - Small components — Default soft limit of ~200 lines per component (configurable in SKILL-CONFIG.json). If growing larger, extract sub-components. Small is beautiful. 🤩
Directory Structure
INLINECODE26 generates:
CODEBLOCK5
We add:
CODEBLOCK6
User Stories (prd.json)
Story structure:
CODEBLOCK7
Story sizing rule: Each story must fit in one context window. If it feels big, split it.
Standard story sequence:
- 1. Scaffold —
pnpx sv create, add core add-ons - Configure — Skeleton + Bits UI, PWA, directory structure, VSCode workspace, Tailwind theme
- Mock Data — Set up mock database/fixtures for development
- Foundation — Root layout, design tokens, home page (INDEX PAGE CHECKPOINT)
- Features — Core features from gathered requirements
- Infrastructure — Database schema, migrations, auth (if needed)
- Polish — PWA manifest, icons
- Tests — E2E tests for critical flows
Index Page Checkpoint: After the index/home page is built (but before other pages), PAUSE execution and request user review. The index page establishes the visual direction—getting early feedback here avoids wasted work on subsequent pages.
See references/scaffold-stories.md for story templates.
Mock Data Strategy
Development uses mock data; production uses real database.
CODEBLOCK8
When drizzle is selected, include stories for:
- - Initial schema creation
- Drizzle Kit configuration
- First 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 |
Dev uses mocks; staging/production need real credentials.
Phase 3: Iterate Until Confirmed
Present the PRD and refine until the user approves.
Present the PRD
CODEBLOCK9
Iteration Loop
Expect refinement. Common adjustments:
- - Add/remove/modify user stories
- Change technical stack choices
- Adjust story priorities
- Split stories that are too large
- Add acceptance criteria
Continue iterating until user 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
CODEBLOCK11
Resolution
- - Development can proceed with mock data
- Staging credentials can be resolved during Stage 1
- Production credentials verified before Stage 3
Phase 5: Execute
Guided build-deploy-verify cycle with user checkpoints and live progress updates.
CODEBLOCK12
Live progress updates: Report each completed 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 via Sub-Agents
Use sessions_spawn to execute stories in parallel where dependencies allow.
Wave structure:
- - Wave 1: Scaffold (must complete first)
- Wave 2: Configure (shadcn, PWA, directories) — parallel
- Wave 3: Mock data setup
- Wave 4+: Feature stories — parallel where independent
- Final wave: E2E test stories
Sub-agent task template:
CODEBLOCK14
Handling Blocked Stories
If a story cannot be completed:
- 1. Mark as
blocked: true in prd.json - Add explanation to
notes field - Continue with other parallelizable stories
- Report blocked stories in 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.
Verify Staging Credentials
Before proceeding, ensure all staging credentials are set:
- - DATABASE_URL (if using database)
- OAuth client ID/secret (if using auth)
- Other API keys
If missing, pause and request from user.
Deploy via GitHub-Vercel Integration
One-time setup (recommended over 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 of GitHub integration:
- - Push to deploy (no CLI needed after setup)
- Automatic preview URLs for all branches
- Persistent branch URLs: INLINECODE35
- Better CI/CD visibility in both dashboards
Deploy to 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 preview URL:
After connecting GitHub, the dev branch gets a persistent preview URL:
INLINECODE39
This URL stays the same across commits—great for sharing with stakeholders.
Fix Environment Issues
Common issues in deployed environments:
- - OAuth callback URLs (must match deployed domain)
- CORS configuration
- Environment variables not set in Vercel
- Database connection strings
- API endpoints using localhost
Smart retry logic:
- 1. Diagnose error type from stdout/stderr
- Attempt fix based on error:
- Dependency error →
pnpm install
- Type error → analyze
pnpm check output
- Test failure → re-run with verbose logging
- Network/timeout → wait 30s, retry
- 3. Escalate after 3 failed 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 Report
CODEBLOCK15
Phase 6: Handoff
Provide lifecycle management documentation.
Generate Admin Manual
Create ADMIN.md in project root:
CODEBLOCK16
Report Handoff
CODEBLOCK17
Error Handling
If any stage fails and cannot be automatically resolved:
- 1. Diagnose: Analyze error output
- Categorize:
- Dependency →
pnpm install
- Type error → show specific errors
- Test failure → show failing tests
- Network → retry with backoff
- 3. Retry: Up to 3 attempts with appropriate fix
- Escalate: Report to user with:
- What failed
- What was tried
- Specific error messages
- Suggested manual resolution
Never leave the project broken. If Stage 2/3 fails, dev branch still works.
Quick Reference
For all CLI commands and auth checks, see references/cli-commands.md.
Default Adapter
Use adapter-auto — automatically detects:
- - Vercel → adapter-vercel
- Cloudflare → adapter-cloudflare
- Netlify → adapter-netlify
- Otherwise → adapter-node
Database Options (drizzle)
- -
postgresql + postgres.js or INLINECODE48 - INLINECODE49 +
better-sqlite3 or INLINECODE51 - INLINECODE52 + INLINECODE53
SvelteKit Web应用技能
使用预设默认值和引导式执行,快速搭建生产就绪的SvelteKit渐进式Web应用。
快速开始
- 1. 描述你的应用 — 告诉我你想构建什么
- 审阅产品需求文档 — 我会生成包含用户故事的计划
- 批准 — 在你的监督下进行构建、测试和部署
- 完成 — 获得一个线上URL和管理文档
帮我构建一个带有截止日期和优先级标签的任务追踪器
这就是我需要开始的所有信息。如有需要,我会提出后续问题。
前置条件
以下CLI工具必须可用(技能会在预检阶段验证):
| CLI | 用途 | 安装方式 |
|---|
| sv | SvelteKit脚手架 | npm i -g sv(或通过pnpx使用) |
| pnpm |
包管理器 | npm i -g pnpm |
| gh | GitHub仓库创建 |
cli.github.com |
| vercel | 部署 | npm i -g vercel |
可选(如果功能需要):
预设默认值
本技能附带经过良好配合的合理默认值。所有默认值均可通过SKILL-CONFIG.json覆盖:
- - 组件库: Skeleton(Svelte 5原生)+ Bits UI后备
- 包管理器: pnpm
- 部署平台: Vercel
- 附加组件: ESLint、Prettier、Vitest、Playwright、mdsvex、MCP
- 状态管理: Svelte 5 runes($state、$derived、$effect)
查看用户配置了解覆盖详情。
用户配置
在使用技能默认值前,检查~/.openclaw/workspace/SKILL-CONFIG.json中的用户特定默认值。用户配置可覆盖技能默认值,涉及:
- - 部署提供商(如vercel、cloudflare、netlify)
- 包管理器(pnpm、npm、yarn)
- 始终包含的附加组件
- MCP IDE配置
- 组件库偏好
工作流程概览
- 1. 收集:自由格式描述 + 设计参考 + 针对性跟进
- 规划:生成完整的产品需求文档(脚手架、配置、功能、测试作为故事)
- 迭代:与用户一起完善产品需求文档直至确认
- 预检:验证所有必需的认证和凭据
- 执行:引导式构建-部署-验证循环,包含用户检查点(开发 → 预发布 → 生产)
阶段1:收集项目描述
采用对话式、迭代的方法来理解用户需求。
1a. 自由开场
以开放式问题开始:
让用户主导他们关心的事情。
1b. 设计参考
请求灵感:
分享1-3个你希望这个应用感觉像的网站
(设计、功能或两者兼有)。
示例:
- - 像Notion但更简单
- Fieldwire的移动优先方法
- Linear的简洁美学
告诉我你喜欢什么比大段描述更能传达信息。
1c. 视觉标识(可选)
如果设计参考暗示了自定义品牌,可以询问:
是否有任何特定的颜色、字体或Logo想要使用?
(我可以预先配置Tailwind主题)
1d. 针对性跟进
根据描述中的空白,具体提问:
| 空白 | 问题 |
|---|
| 用户不明确 | 主要用户是谁?(角色、场景) |
| 核心操作不明确 |
他们必须能够做到的
一件事是什么? |
| 内容未知 | 是否有任何现有内容/资源需要整合? |
| 规模未知 | 你预计有多少用户?(大致范围) |
| 时间线 | 是否有任何截止日期驱动? |
只问缺失的内容,不要审问。
1e. 结构化总结
在继续之前,确认理解:
📝 项目摘要:[名称]
目的:[一句话]
主要用户:[谁]
核心操作:[他们做什么]
设计灵感:[参考]
视觉标识:[颜色/字体(如果指定)]
关键功能:
• [功能1]
• [功能2]
• [功能3]
检测到的技术信号:
• 数据库:[是/否] — [原因]
• 认证:[是/否] — [原因]
• 国际化:[是/否] — [原因]
以上是否准确?[是 / 调整]
迭代直到用户确认。
阶段2:规划(生成产品需求文档)
生成包含技术栈、用户故事和模拟数据策略的完整产品需求文档。
技术栈
始终包含:
CLI: pnpx sv(后备:npx sv)
模板: 最小化
TypeScript: 是
包管理器: pnpm(后备:npm)
核心附加组件(通过sv add):
✓ eslint
✓ prettier
✓ mcp(claude-code)
✓ mdsvex
✓ tailwindcss(+ typography、forms插件)
✓ vitest
✓ playwright
脚手架后:
✓ Skeleton(主要组件库 — Svelte 5原生、可访问)
✓ Bits UI(无头原语 — 用于填补空白/复杂自定义UI的后备)
✓ vite-plugin-pwa(PWA支持)
✓ Svelte 5 runes模式
✓ adapter-auto(自动检测部署目标)
为什么选择Skeleton + Bits UI?
- - Skeleton:为Svelte 5构建的全功能组件库,默认可访问
- Bits UI:当需要更多控制或自定义样式时的无头原语
- 两者配合良好 — Skeleton用于速度,Bits用于灵活性
从描述中推断:
drizzle → 如果需要数据库(询问:postgres/sqlite/turso)
lucia → 如果需要认证
paraglide → 如果需要国际化(询问:哪些语言)
状态管理
遵循Svelte 5最佳实践(参见https://svelte.dev/docs/kit/state-management):
- - 使用$state() runes进行响应式状态
- 使用$derived()进行计算值
- 使用Svelte的上下文API(setContext/getContext)进行跨组件状态
- 服务器状态通过load函数 → data属性流动
- 永远不要在模块级变量中存储用户特定状态(跨请求共享)
代码风格偏好
检查SKILL-CONFIG.json中的用户偏好。常见模式:
- - 优先使用bind:而非回调 — 对于子→父数据流,使用bind:value代替onchange回调属性。更具声明性,更少样板代码。
- 避免使用onMount — 使用$effect()处理副作用。它是响应式的,并且支持SSR。
- 全面使用Runes — $state()、$derived()、$effect()替代传统存储和生命周期钩子。
- 小组件 — 每个组件默认软限制约200行(可在SKILL-CONFIG.json中配置)。如果变得更大,提取子组件。小即是美。🤩
目录结构
sv create生成:
src/
├── routes/ # SvelteKit路由
├── app.html # HTML模板
├── app.d.ts # 类型声明
└── app.css # 全局样式
static/ # 静态资源
我们添加:
src/
├── lib/
│ ├── components/ # 可复用组件(Skeleton + Bits UI)
│ ├── server/ # 仅服务器端代码(数据库客户端、认证)
│ ├── stores/ # Svelte存储(.svelte.ts用于runes)
│ ├── utils/ # 辅助函数
│ └── types/ # TypeScript类型
static/
└── icons/ # PWA图标
用户故事(prd.json)
故事结构:
json
{
project: 项目名称,
branchName: dev,
description: 简要描述,
userStories: [
{
id: US-001,
title: 脚手架项目,
description: 设置基础的SvelteKit项目。,
acceptanceCriteria: [...],
priority: 1,
passes: false,
blocked: false,
notes:
}
]
}
故事大小规则: 每个故事必须适合一个上下文窗口。如果感觉太大,就拆分。
标准故事序列:
- 1. 脚手架 — pnpx sv create,添加核心附加组件
- 配置 — Skeleton + Bits UI、PWA、目录