用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/svelte-society/sveltesociety.dev --skill admin-crud-page命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Patterns for building list and detail pages with forms, filters, and data fetching
Create SvelteKit components using Remote Functions for type-safe client-server communication. Use when building components that need to fetch data, submit forms, or execute server commands. Remote Functions work at the component level, not page level.
Create UI components using tailwind-variants for type-safe styling. Use when creating or editing components in src/lib/ui/.
基于 SOC 职业分类
正在显示 SKILL.md
| name | Admin CRUD Page |
| description | Create admin dashboard pages with tables, forms, and actions |
Use this skill when creating admin pages for managing entities.
Note: For general page patterns (forms, filters, pagination, remote functions), see page-builder.
Admin routes live in src/routes/(admin)/admin/:
src/routes/(admin)/admin/
└── [feature]/
├── +page.svelte # List page (pure renderer)
├── data.remote.ts # Remote functions (all logic here)
├── [id]/
│ └── +page.svelte # Edit page
└── new/
└── +page.svelte # Create page (optional)
IMPORTANT: Never use
+page.server.tsThis project uses Remote Functions exclusively for server-side logic. All data loading, form handling, and mutations must go through
.remote.tsfiles. Never create+page.server.ts,+server.ts, or use SvelteKit form actions.
| Component | Purpose | Import |
|---|---|---|
PageHeader | Page title with icon and actions | $lib/ui/admin/PageHeader.svelte |
Table | Data table with snippets for header/row/actions | $lib/ui/admin/Table.svelte |
AdminList | Simple wrapper with title and "New" button | $lib/ui/admin/AdminList.svelte |
StatusSelect | Status filter dropdown | $lib/ui/admin/StatusSelect.svelte |
TypeSelect | Content type filter | $lib/ui/admin/TypeSelect.svelte |
Badge | Status/type badges | $lib/ui/admin/Badge.svelte |
Actions | Row action buttons (edit, delete, custom) | $lib/ui/admin/Actions |
ContentPicker | Select related content | $lib/ui/admin/ContentPicker.svelte |
QuickAction | Dashboard quick action cards | $lib/ui/admin/QuickAction.svelte |
ConfirmWithDialog | Confirmation dialog wrapper | $lib/ui/admin/ConfirmWithDialog.svelte |
<script lang="ts">
import PageHeader from '$lib/ui/admin/PageHeader.svelte'
import Table from '$lib/ui/admin/Table.svelte'
import { Actions, Action } from '$lib/ui/admin/Actions'
import FileText from 'phosphor-svelte/lib/FileText'
import { getItems, deleteItem } from './data.remote'
const items = await getItems()
</script>
<div class="container mx-auto space-y-8 px-2 py-6">
<PageHeader
title="Items"
description="Manage all items"
icon={FileText}
/>
<Table action={true} data={items}>
{#snippet header(classes)}
<th class={classes}>Name</th>
<th class={classes}>Status</th>
{/snippet}
{#snippet row(item, classes)}
<td class={classes}>{item.name}</td>
<td class={classes}>{item.status}</td>
{/snippet}
{#snippet actionCell(item)}
<Actions id={item.id}>
<Action.Edit href={`/admin/items/${item.id}`} />
<Action.Delete form={deleteItem} />
</Actions>
{/snippet}
</Table>
</div>
<script lang="ts">
import { page } from '$app/state'
import PageHeader from '$lib/ui/admin/PageHeader.svelte'
import { initForm } from '$lib/utils/form.svelte'
import { updateItem, getItem } from '../data.remote'
import FileText from 'phosphor-svelte/lib/FileText'
const itemId = page.params.id!
const item = await getItem({ id: itemId })
initForm(updateItem, () => ({
id: itemId,
name: item?.name ?? '',
status: item?.status ?? 'draft'
}))
</script>
<div class="container mx-auto space-y-8 px-2 py-6">
<PageHeader
title="Edit Item"
description="Update item settings"
icon={FileText}
/>
<form {...updateItem} class="space-y-6">
<input {...updateItem.fields.id.as('hidden', itemId)} />
<!-- See page-builder/DETAIL-PAGE.md for form patterns -->
<button type="submit">Save</button>
</form>
</div>
Always call checkAdminAuth() first in admin remote functions:
import { checkAdminAuth } from '../authorization.remote'
export const getItems = query('unchecked', async (searchParams) => {
checkAdminAuth() // Throws if not admin
// ... rest of logic
})
For patterns that apply to both admin and public pages, see: