stream

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Stream — skill router + execution flow

Stream — 技能路由与执行流程

Rules: Read
RULES.md
once per session — every non-negotiable rule is stated there, nowhere else.
This file is the single entrypoint: intent classification, conditional context detection, and module pointers.

规则: 每次会话请阅读一次
RULES.md
—— 所有不可协商的规则都在此文件中,别处无相关内容。
此文件是唯一入口:用于意图分类、条件上下文检测和模块指向。

Step 0: Intent classifier (mandatory first — never skip)

步骤0:意图分类器(必须首先执行,切勿跳过)

Before any tool call, decide the track from the user's input alone — no probes, no fetches, no CLI checks. The classifier is deterministic: scan the input for the signals below in order.
在调用任何工具之前,仅根据用户输入确定追踪路径——无需探测、抓取或CLI检查。分类器是确定性的:按顺序扫描输入中的以下信号。

Signals → track

信号 → 追踪路径

Signal in user inputTrackSkip CLI gate?
Explicit SDK/framework token:
Chat React
,
Video iOS
,
Feeds Node
,
Moderation
, etc. (with or without version)
D — Docs searchYes
Words "docs" or "documentation"DYes
"How do I {X} in {framework}?", "How does {hook/component/method} work?", "What does {SDK thing} do?"DYes
Operational verbs + Stream noun: "list calls", "show channels", "any flagged", "find users", "check {anything}"B — CLI / data queryNo
stream api
,
stream config
,
stream auth
(literal CLI invocation)
BNo
"Build me a … app", "scaffold", "create a new …" + Stream product, in an empty/new directoryA — Builder (new app)No
"Add Chat/Video/Feeds to this app", "integrate Stream into" — existing projectE — Builder (enhance)No
"Install the CLI", "set up stream" with no project contextC — Bootstrapn/a
Operational verb wrapped in how-to phrasing (e.g. "how do I list my calls?" — docs or CLI)Ask one disambiguatorDefer
用户输入中的信号追踪路径是否跳过CLI验证?
明确的SDK/框架标识:
Chat React
Video iOS
Feeds Node
Moderation
等(带或不带版本号)
D — 文档搜索
包含“docs”或“documentation”字样D
句式为“How do I {X} in {framework}?”、“How does {hook/component/method} work?”、“What does {SDK thing} do?”D
操作动词 + Stream名词:“list calls”、“show channels”、“any flagged”、“find users”、“check {anything}”B — CLI / 数据查询
字面CLI调用:
stream api
stream config
stream auth
B
“Build me a … app”、“scaffold”、“create a new …” + Stream产品,且处于空目录/新目录中A — 构建器(新应用)
“Add Chat/Video/Feeds to this app”、“integrate Stream into” — 针对现有项目E — 构建器(增强现有应用)
“Install the CLI”、“set up stream”且无项目上下文C — 初始化引导不适用
操作动词包裹在“How-to”句式中(例如“how do I list my calls?” —— 文档或CLI均可)询问一个歧义消除问题延迟处理

Disambiguation flow

歧义消除流程

If the input fits more than one row (typically operational verb + how-to phrasing), ask one short question and wait. Do not probe, fetch, or gate before the answer.
Want me to look up the SDK method (docs) or run it now via CLI?
After the answer arrives, route as if the user had given that signal directly.
如果输入符合多行条件(通常是操作动词 + How-to句式),请提出一个简短问题并等待回复。在得到回复前,请勿探测、抓取或进行验证。
您希望我查找SDK方法(文档)还是现在通过CLI执行该操作?
收到回复后,按照用户给出的信号直接路由。

After classification

分类完成后

  • Always (first invocation in conversation) → run Project signals. Cheap local probe; populates session context for every track.
  • Track D → skip the CLI gate and CLI + credentials probes. Consume project signals, then go to
    docs-search.md
    .
  • Tracks A, B, C, E → run the CLI gate then CLI + credentials, then the track. Project signals inform the one-line status and routing.
  • Bare
    /stream
    with no args
    → list the available tracks briefly and wait for input.

  • 始终(会话中的首次调用) → 运行项目信号探测。这是本地轻量探测;会为所有追踪路径填充会话上下文。
  • 追踪路径D → 跳过CLI验证CLI + 凭证探测。利用项目信号,然后跳转至**
    docs-search.md
    **。
  • 追踪路径A、B、C、E → 运行CLI验证,然后运行CLI + 凭证探测,再进入对应追踪路径。项目信号会影响单行状态显示和路由。
  • 仅输入
    /stream
    且无参数 → 简要列出可用的追踪路径并等待输入。

