stream-react
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseStream React (web) - scaffold + enhance + audit + migrate
Stream React(Web端)- 脚手架搭建 + 功能增强 + 集成审计 + 迁移
Read first (every session): Read(React/Next.js non-negotiables) and the cross-cuttingRULES.md. Where the two files state the same rule differently (e.g. Strict mode protection, Package manager), this pack's../stream/RULES.mdwins for React work. GlobRULES.md; if empty, install with../stream/SKILL.md.getstream skills streamCLI: CLI usage (onboarding, credentials, auth, everycall) lives in the root skill - its "Stream CLI" section ingetstream api, with CLI safety in../stream/SKILL.md. Glob../stream/RULES.md; install silently if missing (../stream/SKILL.md).getstream skills stream
This skill builds, enhances, audits, and migrates Stream Chat, Video, and Feeds in React / Next.js web apps - the default pack for all web React work. It covers five tracks:
- Track A - Scaffold a new app: Steps 0-7 below. Use when the cwd is empty / new and the user said "build me a ... app".
- Track E - Enhance an existing app: see . Skips scaffold + theme; reuses the same SDK wiring and component blueprints.
enhance.md - Track F - Audit an existing integration (read-only): for "audit/review my video integration", "check my app against best practices", "is my video app production-ready?", "what am I missing before launch?". Video only: load the Integration best-practices audit section in and follow its protocol - it has a Video-specific checklist + output contract. If the user asks to audit Chat or Feeds, say up front there is no dedicated best-practices checklist for those yet, then do a general docs-based review (fetch the relevant pages from
references/VIDEO.mdand check the app against them) rather than applying the Video checklist. Skip onboarding, auth, the CLI, and all build steps - this track only reads the app and reports findings. Fix issues only if the user then asks.references/docs-map.md - Track M - Migrate / upgrade an SDK version: see . For "upgrade stream-chat-react to v14", "migrate to the new SDK", "bump my Stream version". Docs-driven: detect the installed version, fetch the matching release guide, apply it. Never migrate from memory.
migrate.md - Track S - Migrate from Sendbird: see . For "migrate my app from Sendbird to Stream", "replace @sendbird/uikit-react with Stream", "we're switching off Sendbird". Detects the existing Sendbird integration shape, swaps packages + init, re-implements each touchpoint (UI composition, channels, messages, events/pagination, moderation, theming) against the grounded Sendbird<->Stream mapping the file carries, then offers the separate data migration.
sendbird-migration.md
每次会话必读: 阅读(React/Next.js 强制规则)和跨领域的RULES.md。若两个文件对同一规则的表述不同(如严格模式保护、包管理器),本工具包的../stream/RULES.md对React开发具有最高优先级。读取RULES.md;若文件为空,执行../stream/SKILL.md进行安装。getstream skills streamCLI: CLI使用说明(入门、凭据、认证、所有调用)位于根技能中——其“Stream CLI”部分在getstream api,CLI安全规则在../stream/SKILL.md。读取../stream/RULES.md;若文件缺失则静默安装(执行../stream/SKILL.md)。getstream skills stream
本技能用于在React/Next.js Web应用中构建、增强、审计和迁移Stream聊天、视频及动态流功能——是所有Web React开发的默认工具包。它包含五个流程分支:
- 分支A - 搭建新应用: 以下步骤0-7。适用于当前工作目录为空/新建,且用户提出“build me a ... app”需求的场景。
- 分支E - 增强现有应用: 详见。跳过脚手架搭建和主题设置;复用相同的SDK连接逻辑和组件蓝图。
enhance.md - 分支F - 审计现有集成(只读): 适用于“audit/review my video integration”、“check my app against best practices”、“is my video app production-ready?”、“what am I missing before launch?”等需求。仅支持视频: 加载中的「集成最佳实践审计」部分并遵循其流程——其中包含视频专属检查清单和输出规范。若用户要求审计聊天或动态流功能,需先告知目前暂无专门的最佳实践检查清单,然后基于文档进行常规审查(从
references/VIDEO.md获取相关页面并对照应用检查),而非套用视频检查清单。跳过入门引导、认证、CLI及所有构建步骤——此分支仅读取应用并报告发现的问题。仅在用户后续要求时才修复问题。references/docs-map.md - 分支M - 迁移/升级SDK版本: 详见。适用于“upgrade stream-chat-react to v14”、“migrate to the new SDK”、“bump my Stream version”等需求。基于文档执行:检测已安装版本,获取对应的升级指南并应用。绝不凭记忆进行迁移。
migrate.md - 分支S - 从Sendbird迁移: 详见。适用于“migrate my app from Sendbird to Stream”、“replace @sendbird/uikit-react with Stream”、“we're switching off Sendbird”等需求。检测现有Sendbird集成架构,替换包及初始化逻辑,对照文件中预设的Sendbird<->Stream映射重新实现每个交互点(UI组合、频道、消息、事件/分页、内容审核、主题),然后提供独立的数据迁移选项。
sendbird-migration.md
Flow dispatch - choose exactly one
流程调度 - 仅选择一个分支
- Track A: run to onboard (authenticate + select/create org + app + write credentials), then continue to Start and execute Steps 0-7.
getstream init - Track E: run to onboard (authenticate + select/create org + app + write credentials), then Read and execute
getstream init. Do not enter Start or any scaffold task.enhance.md - Track F: skip onboarding and go directly to the audit in . Do not enter Start or any build step.
references/VIDEO.md - Track M: skip onboarding and Read first; it fetches the live release guide before any edit. Do not enter Start or any scaffold task.
migrate.md - Track S: skip onboarding and Read first; it detects the integration shape before any edit. Do not enter Start or any scaffold task.
sendbird-migration.md
Styling-depth flag (orthogonal to the track). If the request carries a target appearance - an attached screenshot, a Figma frame, or "make it look like WhatsApp / Slack / <app>" - route through : a reference design is a checklist of regions, not a color tweak. Its pipeline is Classify -> Design analysis -> Route -> Ground -> Build -> Verify, run as a coordinator-agent orchestration (parallel subagents where the harness dispatches them; inline serially where not): classify the fidelity tier + viewport, produce a fine-grained design analysis at that names the Stream concept behind every visual signal via per-product identification checklists (chat / video / feeds), route each region to a component + mechanism (theming / injection -> the completion contract / bespoke), ground the names against the live docs, build batched, and close with an empirical verify loop - screenshot + computed-style checks via session browser tooling or a Playwright fallback - iterated until the spec table passes. This composes with the track: Track A scaffolds first, then matches before Step 4's build; Track E matches within E3. Load it before writing UI.
references/design-matching.md.design-verify/design-analysis.mdreferences/custom-ui.md- 分支A: 运行完成入门引导(认证 + 选择/创建组织 + 应用 + 写入凭据),然后进入「开始」环节并执行步骤0-7。
getstream init - 分支E: 运行完成入门引导(认证 + 选择/创建组织 + 应用 + 写入凭据),然后阅读并执行
getstream init。请勿进入「开始」或任何脚手架搭建任务。enhance.md - 分支F: 跳过入门引导,直接进入中的审计环节。请勿进入「开始」或任何构建步骤。
references/VIDEO.md - 分支M: 跳过入门引导,先阅读;它会在编辑前获取最新的升级指南。请勿进入「开始」或任何脚手架搭建任务。
migrate.md - 分支S: 跳过入门引导,先阅读;它会在编辑前检测集成架构。请勿进入「开始」或任何脚手架搭建任务。
sendbird-migration.md
样式深度标记(与分支无关)。 如果请求附带目标外观——如截图、Figma框架,或“make it look like WhatsApp / Slack / <app>”——则遵循流程:参考设计是区域检查清单,而非单纯的颜色调整。其流程为分类 -> 设计分析 -> 路由 -> 落地 -> 构建 -> 验证,通过协调Agent编排执行(支持并行子Agent的场景由调度器分配;否则串行执行):分类保真度层级 + 视口,在生成细粒度设计分析,通过各产品识别清单(聊天/视频/动态流)为每个视觉信号关联对应的Stream概念,将每个区域路由至对应组件 + 机制(主题/注入 -> 完成规范/定制开发),对照实时文档确认概念,批量构建,最后通过实证验证循环——通过会话浏览器工具或Playwright备用方案进行截图 + 计算样式检查——迭代直至规范表通过。此流程可与分支组合:分支A先搭建脚手架,然后在步骤4构建前匹配设计;分支E在E3环节内匹配设计。在编写UI前加载此流程。
references/design-matching.md.design-verify/design-analysis.mdreferences/custom-ui.mdDocs-first triggers (consult docs before building)
文档优先触发规则(构建前查阅文档)
For any feature that matches a UI component, cookbook, or advanced-guide topic, fetch the matching Stream docs page BEFORE writing code. The live docs are the source of truth for the current API and the recommended pattern; the bundled cover the prebuilt common path only. Full keyword -> page map with exact URLs: - it opens with the docs convention (the -twin rule + per-product live index) so any unmapped page is still reachable: never guess a path, fetch the index. Enforced by > Docs-first for cookbook / advanced features.
references/*-blueprints.mdreferences/docs-map.md.mdRULES.mdThis skill is prebuilt-component-first: build the common path with the SDK's prebuilt React components and customize via the documented hooks/props - see > Reference authority. The docs-first protocol covers both the component reference pages and the cookbook / advanced recipes:
RULES.md- UI Cookbook (customization / theming): typing indicator, custom message UI, message actions, reactions customization, message composer / input UI, channel header, channel list preview, emoji picker, autocomplete / suggestion list, link previews, pin indicator, thread header, search, collapsible sidebar, system message / banner, mentions actions, attachment actions, hide channel history, localization / i18n; Video: replacing call controls, custom layouts, lobby preview, PiP, network quality, livestream watching, ringing.
- Advanced Guides: AI integrations (LangChain, AI SDK), advanced search, multiple lists, infinite scroll, read state, online status, location sharing, blocking, message reminders, notifications / web push, attachment previews, audio playback, date formatting, SDK state management, dialog management, TypeScript custom data, chat + video integration, recording, broadcasting, video filters.
When a request hits one of these: match -> the page's URL from -> implement to match. On fetch failure, hand to the skill; if neither resolves the API, stop and ask the user - never build from memory.
WebFetch.mdreferences/docs-map.mdstream-docs对于任何匹配UI组件、食谱或高级指南主题的功能,在编写代码前必须先获取对应的Stream文档页面。 实时文档是当前API和推荐模式的唯一来源; bundled的仅覆盖预构建的通用路径。完整的关键词->页面映射及精确URL见:——开篇包含文档约定(孪生规则 + 各产品实时索引),因此即使是未映射的页面也可访问:绝不猜测路径,直接获取索引。此规则由 > 食谱/高级功能的文档优先原则强制执行。
references/*-blueprints.mdreferences/docs-map.md.mdRULES.md本技能遵循预构建组件优先:使用SDK的预构建React组件实现通用路径,并通过文档化的hooks/props进行定制——详见 > 参考权威。文档优先流程覆盖组件参考页面和食谱/高级方案:
RULES.md- UI食谱(定制/主题): 输入指示器、自定义消息UI、消息操作、 reactions定制、消息编辑器/输入UI、频道头部、频道列表预览、表情选择器、自动补全/建议列表、链接预览、固定指示器、线程头部、搜索、可折叠侧边栏、系统消息/横幅、提及操作、附件操作、隐藏频道历史、本地化/i18n;视频:替换通话控件、自定义布局、 lobby预览、画中画、网络质量、直播观看、来电提醒。
- 高级指南: AI集成(LangChain、AI SDK)、高级搜索、多列表、无限滚动、已读状态、在线状态、位置共享、屏蔽、消息提醒、通知/Web推送、附件预览、音频播放、日期格式化、SDK状态管理、对话框管理、TypeScript自定义数据、聊天+视频集成、录制、广播、视频滤镜。
当请求命中上述任一内容时:匹配 -> 从获取页面的URL并执行 -> 按文档实现。若获取失败,移交至技能;若两者均无法解决API问题,停止操作并询问用户——绝不凭记忆构建。
references/docs-map.md.mdWebFetchstream-docsStart
开始
Track A only. Tracks E, F, and M branch in Flow dispatch above and never enter this section.
Once has onboarded (authenticated + selected/created org + app + written credentials), announce the network plan once, then immediately start executing Steps 0-7 - do not ask permission to begin (the user has authorized the build by asking for it). The only pause for input is the theme + app pick (Step 1b).
getstream init仅适用于分支A。 分支E、F、M从上述「流程调度」环节分支,绝不会进入此部分。
getstream initTrust readout (announce, then continue on the same turn - do not wait)
信任声明(告知后继续执行,无需等待回复)
Before the first network command, print this verbatim to the user, then proceed straight into Step 0 without stopping for a reply:
Scaffolding now. Network calls you'll see:
(Vercel) - scaffold + UI components from npm.npx shadcn@latest ... - Stream SDKs from npm (npm install <stream-packages> --legacy-peer-deps,stream-chat-react, etc.).@stream-io/video-react-sdk - local CLI, no network; writesgetstream env(gitignored by the Next.js scaffold's default; Task B verifies)..env.localInterrupt me at any point if something looks wrong. I'll pause once for your input: the theme + Stream-app pick (Step 1b).
Full per-command audit (publisher, why unpinned, what each writes): section Install trust & integrity below. The user's continued silence after the readout is implicit consent for this scaffold; an objection or stop instruction aborts the run.
Shadcn/ui is always installed during Step 3. stream-react does not install third-party frontend skills - the build uses Stream references + Shadcn. If frontend skill packs (, , ) are already available in the session, use them for generic React / UI polish only; Stream references remain authoritative for SDK wiring.
frontend-designvercel-react-best-practicesweb-design-guidelines在第一个网络命令执行前,向用户逐字打印以下内容,然后直接进入步骤0,无需等待回复:
开始搭建脚手架。您将看到以下网络调用:
(Vercel)——从npm脚手架搭建 + UI组件。npx shadcn@latest ... ——从npm安装Stream SDK(npm install <stream-packages> --legacy-peer-deps、stream-chat-react等)。@stream-io/video-react-sdk ——本地CLI,无网络请求;写入getstream env(Next.js脚手架默认已将其加入.env.local;任务B会验证此设置)。.gitignore若发现异常,可随时打断我。我仅会暂停一次等待您的输入:主题 + Stream应用选择(步骤1b)。
各命令的完整审计信息(发布方、未固定版本的原因、写入内容)见下方「安装信任与完整性」部分。用户在信任声明后保持沉默即视为默认同意此搭建流程;若用户提出反对或停止指令,则终止运行。
步骤3中始终会安装Shadcn/ui。stream-react不会安装第三方前端技能包——构建仅使用Stream参考文档 + Shadcn。如果会话中已存在前端技能包(、、),仅将其用于通用React/UI优化;Stream参考文档仍为SDK连接逻辑的权威依据。
frontend-designvercel-react-best-practicesweb-design-guidelinesInstall trust & integrity
安装信任与完整性
This builder runs three classes of network-touching commands. Each is listed here so a reviewer can audit before approving. CLI install instructions live in the root skill's "Stream CLI" section in .
../stream/SKILL.md| Command | Publisher | Why unpinned | What it writes |
|---|---|---|---|
| Vercel - | Scaffolder; | Project files in cwd. Next.js scaffold's |
| Vercel - same source as above | Same scaffolder; component sync depends on registry parity. | Component files under |
| GetStream (npm) for | Latest published versions of GetStream's own SDKs - same trust model as the CLI itself. | Modules under |
| GetStream - install instructions in the root skill's "Stream CLI" section in | n/a (local CLI, no network at this step) | |
Playwright into a self-contained | Microsoft - | Latest published; runs only when a design match needs a capture and no in-session browser tooling exists (may never run), announced inline at point of use. | Everything under |
Reviewer checklist:
- All invocations resolve to the publishers listed above; substitute a different publisher and the install fails.
npx - is written by the Stream CLI directly, not by the agent, and is not transmitted into the conversation.
.env.local - If the user wants to pin a specific shadcn version, replace with
@latestin Tasks A and A.1.@<version> - The Playwright row is a design-matching verify-loop fallback, not part of the scaffold: it is announced inline if and when it runs (it may never run), installs only into a self-contained harness (never the app root), and does not appear in the Start trust readout above.
.design-verify/
此构建器运行三类涉及网络的命令。以下列出所有命令,供审核人员在批准前检查。CLI安装说明位于根技能的「Stream CLI」部分,见。
../stream/SKILL.md| 命令 | 发布方 | 未固定版本的原因 | 写入内容 |
|---|---|---|---|
| Vercel - | 脚手架工具; | 当前工作目录下的项目文件。Next.js脚手架默认的 |
| Vercel - 同上来源 | 同脚手架工具;组件同步依赖注册表一致性。 | |
| GetStream(npm)提供 | GetStream自有SDK的最新发布版本——与CLI本身的信任模型一致。 | |
| GetStream - 安装说明见根技能的「Stream CLI」部分, | 不适用(本地CLI,此步骤无网络请求) | 项目根目录下的 |
Playwright安装至独立的 | Microsoft - | 最新发布版本;仅在需要捕获设计匹配且会话中无浏览器工具时运行(可能永远不会运行),运行时会实时告知。 | |
审核人员检查清单:
- 所有调用均解析为上述列出的发布方;若替换为其他发布方,安装将失败。
npx - 由Stream CLI直接写入,而非Agent,且不会传输至对话中。
.env.local - 若用户希望固定特定shadcn版本,将任务A和A.1中的替换为
@latest。@<version> - Playwright条目是设计匹配验证循环的备用方案,不属于脚手架的一部分:仅在运行时实时告知(可能永远不会运行),仅安装至独立的环境(绝不会安装至应用根目录),且不会出现在上述「开始」环节的信任声明中。
.design-verify/
Builder Steps
构建步骤
Execute phases in order (later steps depend on earlier ones). Do not run independent phases in parallel. One exception: when is active, its Orchestration section governs scheduling - the design-analysis agent runs concurrently with the Steps 0-3 setup work, and builds / verifies fan out per its role table; everything else here stays sequential. Shell discipline (one per phase, no , standalone) lives in > Shell discipline.
references/design-matching.mdbash -cbash -cegetstream login../stream/RULES.mdTwo-call exception: If you must Read JSON from a call and then choose IDs, use one call for the read, one batched call for all creates.
getstream api按顺序执行各阶段(后续步骤依赖于前期步骤)。请勿并行运行独立阶段。唯一例外: 当生效时,其编排部分控制调度——设计分析Agent与步骤0-3的设置工作并行运行,构建/验证按角色表分散执行;其余所有步骤仍保持顺序执行。Shell规范(每个阶段一个,不使用,独立运行)见 > Shell规范。
references/design-matching.mdbash -cbash -cegetstream login../stream/RULES.md双调用例外: 若必须从调用中读取JSON并选择ID,使用一个调用读取,一个批量调用执行所有创建操作。
getstream apiStep 0: Package manager
步骤0:包管理器
Always use . Never use bun. ( > Package manager.)
npmRULES.md始终使用。绝不使用bun。( > 包管理器。)
npmRULES.mdStep 1: Auth
步骤1:认证
Authentication is handled by (Step 2) - it opens the browser as its own invocation if you're not signed in ( > Provisioning; > Shell discipline). There is no separate auth probe - CLI v1.0.0 removed the pre-1.0 probe, and subcommands are now product-namespaced (e.g. ). Continue to Step 1b.
getstream initbuilder.md../stream/RULES.mdgetstream apiOrganizationReadgetstream apigetstream api chat ...认证由(步骤2)处理——若未登录,它会自行调用打开浏览器( > 资源配置; > Shell规范)。无需单独执行认证探测——CLI v1.0.0已移除1.0版本前的探测,子命令现在按产品命名空间划分(如)。继续执行步骤1b。
getstream initbuilder.md../stream/RULES.mdgetstream apiOrganizationReadgetstream apigetstream api chat ...Step 1b: Theme + app pick
步骤1b:主题 + 应用选择
Ask both setup questions in one message before doing anything else - a single pause, the same "ask exactly once, then act" pattern the other platform packs use for credentials. Build the app options from what is already in context: the org/app already configured in this project by a prior , if any. If none is configured yet, lists your orgs/apps when it runs (Step 2) - interactively with a TTY; in a non-interactive shell it writes a command file to uncomment instead ( > Provisioning documents the exact headless sequence). Don't try to enumerate them with a raw call.
getstream initgetstream init.stream/init-*.yamlbuilder.mdgetstream apiQuick setup - two questions:
- Theme: I can use a random shadcn theme, or you can design your own at ui.shadcn.com/create and share the
value (e.g.--preset). Random, or do you have a preset? (If you already shared a screenshot or Figma, I'll match that instead - skip this.)--preset b1Gdi7z7r- Stream app: (an app is already configured) Use the currently configured app
(default), or pick/create a different one? / (no app configured yet)<name>will list your orgs and apps when it runs - use an existing one, or create a fresh org + app?getstream init
STOP here and wait for the user's answer. Do not continue with any other step until the user responds. Asking a question and continuing to work in parallel is confusing - the user misses the question as output scrolls past.
- Theme - preset provided -> store it for Task A scaffold command. Random / doesn't care -> pick a random preset from ,
nova,vega,maia,lyra,mira.luma - Theme - a reference design (screenshot / Figma) was provided -> the design dictates the theme: skip question 1, pick the shadcn preset closest to the sampled palette, ask only question 2 (the Stream app), and match the design via .
references/design-matching.md - App - named choice, "default", or "don't care" -> Step 2 applies it (the configured app wins whenever one exists). Create new -> Step 2 runs the create flow.
- Account has no orgs at all -> drop question 2, announce that a fresh org + app will be created, and ask only the theme.
在执行任何其他操作前,一次性提出两个设置问题——仅暂停一次,与其他平台工具包选择凭据的“仅询问一次,然后执行”模式一致。根据上下文构建应用选项:若之前的已在此项目中配置了组织/应用,则包含该选项。若尚未配置,运行时(步骤2)会列出您的组织/应用——交互式TTY环境下直接选择;非交互式Shell下会写入命令文件,需取消注释后使用( > 资源配置文档记录了精确的无头执行流程)。请勿尝试通过原始调用枚举组织/应用。
getstream initgetstream init.stream/init-*.yamlbuilder.mdgetstream api快速设置 - 两个问题:
- 主题: 我可以使用随机的shadcn主题,您也可以在ui.shadcn.com/create自行设计并分享
值(如--preset)。使用随机主题,还是您已有预设值?(如果您已分享截图或Figma,我将直接匹配该设计——跳过此问题。)--preset b1Gdi7z7r- Stream应用: (已配置应用) 使用当前已配置的应用**
**(默认),还是选择/创建其他应用? / (未配置应用)<name>运行时会列出您的组织和应用——使用现有应用,还是创建新的组织+应用?getstream init
在此处暂停并等待用户回复。 用户回复前请勿继续执行任何其他步骤。提问后继续并行操作会造成混淆——用户可能会因输出滚动错过问题。
- 主题 - 提供了预设值 -> 存储该值用于任务A的脚手架命令。随机/无要求 -> 从、
nova、vega、maia、lyra、mira中随机选择一个预设值。luma - 主题 - 提供了参考设计(截图/Figma) -> 设计决定主题:跳过问题1,选择与采样调色板最接近的shadcn预设值,仅询问问题2(Stream应用),并通过匹配设计。
references/design-matching.md - 应用 - 指定选择、“默认”或“无要求” -> 步骤2应用该选择(已配置的应用优先)。创建新应用 -> 步骤2执行创建流程。
- 账户无任何组织 -> 跳过问题2,告知将创建新的组织+应用,仅询问主题问题。
Step 2: Pick org + app
步骤2:选择组织 + 应用
Run Provisioning in : handles auth and org/app selection-or-creation (including the Feeds v3 region choice). Let drive it - interactively or via its command file; don't provision with raw calls.
builder.mdgetstream initinitgetstream api执行中的资源配置:处理认证和组织/应用选择或创建(包括Feeds v3区域选择)。让主导流程——交互式或通过命令文件;请勿通过原始调用进行资源配置。
builder.mdgetstream initinitgetstream apiStep 3: Scaffold + .env + SDKs + Configure - SEQUENTIALLY
步骤3:脚手架搭建 + .env + SDK + 配置 - 按顺序执行
Scaffold order
脚手架搭建顺序
Order:
- Steps 1-1b: Auth + theme/app pick (wait for answer).
- Step 2: Apply the org/app choice (select existing or create).
- Task A: Scaffold with Shadcn + Next.js using the chosen preset.
- Task A.1: Add base Shadcn components.
- Continue with Task B (.env), Task C (SDKs), Task D (CLI config).
Task A: Scaffold - scaffolds Next.js + Tailwind + Shadcn/ui (Base UI) into the current directory. Use the theme preset chosen in Step 1b.
The scaffold command creates a new directory, so we scaffold into a temporary subdirectory and move everything up. The flag also lands in the generated as , which npm/pnpm/yarn reject (a package name can't start with ), so the final step rewrites to a valid slug derived from the project directory:
.scaffold-n .scaffoldpackage.json"name": ".scaffold".namebash
npx shadcn@latest init -t next -b base -n .scaffold --no-monorepo -p <random-preset> && mv .scaffold/* .scaffold/.* . 2>/dev/null; rm -rf .scaffold && node -e "const fs=require('fs'),path=require('path'),j=require('./package.json');j.name=path.basename(process.cwd()).toLowerCase().replace(/[^a-z0-9._-]+/g,'-').replace(/^[._-]+/,'')||'app';fs.writeFileSync('package.json',JSON.stringify(j,null,2)+'\n')"Task A.1: Add base Shadcn components:
bash
npx shadcn@latest add button input textarea card avatar badge separatorAdd more components as the use case requires (e.g. , , , ).
dialogdropdown-menutabspopoverDo not modify or after scaffold - use Shadcn's defaults as-is (RULES.md > Theme).
layout.tsxglobals.cssTask B: .env - run AFTER scaffold so the lands inside the project directory.
.envFirst, verify is gitignored ( > Secrets). The Next.js scaffold's default already includes it; this is a safety net for projects whose was hand-edited or doesn't yet exist. Use the file tools (no shell) so no broad permission is needed:
.env*../stream/RULES.md.gitignorebash -c- for
Grepin^\.env(or.gitignoreit). If it already ignoresRead, do nothing..env* - If exists but has no
.gitignoreentry,.envit to append a lineEdit..env* - If does not exist,
.gitignorea newWritecontaining.gitignore..env*
(Inspecting/editing is fine; never Read or Edit itself - > Secrets.)
.gitignore.env../stream/RULES.mdThen write secrets:
bash
getstream envgetstream envNEXT_PUBLIC_STREAM_API_KEYSTREAM_API_SECRET.env.local/api/tokenNEXT_PUBLIC_STREAM_API_KEY/api/token.env.localRULES.mdTask C: Install Stream SDKs + verify icons - Only what the use case needs:
bash
undefined顺序:
- 步骤1-1b: 认证 + 主题/应用选择(等待回复)。
- 步骤2: 应用组织/应用选择(选择现有或创建新的)。
- 任务A: 使用选定的预设值搭建Shadcn + Next.js脚手架。
- 任务A.1: 添加基础Shadcn组件。
- 继续执行任务B(.env)、任务C(SDK)、任务D(CLI配置)。
任务A:脚手架搭建 - 在当前目录中搭建Next.js + Tailwind + Shadcn/ui(基础UI)。使用步骤1b中选择的主题预设值。
脚手架命令会创建新目录,因此我们先在临时子目录中搭建,然后将所有内容移至上层目录。标志还会在生成的中写入,而npm/pnpm/yarn会拒绝此名称(包名不能以开头),因此最后一步将重写为基于项目目录的有效slug:
.scaffold-n .scaffoldpackage.json"name": ".scaffold".namebash
npx shadcn@latest init -t next -b base -n .scaffold --no-monorepo -p <random-preset> && mv .scaffold/* .scaffold/.* . 2>/dev/null; rm -rf .scaffold && node -e "const fs=require('fs'),path=require('path'),j=require('./package.json');j.name=path.basename(process.cwd()).toLowerCase().replace(/[^a-z0-9._-]+/g,'-').replace(/^[._-]+/,'')||'app';fs.writeFileSync('package.json',JSON.stringify(j,null,2)+'\
')"任务A.1:添加基础Shadcn组件:
bash
npx shadcn@latest add button input textarea card avatar badge separator根据使用场景添加更多组件(如、、、)。
dialogdropdown-menutabspopover脚手架搭建完成后请勿修改或——使用Shadcn的默认设置( > 主题)。
layout.tsxglobals.cssRULES.md任务B:.env - 在脚手架搭建完成后运行,确保写入项目目录内。
.env首先,验证已加入git忽略( > 机密信息)。Next.js脚手架默认已配置此设置;这是针对被手动编辑或尚未存在的项目的安全保障。使用文件工具(不使用Shell),无需的广泛权限:
.env*../stream/RULES.md.gitignorebash -c- 在中
.gitignore查找Grep(或直接^\\.env文件)。若已忽略Read,则无需操作。.env* - 若存在但无
.gitignore条目,**.env**文件并添加一行Edit。.env* - 若不存在,**
.gitignore**新的Write文件,内容为.gitignore。.env*
(检查/编辑是允许的;绝不读取或编辑本身—— > 机密信息。)
.gitignore.env../stream/RULES.md然后写入机密信息:
bash
getstream envgetstream envNEXT_PUBLIC_STREAM_API_KEYSTREAM_API_SECRET.env.local/api/tokenNEXT_PUBLIC_STREAM_API_KEY/api/token.env.localRULES.md任务C:安装Stream SDK + 验证图标 - 仅安装使用场景所需的SDK:
bash
undefinedChat: stream-chat stream-chat-react
聊天: stream-chat stream-chat-react
Video: @stream-io/video-react-sdk
视频: @stream-io/video-react-sdk
Feeds: @stream-io/feeds-react-sdk
动态流: @stream-io/feeds-react-sdk
Server: @stream-io/node-sdk
服务器: @stream-io/node-sdk
npm install <packages> --legacy-peer-deps
After installing SDKs, note the resolved **Stream Chat React major**: the bundled blueprints assume **v14** (`MessageComposer`, `stream-chat-react/css/index.css`). `@latest` is v14 today; if a future install resolves a **newer major**, fetch that major's component reference from [`references/docs-map.md`](references/docs-map.md) (Version note) before writing the provider tree - don't apply v14 names from memory.
Also verify an icon package is available. Some Shadcn presets bundle one, others don't:
```bash
node -e "const p=['lucide-react','@phosphor-icons/react','@hugeicons/react'];console.log(p.some(m=>{try{require.resolve(m);return true}catch{return false}})?'ICONS_OK':'NO_ICONS')"If , install : . If an icon package is already present, use that one throughout the app - do not install a second.
NO_ICONSlucide-reactnpm install lucide-react --legacy-peer-depsTask D: Configure Stream - run the CLI commands from the relevant (App Integration -> Setup) for each product the use case needs.
references/<Product>.mdnpm install <packages> --legacy-peer-deps
安装SDK后,记录解析后的**Stream Chat React主版本**:bundled的蓝图假设为**v14**(`MessageComposer`、`stream-chat-react/css/index.css`)。目前`@latest`为v14;若未来安装解析到**更新的主版本**,在编写提供程序树前需从[`references/docs-map.md`](references/docs-map.md)(版本说明)获取对应主版本的组件参考——绝不凭记忆使用v14的名称。
同时验证是否有可用的图标包。部分Shadcn预设已捆绑图标包,其他则没有:
```bash
node -e "const p=['lucide-react','@phosphor-icons/react','@hugeicons/react'];console.log(p.some(m=>{try{require.resolve(m);return true}catch{return false}})?'ICONS_OK':'NO_ICONS')"若输出,安装:。若已存在图标包,在整个应用中使用该包——请勿安装第二个图标包。
NO_ICONSlucide-reactnpm install lucide-react --legacy-peer-deps任务D:配置Stream - 针对使用场景所需的每个产品,运行相关(应用集成 -> 设置)中的CLI命令。
references/<Product>.mdStep 4: Generate code and UI
步骤4:生成代码和UI
Prebuilt-component-first. Build the common path with the SDK's prebuilt React components and customize via the documented hooks/props ( > Reference authority). Writing your own component for a region (custom message row, composer, channel preview/header, call layout) - not just passing props - loads (the completion contract) first; see > Reference authority.
RULES.mdreferences/custom-ui.mdRULES.mdDocs-first: before implementing any component, cookbook, or advanced feature (typing indicator, custom message UI, reactions, AI integrations, read state, notifications, call layouts, ...), follow the Docs-first triggers section above - the matching page first, then build to match.
WebFetchreferences/docs-map.mdLoad and (cross-cutting SDK wiring: token route, instantiation, CSS imports), plus only the relevant header + (the prebuilt provider tree + props) for the product(s) you are implementing - not every reference file. For any customization, fetch the matching live page from first (and if you are writing your own component for a region, load first per Step 4's rule above / > Reference authority). Pull Use Case Matching and Page Flow from to choose products and navigation structure. For multi-product apps (Chat + Video, Chat + Feeds, Video + Feeds, etc.), also load before writing AppShell - it has the canonical multi-client provider hierarchy and an error -> cause -> fix table.
builder-ui.mdsdk.mdreferences/<Product>.mdreferences/<Product>-blueprints.mdreferences/docs-map.mdreferences/custom-ui.mdRULES.mdbuilder.mdreferences/CROSS-PRODUCT.md预构建组件优先。 使用SDK的预构建React组件实现通用路径,并通过文档化的hooks/props进行定制( > 参考权威)。若为某个区域编写自定义组件(自定义消息行、编辑器、频道预览/头部、通话布局)——不仅传递props——需先加载(完成规范);详见 > 参考权威。
RULES.mdreferences/custom-ui.mdRULES.md文档优先: 在实现任何组件、食谱或高级功能(输入指示器、自定义消息UI、reactions、AI集成、已读状态、通知、通话布局等)前,遵循上述文档优先触发规则部分——先匹配的页面,然后按文档构建。
WebFetchreferences/docs-map.md加载和(跨领域SDK连接逻辑:令牌路由、实例化、CSS导入),以及仅加载正在实现的产品对应的头部 + (预构建提供程序树 + props)——无需加载所有参考文件。对于任何定制需求,先从获取匹配的实时页面(若为某个区域编写自定义组件,需先加载,遵循步骤4的规则 / > 参考权威)。从中提取使用场景匹配和页面流程,以选择产品和导航结构。对于多产品应用(聊天+视频、聊天+动态流、视频+动态流等),编写AppShell前还需加载——其中包含规范的多客户端提供程序层级结构和错误->原因->修复表。
builder-ui.mdsdk.mdreferences/<Product>.mdreferences/<Product>-blueprints.mdreferences/docs-map.mdreferences/custom-ui.mdRULES.mdbuilder.mdreferences/CROSS-PRODUCT.mdStep 5: Verify
步骤5:验证
Type-check first (reports ALL errors at once, ~3s):
bash
npx tsc --noEmitFix all type errors. Then run the full build:
bash
npx next buildFix any remaining errors. Do NOT skip - it catches every type error in one pass, while stops at the first error per file and requires multiple rebuild cycles.
tsc --noEmitnext build先进行类型检查(一次性报告所有错误,约3秒):
bash
npx tsc --noEmit修复所有类型错误。然后执行完整构建:
bash
npx next build修复剩余所有错误。请勿跳过——它可一次性捕获所有类型错误,而会在每个文件的第一个错误处停止,需要多次重建。
tsc --noEmitnext buildStep 6: Start dev server
步骤6:启动开发服务器
Pick a random 5-digit port (10000-65535). Run the server using :
run_in_backgroundbash
PORT=$((RANDOM % 55536 + 10000))
npx next dev -p $PORTImportant: The dev server is a long-running process. When run in the background it will eventually emit a "completed" notification - this does not mean the server stopped. The server is still running and serving requests. Do not respond to the background-task completion notification by telling the user the server has stopped. If you receive that notification after Step 7, ignore it silently - do not output anything.
随机选择一个5位端口(10000-65535)。使用运行服务器:
run_in_backgroundbash
PORT=$((RANDOM % 55536 + 10000))
npx next dev -p $PORT重要提示: 开发服务器是长期运行的进程。在后台运行时,它最终会发出“已完成”通知——这不代表服务器已停止。服务器仍在运行并处理请求。请勿响应后台任务完成通知,告知用户服务器已停止。若步骤7后收到该通知,请忽略——无需输出任何内容。
Step 6b: Smoke-check the render (required)
步骤6b:渲染冒烟测试(必填)
A green + (Step 5) says nothing about what the user sees - it compiles, it does not render. Before the summary, capture at least one screenshot of the logged-in main screen and actually look at it, using the tool ladder in > 6b (in-session browser tooling first, else the Playwright fallback; the and capture gotchas in 6c apply). You are checking for gross breakage the build cannot catch: a blank / splash-stuck screen, unstyled or collapsed layout, a region not filling its pane, or console errors. Fix what you see and re-capture.
tscnext buildreferences/design-matching.mdnetworkidleIf the request carried any target appearance - an attached screenshot, a Figma frame, or "make it look like <app>" - this smoke check is not enough: you must run the full Step 6 verify loop (a per-region spec table diffed against a this-round capture). A referenced build that skipped that loop is unfinished, not merely unpolished - catching it here is the backstop if the styling-depth flag was missed at Start.
references/design-matching.mdtscnext buildreferences/design-matching.mdnetworkidle如果请求附带任何目标外观——如截图、Figma框架,或“make it look like <app>”——此冒烟测试不够:必须运行完整的步骤6验证循环(逐区域规范表与当前捕获截图对比)。跳过该循环的参考设计构建视为未完成,而非仅未优化——此处是“开始”环节遗漏样式深度标记的最后保障。
references/design-matching.mdStep 7: Summary
步骤7:总结
Show the org/app used (created or selected), plus resources and files created. Include the local URL. Do NOT say "you can now start the dev server" - it's already running.
End with:
Open, enter a username, and start testing. Open a second tab with a different username to test multi-user interactions.http://localhost:<PORT>
展示使用的组织/应用(创建或选择),以及创建的资源和文件。包含本地URL。请勿说“您现在可以启动开发服务器”——服务器已在运行。
结尾附上:
打开,输入用户名开始测试。打开第二个标签页,使用不同用户名测试多用户交互。http://localhost:<PORT>
Use Case Matching and Page Flow
使用场景匹配和页面流程
Both live in (Use Case Matching, Page Flow). Match the user's words to a use case there, then build only the products that use case needs and follow the hub-first navigation it describes. Moderation is configured via CLI during setup only - never build moderation review UI ( > Moderation is Dashboard-only).
builder.mdRULES.md两者均位于(使用场景匹配、页面流程)。将用户的需求与其中的使用场景匹配,然后仅构建该场景所需的产品,并遵循其描述的中心优先导航结构。内容审核仅在设置期间通过CLI配置——绝不构建内容审核审查UI( > 内容审核仅通过控制台操作)。
builder.mdRULES.mdCross-Product Integration
跨产品集成
When building apps that combine multiple products, read each relevant App Integration section. Key patterns:
references/<Product>.md- Combined token route: returns tokens for each product (
/api/token). Upsert only the requesting user - never seed demo users ({ chatToken, videoToken, feedToken, apiKey }> No auto-seeding).../stream/RULES.md - Video + Feeds (Livestreaming): Feed hub separates activities as prominent live cards. "Go Live" posts a live activity via
type === "live". "End Stream" removes it./api/feed/live - Video + Chat (Livestreaming): Chat alongside video on the watch screen. Use channel type - one channel per stream, keyed by call ID. Create the chat channel in the
livestreamroute./api/token - Moderation (all use cases): Run Moderation CLI setup commands from (App Integration -> Setup), adjusting channel type name. Never build moderation review UI (
references/MODERATION.md> Moderation is Dashboard-only).RULES.md
For multi-product provider nesting, load .
references/CROSS-PRODUCT.md构建多产品组合的应用时,阅读每个相关的应用集成部分。关键模式:
references/<Product>.md- 组合令牌路由: 返回每个产品的令牌(
/api/token)。仅更新请求用户的令牌——绝不自动创建演示用户({ chatToken, videoToken, feedToken, apiKey }> 不自动创建演示用户)。../stream/RULES.md - 视频 + 动态流(直播): 动态流中心将的活动作为显眼的直播卡片单独展示。“开始直播”通过
type === "live"发布直播活动。“结束直播”移除该活动。/api/feed/live - 视频 + 聊天(直播): 观看页面中视频旁显示聊天。使用频道类型——每个流对应一个频道,按通话ID关联。在
livestream路由中创建聊天频道。/api/token - 内容审核(所有场景): 运行(应用集成 -> 设置)中的内容审核CLI设置命令,调整频道类型名称。绝不构建内容审核审查UI(
references/MODERATION.md> 内容审核仅通过控制台操作)。RULES.md
对于多产品提供程序嵌套,加载。
references/CROSS-PRODUCT.mdReference file paths
参考文件路径
Blueprint files live in the directory next to this SKILL.md. Resolve them relative to this skill's own directory, wherever the pack is installed (e.g. ). Do not hardcode machine-specific absolute paths or assume a repo-checkout layout.
references/<skill-dir>/references/FEEDS.md蓝图文件位于本SKILL.md旁的目录中。相对于本技能自身的目录解析路径,无论工具包安装在何处(如)。请勿硬编码机器特定的绝对路径,或假设仓库 checkout 布局。",
references/<skill-dir>/references/FEEDS.md