partykit
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "partykit":https://skillpi.com/zh/skills/deepskill-31b12ad9eb0679823b2f027f2357266ad9068274040f869247bdd28622a8f62f。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
使用 PartyKit 构建多人协作应用。适用于构建实时协作功能、创建多人体验、添加实时光标、实现协同编辑、创建实时投票或调查、跨客户端同步状态或在边缘构建 WebSocket 服务器等场景,涵盖 PartyServer 定义、客户端连接、状态管理、休眠机制及部署等内容。
介绍来源: third_party · TerminalSkills · 1.0.0 参考来源
SkillPi 解读
- 软件、账号及付费要求
- 贝什
- 实测状态
- 未测试
文件浏览
Frontmatter
name: partykit
description: >-
Build multiplayer and collaborative apps with PartyKit. Use when a user asks
to build real-time collaboration features, create multiplayer experiences,
add live cursors, build collaborative editing, create real-time voting or
polls, sync state across clients, or build WebSocket servers on the edge.
Covers PartyServer definition, client connections, state management,
hibernation, and deployment to Cloudflare.
license: Apache-2.0
compatibility: 'Node.js 18+ (deploys to Cloudflare Workers)'
metadata:
author: terminal-skills
version: 1.0.0
category: development
tags:
- partykit
- realtime
- multiplayer
- collaboration
- websocket
- edgePartyKit
Overview
PartyKit is a platform for building real-time, multiplayer, and collaborative applications. Each "party" is an isolated room running on Cloudflare's edge network — close to users for low latency. Unlike Socket.IO (which needs a persistent server), PartyKit runs serverless with automatic hibernation — you pay for active connections, not idle servers. Use it for collaborative editing, live cursors, multiplayer games, real-time polls, and any feature where multiple clients need synchronized state.
Instructions
Step 1: Setup
# Create new project
npm create partykit@latest my-party
cd my-party
# Or add to existing project
npm install partykit partysocket
# Start development server
npx partykit dev
# Server running at http://127.0.0.1:1999
Step 2: Define a Party Server
// party/index.ts — A PartyKit server (one instance per room)
import type * as Party from 'partykit/server'
export default class ChatRoom implements Party.Server {
// Shared state for this room
messages: Array<{ author: string; text: string; timestamp: number }> = []
constructor(readonly room: Party.Room) {}
onConnect(conn: Party.Connection, ctx: Party.ConnectionContext) {
/** Called when a client connects to this room. */
// Send existing messages to the new connection
conn.send(JSON.stringify({ type: 'history', messages: this.messages }))
// Notify others
this.room.broadcast(
JSON.stringify({ type: 'user-joined', connectionId: conn.id }),
[conn.id] // exclude the new connection
)
}
onMessage(message: string, sender: Party.Connection) {
/** Called when a client sends a message. */
const data = JSON.parse(message)
if (data.type === 'chat') {
const chatMessage = {
author: data.author,
text: data.text,
timestamp: Date.now(),
}
this.messages.push(chatMessage)
// Broadcast to all connections in this room
this.room.broadcast(JSON.stringify({ type: 'new-message', message: chatMessage }))
}
}
onClose(conn: Party.Connection) {
this.room.broadcast(JSON.stringify({ type: 'user-left', connectionId: conn.id }))
}
}
Step 3: Client Connection
// hooks/useParty.ts — React hook for PartyKit connection
import usePartySocket from 'partysocket/react'
export function useChatRoom(roomId: string, userName: string) {
const [messages, setMessages] = useState<ChatMessage[]>([])
const socket = usePartySocket({
host: process.env.NEXT_PUBLIC_PARTYKIT_HOST!,
room: roomId,
onMessage(event) {
const data = JSON.parse(event.data)
if (data.type === 'history') {
setMessages(data.messages)
} else if (data.type === 'new-message') {
setMessages(prev => [...prev, data.message])
}
},
})
const sendMessage = (text: string) => {
socket.send(JSON.stringify({ type: 'chat', author: userName, text }))
}
return { messages, sendMessage, readyState: socket.readyState }
}
Step 4: Live Cursors
// party/cursors.ts — Real-time cursor sharing (like Figma)
import type * as Party from 'partykit/server'
type Cursor = { x: number; y: number; name: string; color: string }
export default class CursorRoom implements Party.Server {
cursors = new Map<string, Cursor>()
constructor(readonly room: Party.Room) {}
onMessage(message: string, sender: Party.Connection) {
const cursor: Cursor = JSON.parse(message)
this.cursors.set(sender.id, cursor)
// Broadcast cursor position to everyone else
this.room.broadcast(
JSON.stringify({ id: sender.id, ...cursor }),
[sender.id]
)
}
onClose(conn: Party.Connection) {
this.cursors.delete(conn.id)
this.room.broadcast(JSON.stringify({ id: conn.id, gone: true }))
}
}
Step 5: Deploy
# Deploy to Cloudflare's edge network
npx partykit deploy
# Custom domain
npx partykit deploy --domain my-party.example.com
# Environment variables
npx partykit env add OPENAI_API_KEY
Examples
Example 1: Add collaborative editing to a document app
User prompt: "Add real-time collaboration to our note-taking app — multiple users editing the same document with live cursors."
The agent will:
- Create a PartyKit server that manages document state and cursor positions.
- Use CRDT (Yjs) for conflict-free concurrent editing.
- Add cursor presence showing each editor's position and name.
- Deploy to Cloudflare's edge for global low-latency access.
Example 2: Build a live polling/voting feature
User prompt: "Add real-time polls to our presentation tool. Audience votes on their phones, results update live on the presenter's screen."
The agent will:
- Create a party room per poll with vote state.
- Audience connects via phone, casts votes.
- Presenter view receives real-time vote count updates.
- Results animate as votes come in.
Guidelines
- Each room is an isolated instance — state is not shared between rooms. Use room IDs to partition data (one room per document, per game session, per chat channel).
- PartyKit hibernates rooms with no active connections — you're not paying for idle rooms. State persists in the room object while connections exist.
- For persistent state (survive room hibernation), use PartyKit's built-in storage (
this.room.storage) or an external database. - Use
partysocket(not raw WebSocket) on the client — it handles reconnection, buffering, and the PartyKit protocol. - PartyKit deploys to Cloudflare's edge network — rooms run closest to the first connecting user, then all subsequent users connect to that location.
当前收录版本
1.0.0
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供完整的 PartyKit 开发端到端指南,涵盖服务端、客户端、部署全流程
- 覆盖实时协作、多人体验、实时光标、协同编辑、实时投票等高频刚需场景
- 包含多个实际用例和完整代码示例,实用性强
亮点
- 触发词精准完整,覆盖多种变体,边界清晰
- description 明确列出适用场景,与 Skill 内容高度匹配
亮点
- Phase/步骤清晰,有出口条件,含端到端示例
- frontmatter完整,单文件≤500行,文档结构清晰
待提升项
-
异常处理覆盖不足 原报告严重程度:轻微
代码示例中未显式处理网络异常、JSON 解析失败等边界情况
改进建议:建议在关键消息处理逻辑中添加 try-catch 块,处理 JSON.parse 失败、网络中断等异常场景
亮点
- 工具来源明确,参数正确,提供了具体的 npm 命令和部署指令
- 可靠性良好,覆盖主要使用场景
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 41, 44, 161, 164, 167 行
文档引用的域名或地址
这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。
- 127.0.0.1
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
贝什
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。