Project signals (always — once per session)

项目信号探测(始终执行——每次会话一次)

A local-only probe. No CLI binary, no network, no gate. Both Track D and tracks A/B/C/E consume the result, so it's worth running once on the first invocation regardless of which track was picked.
bash
bash -c 'echo "=== PKG ==="; grep -oE "\"(stream-chat[^\"]*|@stream-io/[^\"]*)\": *\"[^\"]*\"" package.json 2>/dev/null; echo "=== NEXT ==="; test -f package.json && grep -q "\"next\"" package.json && echo "NEXTJS" || echo "NO_NEXT"; echo "=== NATIVE ==="; ls pubspec.yaml go.mod requirements.txt pyproject.toml Podfile build.gradle 2>/dev/null; echo "=== EMPTY ==="; test -z "$(ls -A 2>/dev/null)" && echo "EMPTY_CWD" || echo "NON_EMPTY"'
Do NOT use
bash -ce
(
-e
= exit-on-error):
grep
returns exit 1 when it finds no matches, which aborts the entire probe and leaves you with partial output. Same applies to every other probe in this file.
This gives you:
  • PKG: Stream npm packages with versions (e.g.
    "stream-chat-react": "^14.2.0"
    ) — empty if none
  • NEXT:
    NEXTJS
    if
    next
    is in
    package.json
    , else
    NO_NEXT
  • NATIVE: Names of non-npm project files present (Flutter, Go, Python, iOS, Android)
  • EMPTY:
    EMPTY_CWD
    if cwd is empty, else
    NON_EMPTY
Hold the result in conversation context. Don't re-run unless:
  • A scaffold (Track A) or install (Track E) completed and added new packages
  • The user changed directory mid-conversation
  • A signal you need is missing (e.g., Track D needs a version and
    PKG
    was empty earlier — re-probe one specific file)
Don't print this result as a heading. Use it internally; surface a signal only when it changes what you say to the user (e.g., "I see Chat React v14 — looking up v14 docs.").

这是仅本地执行的探测。无需CLI二进制文件、无需网络、无需验证。追踪路径D和A/B/C/E都会使用探测结果,因此无论选择哪个追踪路径,首次调用时都值得运行一次。
bash
bash -c 'echo "=== PKG ==="; grep -oE "\"(stream-chat[^\"]*|@stream-io/[^\"]*)\": *\"[^\"]*\"" package.json 2>/dev/null; echo "=== NEXT ==="; test -f package.json && grep -q "\"next\"" package.json && echo "NEXTJS" || echo "NO_NEXT"; echo "=== NATIVE ==="; ls pubspec.yaml go.mod requirements.txt pyproject.toml Podfile build.gradle 2>/dev/null; echo "=== EMPTY ==="; test -z "$(ls -A 2>/dev/null)" && echo "EMPTY_CWD" || echo "NON_EMPTY"'
请勿使用
bash -ce
-e
表示遇到错误即退出):当
grep
未找到匹配项时会返回退出码1,这会终止整个探测并导致输出不完整。此文件中的所有其他探测也遵循此规则。
探测结果包含:
  • PKG: 带版本号的Stream npm包(例如
    "stream-chat-react": "^14.2.0"
    )——无匹配时为空
  • NEXT: 如果
    package.json
    中包含
    next
    则返回
    NEXTJS
    ,否则返回
    NO_NEXT
  • NATIVE: 存在的非npm项目文件名称(Flutter、Go、Python、iOS、Android)
  • EMPTY: 当前目录为空则返回
    EMPTY_CWD
    ,否则返回
    NON_EMPTY
将结果保存在会话上下文中。仅在以下情况重新运行:
  • 脚手架(追踪路径A)或安装(追踪路径E)完成并添加了新包
  • 用户在会话中途切换了目录
  • 需要的信号缺失(例如,追踪路径D需要版本号但之前的
    PKG
    为空——重新探测特定文件)
