Agent Skillsstella/stella › conventions-ai

conventions-ai

GitHub

规范AI集成开发,确保SDK状态处理完备、生命周期语义一致及数据持久化安全。适用于构建或审查AI聊天、适配器、流式传输及消息持久化等功能。

.agents/skills/conventions-ai/SKILL.md stella/stella

Trigger Scenarios

构建AI聊天功能 审查模型适配器或工具实现 处理流式传输与消息持久化

Install

npx skills add stella/stella --skill conventions-ai -g -y
More Options

Non-standard path

npx skills add https://github.com/stella/stella/tree/main/.agents/skills/conventions-ai -g -y

Use without installing

npx skills use stella/stella@conventions-ai

指定 Agent (Claude Code)

npx skills add stella/stella --skill conventions-ai -a claude-code -g -y

安装 repo 全部 skill

npx skills add stella/stella --all -g -y

预览 repo 内 skill

npx skills add stella/stella --list

SKILL.md

Frontmatter
{
    "name": "conventions-ai",
    "description": "Apply when building or reviewing Stella AI chat, model\/provider adapters, tools, prompts, streaming, message persistence, approvals, structured output, or AI-generated follow-ups. Enforces exhaustive SDK state handling, truthful capability exposure, recoverable failures, and stream-to-reload parity."
}

AI Conventions

AI integrations are protocol boundaries. Keep SDK evolution, provider iteration, tool failures, persistence, and UI reconstruction from producing silent state loss.

Read the contract first

  • Fetch current documentation for the exact installed AI SDK and adapters before changing lifecycle or state handling. Inspect installed types and implementation when documentation does not define event ordering precisely.
  • Trace the complete vertical path: provider events, server stream bridge, client stream processor, message-part types, persistence validation, reload, and UI. A fix at one layer is incomplete if another layer can discard the same state.

Make SDK states exhaustive

  • Never reinterpret or manually redeclare a protocol shape that can be inherited from upstream. Derive discriminators, states, message parts, hook surfaces, and event unions from the installed SDK's exported types, then lock every member with an exhaustive switch or satisfies Record<UpstreamUnion, ...>. An upstream addition, removal, or rename must fail Stella's typecheck and force an explicit boundary decision.
  • Derive state types from the SDK or Stella's validated boundary type. Handle them with an exhaustive switch plus a never check, or a satisfies Record<SdkState, ...> table.
  • Never use an untyped partial allowlist, truthiness check, or permissive default branch for SDK states. A new SDK member must fail typecheck until its behavior is chosen explicitly.
  • Treat values crossing a process, stream, persistence, or browser boundary as untrusted. Reject malformed or unknown wire values deliberately; accept and preserve every documented state, including partial, approval, error, and terminal variants.
  • Keep success, recoverable failure, incomplete input, and impossible internal invariants distinct. A valid failed tool call is turn data, not malformed chat.

Preserve lifecycle semantics

  • Do not assume one provider iteration or SDK RUN_STARTED / RUN_FINISHED pair equals one user-visible assistant message. Tool cycles may contain multiple model runs that contribute to one assistant turn.
  • Keep a logical assistant message active until the whole turn is complete. Ensure later tool calls, user-input requests, approvals, reasoning, and structured output cannot appear live and then disappear after persistence or refetch.
  • End a tool when its promised user-visible result exists. Do not keep an AI tool unresolved across a later, independent UI decision: for example, an editable document draft completes document creation, while saving or exporting that draft is a separate user action. Otherwise the next user message enters a protocol turn whose preceding tool call still has no result.
  • Model turn ownership explicitly. Pending user-input and approval tools own the turn until resolved; do not show autonomous follow-ups or drain queued messages while the chat is submitted, streaming, awaiting input, or in error recovery.
  • Treat a thread id as a protocol-ownership key. Two independently mounted chat runtimes must not drive the same thread; surfaces that intentionally show one conversation must share one runtime instance. Otherwise allocate a distinct thread so tool continuation, retries, and persistence have one owner.

Advertise only executable capabilities

  • Derive tool schemas and prompt capability instructions from the same executable registry. If a capability cannot succeed in the current context, omit both its tool and its prompt instructions.
  • Give public, fixed catalogs exact schemas. Keep dynamic or private catalogs generic only when exposing their values would leak data or create stale schemas.
  • Instruct the model to recover from tool errors within the same turn: correct the call, choose an available alternative, or continue without the tool. Escalate to a fatal user-visible error only when the turn itself cannot continue.
  • Generate follow-up chips from the user's perspective because they are inserted verbatim as user messages. Suppress them for failed, incomplete, or user-owned turns.