请勿将此结果作为标题打印。仅在内部使用;仅当结果会改变您对用户说的内容时才展示(例如“我看到您使用的是Chat React v14——正在查找v14版本的文档。”)。

CLI gate (tracks A, B, C, E only)

CLI验证(仅适用于追踪路径A、B、C、E)

Track D skips this step. For all other tracks: verify the
stream
executable
is installed and runnable before any further work.
  1. Run:
    bash
    bash -c 'command -v stream >/dev/null 2>&1 && stream --version || echo "NOT_FOUND"'
  2. If the output is
    NOT_FOUND
    or either command fails:
    stop here. Do not proceed to the credentials probe, builder,
    stream api
    , credential checks, or SDK wiring. Follow
    bootstrap.md
    (explain what the CLI is, ask the user once for permission to install, then run the install — needs network approval). Do not suggest continuing scaffold/CLI work without the binary; only after the user declines install may you offer read-only help from
    sdk.md
    per bootstrap, or hand the user back to Track D for documentation questions.
  3. If
    stream --version
    succeeds:
    continue to the credentials probe.

追踪路径D跳过此步骤。对于其他所有追踪路径:在进行后续操作前,先验证**
stream
可执行文件**已安装且可运行。
  1. 运行:
    bash
    bash -c 'command -v stream >/dev/null 2>&1 && stream --version || echo "NOT_FOUND"'
  2. 如果输出为
    NOT_FOUND
    或任一命令失败:
    在此停止。请勿继续进行凭证探测、构建器操作、
    stream api
    调用、凭证检查或SDK配置。遵循**
    bootstrap.md
    (解释CLI是什么,询问用户一次是否允许安装,然后执行安装——需要网络权限)。请勿建议在没有二进制文件的情况下继续脚手架/CLI操作;仅当用户拒绝安装时,才可根据引导步骤提供来自
    sdk.md
    **的只读帮助,或引导用户返回追踪路径D进行文档查询。
  3. 如果
    stream --version
    执行成功:
    继续进行凭证探测。

CLI + credentials probe (tracks A, B, C, E only)

CLI + 凭证探测(仅适用于追踪路径A、B、C、E)

Run this single probe to confirm the CLI works and credentials are available. Project signals are already in context from the earlier local probe — don't repeat them here.
bash
bash -c 'echo "=== CLI ==="; command -v stream 2>/dev/null; stream --version 2>/dev/null || echo "NOT_FOUND"; echo "=== CONFIG ==="; stream config list 2>/dev/null || echo "NO_CONFIG"'
This gives you:
  • CLI state: installed or not (should already be OK after the CLI gate)
  • Config state: CLI configured (
    cli-configured
    ) or not (
    NO_CONFIG
    )
.env
is intentionally NOT checked here.
Many sandbox configs install a
PreToolUse
hook that blocks any bash command referencing
.env
— including inside a
bash -c
wrapper — which would silently fail this whole probe. For tracks A (new app) and E (enhance), you'll either create a fresh
.env
via
stream env
(Task B) or work in a project that already has one; the project-signals probe tells you whether you're in an existing project.
Auth check (run only on tracks A/B/E that need to make
stream api
calls):
The probe above does NOT verify you're logged in —
stream config list
succeeds even when unauthenticated. Run one auth-requiring call, unpiped so the exit code surfaces:
bash
stream api OrganizationRead
Do not pipe through
head
/
tail
/
jq
on this probe — the pipeline exit code is the last command's, which masks the auth failure. If output volume is a concern, redirect:
stream api OrganizationRead >/dev/null 2>&1; echo "exit=$?"
.
  • Exit 0 → authenticated, continue. (Bonus: the output is reusable for Step 2's "check existing orgs".)
  • Exit 2 / "not authenticated" → immediately run
    stream auth login
    as its own Bash invocation (required for browser PKCE — never chain with
    &&
    or wrap inside a heredoc). Do not ask the user first.
  • If
    stream auth login
    hangs past ~60s or the user reports a stuck browser state → run
    stream auth logout
    to clear stale state, then retry
    stream auth login
    once. If the second attempt also hangs, stop and ask the user to complete login manually (they can type
    ! stream auth login
    to run it in-session).
Show a one-line status combining project signals and CLI + credentials:
  • ✓ Stream CLI v0.1.0 · app-a3f7b201 (Feeds + Chat) · Next.js + Chat React v14 · ~/stream-tv
  • ✓ Stream CLI v0.1.0 · configured via CLI · no local project
  • ✓ Stream CLI v0.1.0 · no credentials · empty dir (ready to scaffold)
  • ✗ Stream CLI not found — see bootstrap.md to install
    (only if the CLI gate was skipped in error — do not route onward; go back and run it)

运行此单个探测以确认CLI可用且凭证已就绪。项目信号已从之前的本地探测存入上下文——请勿在此重复。
bash
bash -c 'echo "=== CLI ==="; command -v stream 2>/dev/null; stream --version 2>/dev/null || echo "NOT_FOUND"; echo "=== CONFIG ==="; stream config list 2>/dev/null || echo "NO_CONFIG"'
探测结果包含:
  • CLI状态: 是否已安装(通过CLI验证后应该已就绪)
  • 配置状态: CLI已配置(
    cli-configured
    )或未配置(
    NO_CONFIG
此处特意不检查
.env
文件
。许多沙箱配置会安装
PreToolUse
钩子,阻止任何引用
.env
的bash命令——包括在
bash -c
包装器内的命令——这会导致整个探测静默失败。对于追踪路径A(新应用)和E(增强现有应用),您要么通过
stream env
创建新的
.env
(任务B),要么在已有
.env
的项目中工作;项目信号探测会告知您是否处于现有项目中。
权限检查(仅在需要调用
stream api
的追踪路径A/B/E中运行):
上述探测不会验证您是否已登录——即使未认证,
stream config list
也会执行成功。运行一个需要权限的调用,不要通过管道传递,以便显示退出码:
bash
stream api OrganizationRead
在此探测中请勿通过
head
/
tail
/
jq
进行管道传递——管道的退出码是最后一个命令的退出码,这会掩盖权限失败。如果担心输出量,可以重定向:
stream api OrganizationRead >/dev/null 2>&1; echo "exit=$?"
  • 退出码0 → 已认证,继续。(额外收获:输出可用于步骤2的“检查现有组织”。)
  • 退出码2 / “未认证” → 立即单独调用
    stream auth login
    (浏览器PKCE要求——切勿用
    &&
    链式调用或包裹在 heredoc 中)。无需先询问用户。
  • 如果
    stream auth login
    运行超过约60秒仍未响应,或用户报告浏览器状态卡住 → 运行
    stream auth logout
    清除过期状态,然后重试
    stream auth login
    一次。如果第二次尝试仍卡住,请停止并要求用户手动完成登录(他们可以在会话中输入
    ! stream auth login
    来运行该命令)。
展示结合项目信号和CLI + 凭证状态的单行状态信息
  • ✓ Stream CLI v0.1.0 · app-a3f7b201 (Feeds + Chat) · Next.js + Chat React v14 · ~/stream-tv
  • ✓ Stream CLI v0.1.0 · 通过CLI配置 · 无本地项目
  • ✓ Stream CLI v0.1.0 · 无凭证 · 空目录(可进行脚手架搭建)
  • ✗ Stream CLI未找到 —— 请查看bootstrap.md进行安装
    (仅当CLI验证被错误跳过时显示——请勿继续路由;返回并重新运行验证)

Install

安装

Skill pack:
npx skills add GetStream/agent-skills
(skills.sh) — markdown only, does not install the
stream
binary.
stream
CLI:
See
bootstrap.md
for binary install from
latest.json
/
install.sh
.

技能包:
npx skills add GetStream/agent-skills
skills.sh)——仅包含markdown文件,不会安装
stream
二进制文件。
stream
CLI:
请查看**
bootstrap.md
**了解从
latest.json
/
install.sh
安装二进制文件的方法。

Module map

模块映射

Step 0 picks the track. Each Track section below has the full prerequisites and phase table — this is just the at-a-glance map.
TrackModule(s)
A — Build new app
builder.md
+
builder-ui.md
B — CLI / data query
cli.md
; tricky bodies →
cli-cookbook.md
C — Bootstrap
bootstrap.md
D — Docs search (no CLI gate)
docs-search.md
E — Enhance existing app
builder.md
(skip scaffold) +
references/<Product>.md
SDK wiring inside A/E
sdk.md
+ relevant
references/<Product>.md
Reference blueprints (load only after the user names the product, used by Tracks A and E):
ProductHeader (setup + gotchas)Full blueprints (load per component)
Chat
references/CHAT.md
references/CHAT-blueprints.md
Feeds
references/FEEDS.md
references/FEEDS-blueprints.md
Video
references/VIDEO.md
references/VIDEO-blueprints.md
Moderation
references/MODERATION.md
references/MODERATION-blueprints.md

步骤0选择追踪路径。以下每个追踪路径部分都包含完整的先决条件和阶段表——此部分仅为概览映射。
追踪路径模块
A — 构建新应用
builder.md
+
builder-ui.md
B — CLI / 数据查询
cli.md
; 复杂请求体 →
cli-cookbook.md
C — 初始化引导
bootstrap.md
D — 文档搜索(无需CLI验证)
docs-search.md
E — 增强现有应用
builder.md
(跳过脚手架) +
references/<Product>.md
A/E中的SDK配置
sdk.md
+ 相关的
references/<Product>.md
参考蓝图(仅在用户指定产品后加载,供追踪路径A和E使用):
产品头部文件(设置 + 注意事项)完整蓝图(按组件加载)
Chat
references/CHAT.md
references/CHAT-blueprints.md
Feeds
references/FEEDS.md
references/FEEDS-blueprints.md
Video
references/VIDEO.md
references/VIDEO-blueprints.md
Moderation
references/MODERATION.md
references/MODERATION-blueprints.md

Cross-track follow-ups (use judgment)

跨追踪路径后续操作(酌情处理)

The tracks share a single skill so a result from one can naturally enable an action in another. Surface a follow-up offer when it genuinely helps the user — not as boilerplate on every turn.
  • D → B: A docs answer that names a runnable operation can offer "want me to run that now via CLI?" (only if read-safe or clearly operational intent).
  • B → D: A CLI result that has a relevant docs page can offer "want the page that explains this?" (link only — don't fetch unprompted).
  • A/E → D: After scaffold or integration completes, mention that the SDK + version is preloaded and ask-anything is available.
  • D → A/E: A docs answer that describes a setup-heavy flow can mention scaffold / integrate is available — without running it.
Do not auto-execute a cross-track action. Offer, then wait for the user to confirm. The track switch happens through the user's reply, which re-enters Step 0.

所有追踪路径共享同一个技能,因此一个路径的结果自然可以触发另一个路径的操作。当确实对用户有帮助时再提供后续操作建议——不要在每次交互都作为模板内容。
  • D → B: 如果文档答案提到了可执行操作,可以询问“是否需要我现在通过CLI执行该操作?”(仅适用于只读操作或明确的操作意图)。
  • B → D: 如果CLI结果有相关文档页面,可以询问“是否需要查看解释此内容的文档页面?”(仅提供链接——请勿未经请求抓取内容)。
  • A/E → D: 脚手架或集成完成后,告知用户SDK + 版本已预加载,可随时提问。
  • D → A/E: 如果文档答案描述了一个设置复杂的流程,可以提及提供脚手架/集成服务——但不要自动执行。
请勿自动执行跨追踪路径操作。先提供建议,然后等待用户确认。追踪路径切换通过用户的回复完成,回复会重新进入步骤0。

Track A — Build new app (empty directory)

追踪路径A — 构建新应用(空目录)

Full detail: Steps 0–7 in
builder.md
; Step 4 UI in
builder-ui.md
.
PhaseNameWhat you do
A1CLI gate + context probeRun the CLI gate then CLI + credentials. Show one-line status. If CLI missing, install via
bootstrap.md
before A2 — never skip.
A2ExecuteImmediately start
builder.md
Steps 0–7. Frontend skills + Shadcn/ui are always installed during Step 3 — no prompt needed.
Anti-patterns: running skills install before scaffold; building a moderation review queue in the app.

详细内容: **
builder.md
中的步骤0–7;
builder-ui.md
**中的步骤4 UI部分。
阶段名称操作内容
A1CLI验证 + 上下文探测运行CLI验证,然后运行CLI + 凭证探测。展示单行状态信息。如果CLI缺失,在进入A2前通过**
bootstrap.md
**安装——切勿跳过。
A2执行立即启动
builder.md
中的步骤0–7。步骤3中始终会安装前端技能 + Shadcn/ui——无需提示。
反模式: 在脚手架搭建前安装技能;在应用中构建内容审核队列。

Track B — CLI / data queries

追踪路径B — CLI / 数据查询

Module:
cli.md
.
Prerequisite: Complete the CLI gate — the
stream
CLI must be installed before running queries or credential resolution.
Credential resolution (do this before any
stream api
call):
  1. .env
    in cwd
    has
    STREAM_API_KEY
    → credentials are local. Mention which app you're querying if you can determine it.
  2. No
    .env
    → check
    stream config list
    for configured org/app → use those. Mention: "Querying configured app:
    <app-name>
    ."
  3. Nothing → tell the user: "No Stream credentials found. Run
    stream auth login
    to connect, or
    cd
    into a project with a
    .env
    ."
PhaseNameWhat you doWAIT?
B1Resolve credentialsRun credential resolution above — silently if
.env
or config exists
Only if no credentials found
B2Execute
stream --safe api …
first; exit 5 → explain, confirm, retry without
--safe

模块:
cli.md
.
先决条件: 完成CLI验证——运行查询或凭证解析前必须安装
stream
CLI。
凭证解析(在任何
stream api
调用前执行):
  1. 当前目录下的**
    .env
    **包含
    STREAM_API_KEY
    → 凭证为本地凭证。如果可以确定,说明您正在查询哪个应用。
  2. .env
    文件
    → 检查
    stream config list
    中的已配置组织/应用 → 使用这些配置。说明:“正在查询已配置的应用:
    <app-name>
    。”
  3. 无任何凭证 → 告知用户:“未找到Stream凭证。请运行
    stream auth login
    进行连接,或切换到包含
    .env
    文件的项目目录。”
阶段名称操作内容是否等待?
B1解析凭证执行上述凭证解析——如果
.env
或配置存在则静默执行
仅在未找到凭证时等待
B2执行先运行
stream --safe api …
;如果退出码为5 → 解释原因,确认后不带
--safe
重试

Track C — Bootstrap (install CLI / skill)

追踪路径C — 初始化引导(安装CLI / 技能)

Module:
bootstrap.md
.
PhaseNameWhat you doWAIT?
C1ExplainWhat
stream
is; one confirmation to install
User confirms
C2InstallFollow bootstrap (binary +
npx skills add GetStream/agent-skills
)
As needed

模块:
bootstrap.md
.
阶段名称操作内容是否等待?
C1说明解释
stream
是什么;请求一次安装确认
等待用户确认
C2安装遵循引导步骤(安装二进制文件 +
npx skills add GetStream/agent-skills
根据需要等待

Track D — Docs search (no CLI gate)

追踪路径D — 文档搜索(无需CLI验证)

Module:
docs-search.md
.
The full docs-search engine: SDK identification (explicit input → project signals → keyword inference),
llms.txt
slug resolution, framework-index fetch, page fetch, cited answer. All honesty rules and URL-grounding rules live in
docs-search.md
— read it before answering.
PhaseNameWhat you do
D1Identify SDKExplicit input wins; otherwise consume project signals (PKG / NATIVE already in context); fall back to keyword tiers (Step 1c in
docs-search.md
)
D2Resolve slugFetch
llms.txt
once per conversation, find slug for product + framework
D3Fetch + answerFetch the framework index (verbatim URLs), pick the right page, fetch it, quote and cite
Track D never invokes Write, Edit, npm, scaffold tools, or
Bash(stream *)
. If the user asks for action mid-conversation, offer to switch tracks (D → B/A/E) and re-enter Step 0.

模块:
docs-search.md
.
完整的文档搜索引擎:SDK识别(明确输入 → 项目信号 → 关键词推断)、
llms.txt
路径解析、框架索引抓取、页面抓取、引用式回答。所有诚信规则和URL锚定规则都在
docs-search.md
中——回答前请阅读。
阶段名称操作内容
D1识别SDK明确输入优先;否则使用项目信号(PKG / NATIVE已在上下文中);最后回退到关键词层级(
docs-search.md
中的步骤1c)
D2解析路径每次会话抓取一次
llms.txt
,找到产品 + 框架对应的路径
D3抓取 + 回答抓取框架索引(原始URL),选择正确页面,抓取内容,引用并标注来源
追踪路径D永远不会调用写入、编辑、npm、脚手架工具或
Bash(stream *)
。如果用户在会话中途请求操作,可提供切换追踪路径(D → B/A/E)的选项,然后重新进入步骤0。

Track E — Enhance existing app

追踪路径E — 增强现有应用

For adding Stream products to an existing Next.js project. Uses references files and SDK patterns but skips scaffold entirely.
Prerequisite: Complete the CLI gate — install the
stream
CLI before npm installs,
stream api
setup, or token routes that depend on CLI-backed config.
用于向现有Next.js项目添加Stream产品。使用参考文件和SDK模式,但完全跳过脚手架步骤。
先决条件: 完成CLI验证——在npm安装、
stream api
设置或依赖CLI配置的令牌路由前,必须安装
stream
CLI。

E1: Audit the existing project

E1:审计现有项目

Before writing any code, understand what's already in place:
  1. Packages: Check
    package.json
    for
    stream-chat
    ,
    stream-chat-react
    ,
    @stream-io/video-react-sdk
    ,
    @stream-io/node-sdk
    .
  2. Auth: Does the app already have a
    /api/token
    route? If so, extend it with the new product's token — don't create a second token route.
  3. Credentials: Check for
    .env
    with
    STREAM_API_KEY
    /
    STREAM_API_SECRET
    . If missing, run credential resolution (Track B).
  4. UI framework: Confirm Tailwind, Shadcn, or whatever the project uses. Do not install Shadcn or change the styling setup unless the user asks.
  5. Directory structure: Note whether the project uses
    app/
    or
    src/app/
    — match the existing convention.
在编写任何代码前,先了解现有项目的情况:
  1. 包: 检查
    package.json
    中是否包含
    stream-chat
    stream-chat-react
    @stream-io/video-react-sdk
    @stream-io/node-sdk
  2. 权限: 应用是否已有
    /api/token
    路由?如果有,扩展该路由以返回新产品的令牌——不要创建第二个令牌路由。
  3. 凭证: 检查是否存在包含
    STREAM_API_KEY
    /
    STREAM_API_SECRET
    .env
    文件。如果缺失,执行追踪路径B中的凭证解析。
  4. UI框架: 确认项目使用的是Tailwind、Shadcn或其他框架。除非用户要求,否则不要安装Shadcn或更改样式设置
  5. 目录结构: 注意项目使用的是
    app/
    还是
    src/app/
    ——遵循现有约定。

E2: Install + configure

E2:安装 + 配置

  1. Install only the new SDKs:
    npm install <new-packages> --legacy-peer-deps
    (RULES.md › Package manager).
  2. Configure via CLI: run setup commands from the relevant
    references/<Product>.md
    (App Integration → Setup). For example, Feeds needs feed groups created; Moderation needs blocklist + config.
  3. Import CSS if the product needs it (Chat:
    stream-chat-react/dist/css/v2/index.css
    , Video:
    @stream-io/video-react-sdk/dist/css/styles.css
    ).
  1. 仅安装新的SDK:
    npm install <new-packages> --legacy-peer-deps
    (RULES.md › 包管理器)。
  2. 通过CLI配置: 运行相关
    references/<Product>.md
    中的设置命令(应用集成 → 设置)。例如,Feeds需要创建信息流组;Moderation需要创建黑名单 + 配置。
  3. 导入CSS(如果产品需要):Chat需导入
    stream-chat-react/dist/css/v2/index.css
    ,Video需导入
    @stream-io/video-react-sdk/dist/css/styles.css

E3: Integrate

E3:集成

  1. Token route: Extend the existing
    /api/token
    to return the new product's token alongside existing ones. Follow
    sdk.md
    for server-side instantiation patterns.
  2. API routes: Add product-specific routes from the relevant
    references/<Product>.md
    (App Integration → API Routes). Feeds needs several (
    /api/feed/get
    ,
    /api/feed/post
    , etc.); Chat and Video typically only need the token route.
  3. Components: Load the relevant
    references/<Product>-blueprints.md
    sections and build components using the existing project's patterns and styling conventions — not the builder-ui.md defaults.
  4. State: If the app already manages user state (auth context, session), wire Stream tokens into that — don't add a separate Login Screen unless the app has no auth.
  1. 令牌路由: 扩展现有
    /api/token
    路由,使其在返回现有令牌的同时返回新产品的令牌。遵循
    sdk.md
    中的服务器端实例化模式。
  2. API路由: 添加相关
    references/<Product>.md
    中的产品特定路由(应用集成 → API路由)。Feeds需要多个路由(
    /api/feed/get
    /api/feed/post
    等);Chat和Video通常只需要令牌路由。
  3. 组件: 加载相关
    references/<Product>-blueprints.md
    中的部分内容,并使用现有项目的模式和样式约定构建组件——不要使用builder-ui.md中的默认设置。
  4. 状态: 如果应用已管理用户状态(权限上下文、会话),将Stream令牌接入该状态——除非应用无权限系统,否则不要添加单独的登录界面。

E4: Verify

E4:验证

Run
npx next build
and fix any errors.
运行
npx next build
并修复所有错误。

Key constraints

关键约束

  • Do not re-scaffold, re-initialize Shadcn, install frontend skills, or modify
    globals.css
    /
    layout.tsx
    .
  • Do not overwrite or restructure existing files — add new files alongside them.
  • Do not change the existing auth flow. Adapt Stream's token generation to fit the app's existing auth, not the other way around.
  • If the project uses a different package manager (yarn, pnpm), match what it already uses — the npm-only rule applies to new scaffolds, not existing projects.

  • 请勿重新搭建脚手架、重新初始化Shadcn、安装前端技能或修改
    globals.css
    /
    layout.tsx
  • 请勿覆盖或重构现有文件——在现有文件旁添加新文件。
  • 请勿更改现有权限流程。调整Stream的令牌生成以适配应用的现有权限系统,而非反过来。
  • 如果项目使用其他包管理器(yarn、pnpm),遵循现有包管理器的使用规则——仅npm规则适用于新脚手架项目,不适用于现有项目。

Paths (portable)

路径(可移植)

WhatWhere
Reference headers
agent-skills/skills/stream/references/*.md
Reference blueprints
agent-skills/skills/stream/references/*-blueprints.md
Docs search engine
agent-skills/skills/stream/docs-search.md
CLI endpoint index
~/.stream/cache/API.md
after
stream api --refresh
Skill modules
agent-skills/skills/stream/

内容路径
参考头部文件
agent-skills/skills/stream/references/*.md
参考蓝图
agent-skills/skills/stream/references/*-blueprints.md
文档搜索引擎
agent-skills/skills/stream/docs-search.md
CLI端点索引运行
stream api --refresh
后位于
~/.stream/cache/API.md
技能模块
agent-skills/skills/stream/

Tooling (all hosts)

工具(所有主机)

Loading: This file (
SKILL.md
) +
RULES.md
+ files named by the routing table for the task. Track D loads
docs-search.md
only; tracks A/B/C/E load their respective modules.
Batching: One
bash -c
per builder phase where possible (never
-ce
-e
aborts on any non-zero exit, including
grep
finding nothing).
stream auth login
stays its own invocation for browser PKCE — never chain with
&&
or wrap in a heredoc.
Support: If the user asks for support or how to contact someone, direct them to getstream.io/contact.
加载: 此文件(
SKILL.md
) +
RULES.md
+ 任务路由表中指定名称的文件。追踪路径D仅加载
docs-search.md
;追踪路径A/B/C/E加载各自的模块。
批量处理: 尽可能在每个构建阶段使用一个
bash -c
命令(切勿使用
-ce
——
-e
会在任何非零退出码时终止,包括
grep
未找到匹配项的情况)。
stream auth login
需单独调用以支持浏览器PKCE——切勿用
&&
链式调用或包裹在 heredoc 中。
支持: 如果用户请求支持或询问如何联系相关人员,请引导他们访问getstream.io/contact