Required tests

  • Add a regression test for every fixed AI bug.
  • When Stella compensates for an SDK lifecycle or event-shape mismatch, add a canary through the real SDK runtime at that boundary. Assert the user-visible invariant across streamed intermediate events, not dependency-private implementation details, so an upgrade fails where the assumption changes.
  • Iterate every SDK union member in state-policy tests. Make the test input type depend on the SDK union so new members cannot be omitted silently.
  • For stream changes, test a multi-run tool cycle and assert the browser-visible message parts equal the persisted parts and the reloaded parts.
  • Cover success, recoverable tool error, incomplete/streaming structured output, approval, pending user input, cancellation, and malformed wire input where the touched boundary supports them.
  • Assert unavailable capabilities are absent from both the final provider tool request and the assembled system prompt.
  • For artifact or file surfaces that spawn chat, assert the new surface has empty history, a thread id distinct from its origin conversation, and a stable id across streaming updates and rerenders.

Review checklist

Before finishing, verify all of these:

  1. Every touched SDK union is exhaustive at compile time.
  2. Every external boundary validates runtime data without dropping valid states.
  3. Live, persisted, and reloaded message parts have the same meaning.
  4. Advertised tools are executable in the current context.
  5. Recoverable failures let the model continue without UX drama.
  6. Pending human interactions retain turn ownership.
  7. Focused tests reproduce lifecycle ordering, not only helper behavior.

Version History

  • dd81665 Current 2026-08-16 07:07

Same Skill Collection

.agents/skills/click-around/SKILL.md
.agents/skills/conventions-db/SKILL.md
.agents/skills/conventions-i18n/SKILL.md
.agents/skills/conventions-ingestion/SKILL.md
.agents/skills/conventions-perf/SKILL.md
.agents/skills/conventions-scale/SKILL.md
.agents/skills/conventions-security/SKILL.md
.agents/skills/conventions-use-effect/SKILL.md
.agents/skills/conventions-ux/SKILL.md
.agents/skills/dev/SKILL.md
.agents/skills/finish-pr/SKILL.md
.agents/skills/new-handler/SKILL.md
.agents/skills/open-pr/SKILL.md
.agents/skills/plan/SKILL.md
.agents/skills/product-deep-think/SKILL.md
.agents/skills/product-think/SKILL.md
.agents/skills/rabbit-round/SKILL.md
.agents/skills/regression-hunt/SKILL.md
.agents/skills/security-audit/SKILL.md
.agents/skills/update-deps/SKILL.md
.ai/local-skills/click-around/SKILL.md
.ai/local-skills/conventions-ai/SKILL.md
.ai/local-skills/conventions-db/SKILL.md
.ai/local-skills/conventions-i18n/SKILL.md
.ai/local-skills/conventions-ingestion/SKILL.md
.ai/local-skills/conventions-perf/SKILL.md
.ai/local-skills/conventions-scale/SKILL.md
.ai/local-skills/conventions-security/SKILL.md
.ai/local-skills/conventions-use-effect/SKILL.md
.ai/local-skills/conventions-ux/SKILL.md
.ai/local-skills/dev/SKILL.md
.ai/local-skills/new-handler/SKILL.md
.ai/local-skills/open-pr/SKILL.md
.ai/local-skills/plan/SKILL.md
.ai/local-skills/product-deep-think/SKILL.md
.ai/local-skills/rabbit-round/SKILL.md
.ai/local-skills/security-audit/SKILL.md
.ai/local-skills/update-deps/SKILL.md
packages/cli/skills/stella-cli/SKILL.md
packages/skills/blueprints/answer-from-sources/SKILL.md
packages/skills/blueprints/blank/SKILL.md
packages/skills/blueprints/check-against-rules/SKILL.md
packages/skills/blueprints/intake-to-draft/SKILL.md
.agents/skills/conventions-testing/SKILL.md
.ai/local-skills/conventions-testing/SKILL.md

Metadata

Files
0
Version
dd81665
Hash
08075741
Indexed
2026-08-16 07:07

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-16 22:26
浙ICP备14020137号-1 $mapa de visitantes$