Agent Skills › moeru-ai/apeira

moeru-ai/apeira

GitHub

一种极致压缩的沟通模式,通过删除冠词、填充词和客套话,节省约75%的Token使用量,同时保持技术准确性。适用于用户明确要求简洁或低资源消耗的场景。

7 skills 29

Install All Skills

npx skills add moeru-ai/apeira --all -g -y
More Options

List skills in collection

npx skills add moeru-ai/apeira --list

Skills in Collection (7)

一种极致压缩的沟通模式,通过删除冠词、填充词和客套话,节省约75%的Token使用量,同时保持技术准确性。适用于用户明确要求简洁或低资源消耗的场景。
用户说 caveman mode 用户说 talk like caveman 用户说 use caveman 用户说 less tokens 用户说 be brief 用户调用 /caveman
.agents/skills/caveman/SKILL.md
npx skills add moeru-ai/apeira --skill caveman -g -y
SKILL.md
Frontmatter
{
    "name": "caveman",
    "description": "Ultra-compressed communication mode. Cuts token usage ~75% by dropping filler, articles, and pleasantries while keeping full technical accuracy. Use when user says \"caveman mode\", \"talk like caveman\", \"use caveman\", \"less tokens\", \"be brief\", or invokes \/caveman."
}

Respond terse like smart caveman. All technical substance stay. Only fluff die.

Persistence

ACTIVE EVERY RESPONSE once triggered. No revert after many turns. No filler drift. Still active if unsure. Off only when user says "stop caveman" or "normal mode".

Rules

Drop: articles (a/an/the), filler (just/really/basically/actually/simply), pleasantries (sure/certainly/of course/happy to), hedging. Fragments OK. Short synonyms (big not extensive, fix not "implement a solution for"). Abbreviate common terms (DB/auth/config/req/res/fn/impl). Strip conjunctions. Use arrows for causality (X -> Y). One word when one word enough.

Technical terms stay exact. Code blocks unchanged. Errors quoted exact.

Pattern: [thing] [action] [reason]. [next step].

Not: "Sure! I'd be happy to help you with that. The issue you're experiencing is likely caused by..." Yes: "Bug in auth middleware. Token expiry check use < not <=. Fix:"

Examples

"Why React component re-render?"

Inline obj prop -> new ref -> re-render. useMemo.

"Explain database connection pooling."

Pool = reuse DB conn. Skip handshake -> fast under load.

Auto-Clarity Exception

Drop caveman temporarily for: security warnings, irreversible action confirmations, multi-step sequences where fragment order risks misread, user asks to clarify or repeats question. Resume caveman after clear part done.

Example -- destructive op:

Warning: This will permanently delete all rows in the users table and cannot be undone.

DROP TABLE users;

Caveman resume. Verify backup exist first.

用于构建跨平台聊天机器人(Slack、Teams等)的TypeScript SDK。支持事件处理、消息发送、卡片交互、流式AI响应及多适配器部署,提供统一接口实现一次编写处处运行。
需要开发或配置 Slack, Teams, Discord 等平台的聊天机器人 实现聊天应用中的卡片交互、模态框、斜杠命令或文件上传功能 集成 AI SDK 进行流式响应或工具调用 查找 Chat SDK 相关文档或指南以解决接入问题
.agents/skills/chat-sdk/SKILL.md
npx skills add moeru-ai/apeira --skill chat-sdk -g -y
SKILL.md
Frontmatter
{
    "name": "chat-sdk",
    "description": "Build multi-platform chat bots with Chat SDK (`chat` npm package). Use when developers want to build a Slack, Teams, Google Chat, Discord, Telegram, GitHub, Linear, or WhatsApp bot, handle mentions, direct messages, subscribed threads, reactions, slash commands, cards, modals, files, or AI streaming, set up webhook routes or multi-adapter bots, send rich cards or streamed AI responses to chat platforms, or build a custom adapter or state adapter."
}

Chat SDK

Unified TypeScript SDK for building chat bots across Slack, Teams, Google Chat, Discord, Telegram, GitHub, Linear, and WhatsApp. Write bot logic once, deploy everywhere.

Start with published sources

When Chat SDK is installed in a user project, inspect the published files that ship in node_modules:

node_modules/chat/docs/                    # bundled docs
node_modules/chat/dist/index.d.ts          # core API types
node_modules/chat/dist/jsx-runtime.d.ts    # JSX runtime types
node_modules/chat/docs/contributing/       # adapter-authoring docs
node_modules/chat/resources/guides/        # framework/platform guides (markdown)
node_modules/chat/resources/templates.json # starter templates (title, description, href)

If one of the paths below does not exist, that package is not installed in the project yet.

Read these before writing code:

  • node_modules/chat/docs/getting-started.mdx — install and setup
  • node_modules/chat/docs/usage.mdxChat config and lifecycle
  • node_modules/chat/docs/handling-events.mdx — event routing and handlers
  • node_modules/chat/docs/threads-messages-channels.mdx — thread/channel/message model
  • node_modules/chat/docs/posting-messages.mdx — post, edit, delete, schedule
  • node_modules/chat/docs/streaming.mdx — AI SDK integration and streaming semantics
  • node_modules/chat/docs/cards.mdx — JSX cards
  • node_modules/chat/docs/actions.mdx — button/select interactions
  • node_modules/chat/docs/modals.mdx — modal submit/close flows
  • node_modules/chat/docs/slash-commands.mdx — slash command routing
  • node_modules/chat/docs/direct-messages.mdx — DM behavior and openDM()
  • node_modules/chat/docs/files.mdx — attachments/uploads
  • node_modules/chat/docs/state.mdx — persistence, locking, dedupe
  • node_modules/chat/docs/adapters.mdx — cross-platform feature matrix
  • node_modules/chat/docs/api/chat.mdx — exact Chat API
  • node_modules/chat/docs/api/thread.mdx — exact Thread API
  • node_modules/chat/docs/api/message.mdx — exact Message API
  • node_modules/chat/docs/api/modals.mdx — modal element and event details

For the specific adapter or state package you are using, inspect that installed package's dist/index.d.ts export surface in node_modules.

Available resources

Guides

  • node_modules/chat/resources/guides/how-to-build-an-ai-agent-for-slack-with-chat-sdk-and-ai-sdk.md — Build a Slack AI agent using Chat SDK, AI SDK's ToolLoopAgent, and Vercel AI Gateway. Covers project setup, tool definitions, streaming responses, deployment to Vercel, and scaling tool selection with toolpick.
  • node_modules/chat/resources/guides/run-and-track-deploys-from-slack.md — Build a Slack deploy bot with Chat SDK and Vercel Workflow. Dispatch GitHub Actions from a slash command, gate production behind approval, poll for completion, and notify Linear and GitHub when the run finishes.
  • node_modules/chat/resources/guides/triage-form-submissions-with-chat-sdk.md — Build a Slack bot that triages form submissions with interactive cards. Forward, edit, or mark as spam without leaving Slack. Built with Chat SDK, Hono, and Resend.
  • node_modules/chat/resources/guides/how-to-build-a-slack-bot-with-next-js-and-redis.md — This guide walks through building a Slack bot with Next.js, covering project setup, Slack app configuration, event handling, interactive features, and deployment.
  • node_modules/chat/resources/guides/create-a-discord-support-bot-with-nuxt-and-redis.md — This guide walks through building a Discord support bot with Nuxt, covering project setup, Discord app configuration, Gateway forwarding, AI-powered responses, and deployment.
  • node_modules/chat/resources/guides/ship-a-github-code-review-bot-with-hono-and-redis.md — This guide walks through building a GitHub bot that reviews pull requests on demand. When a user @mentions the bot on a PR, Chat SDK picks up the mention, spins up a Vercel Sandbox with the repo cloned, and uses AI SDK to analyze the diff.

Templates

Listed in node_modules/chat/resources/templates.json:

Quick start

import { Chat } from "chat";
import { createSlackAdapter } from "@chat-adapter/slack";
import { createRedisState } from "@chat-adapter/state-redis";

const bot = new Chat({
  userName: "mybot",
  adapters: {
    slack: createSlackAdapter(),
  },
  state: createRedisState(),
  dedupeTtlMs: 600_000,
});

bot.onNewMention(async (thread) => {
  await thread.subscribe();
  await thread.post("Hello! I'm listening to this thread.");
});

bot.onSubscribedMessage(async (thread, message) => {
  await thread.post(`You said: ${message.text}`);
});

Core concepts

  • Chat — main entry point; coordinates adapters, routing, locks, and state
  • Adapters — platform-specific integrations for Slack, Teams, Google Chat, Discord, Telegram, GitHub, Linear, and WhatsApp
  • State adapters — persistence for subscriptions, locks, dedupe, and thread state
  • Thread — conversation context with post(), stream(), subscribe(), setState(), startTyping()
  • Message — normalized content with text, formatted, attachments, author info, and platform raw
  • Channel — container for threads and top-level posts

Event handlers

Handler Trigger
onNewMention Bot @-mentioned in an unsubscribed thread
onDirectMessage New DM in an unsubscribed DM thread
onSubscribedMessage Any message in a subscribed thread
onNewMessage(regex) Regex match in an unsubscribed thread
onReaction(emojis?) Emoji added or removed
onAction(actionIds?) Button clicks and select/radio interactions
onModalSubmit(callbackId?) Modal form submitted
onModalClose(callbackId?) Modal dismissed/cancelled
onSlashCommand(commands?) Slash command invocation
onAssistantThreadStarted Slack assistant thread opened
onAssistantContextChanged Slack assistant context changed
onAppHomeOpened Slack App Home opened
onMemberJoinedChannel Slack member joined channel event

Read node_modules/chat/docs/handling-events.mdx, node_modules/chat/docs/actions.mdx, node_modules/chat/docs/modals.mdx, and node_modules/chat/docs/slash-commands.mdx before wiring handlers. onDirectMessage behavior is documented in node_modules/chat/docs/direct-messages.mdx.

Streaming

Pass any AsyncIterable<string> to thread.post(). For AI SDK, prefer result.fullStream over result.textStream when available so step boundaries are preserved.

import { ToolLoopAgent } from "ai";

const agent = new ToolLoopAgent({ model: "anthropic/claude-4.5-sonnet" });

bot.onNewMention(async (thread, message) => {
  const result = await agent.stream({ prompt: message.text });
  await thread.post(result.fullStream);
});

Key details:

  • streamingUpdateIntervalMs controls post+edit fallback cadence
  • fallbackStreamingPlaceholderText defaults to "..."; set null to disable
  • Structured StreamChunk support is Slack-only; other adapters ignore non-text chunks

Cards and modals (JSX)

Set jsxImportSource: "chat" in tsconfig.json.

Card components:

  • Card, CardText, Section, Fields, Field, Button, CardLink, LinkButton, Actions, Select, SelectOption, RadioSelect, Table, Image, Divider

Modal components:

  • Modal, TextInput, Select, SelectOption, RadioSelect

Button and Modal accept a callbackUrl prop — when triggered, the SDK POSTs the action payload to that URL in addition to firing any onAction / onModalSubmit handler. Use this for webhook-based workflow flows. See node_modules/chat/docs/actions.mdx and node_modules/chat/docs/modals.mdx.

await thread.post(
  <Card title="Order #1234">
    <CardText>Your order has been received.</CardText>
    <Actions>
      <Button id="approve" style="primary">Approve</Button>
      <Button id="reject" style="danger">Reject</Button>
    </Actions>
  </Card>
);

Adapter inventory

See chat-sdk.dev/adapters for the current list of official, vendor-official, and community adapters, including package names and authors. For the exact factory function and config types of an installed adapter, inspect its dist/index.d.ts in node_modules.

Building a custom adapter

Read these published docs first:

  • node_modules/chat/docs/contributing/building.mdx
  • node_modules/chat/docs/contributing/testing.mdx
  • node_modules/chat/docs/contributing/publishing.mdx

Also inspect:

  • node_modules/chat/dist/index.d.tsAdapter and related interfaces
  • node_modules/@chat-adapter/shared/dist/index.d.ts — shared errors and utilities
  • Installed official adapter dist/index.d.ts files — reference implementations for config and APIs

A custom adapter needs request verification, webhook parsing, message/thread/channel operations, ID encoding/decoding, and a format converter. Use BaseFormatConverter from chat and shared utilities from @chat-adapter/shared.

Webhook setup

Each registered adapter exposes bot.webhooks.<name>. Wire those directly to your HTTP framework routes. See node_modules/chat/resources/guides/how-to-build-a-slack-bot-with-next-js-and-redis.md and node_modules/chat/resources/guides/create-a-discord-support-bot-with-nuxt-and-redis.md for framework-specific route patterns.

用于对用户的设计或计划进行深度压力测试。通过逐一提问并推荐答案,遍历决策树分支以消除依赖,直至达成共同理解。若问题可通过代码库解答,则优先探索代码库。
用户希望压力测试计划 用户希望接受设计拷问 用户提及 'grill me'
.agents/skills/grill-me/SKILL.md
npx skills add moeru-ai/apeira --skill grill-me -g -y
SKILL.md
Frontmatter
{
    "name": "grill-me",
    "description": "Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree. Use when user wants to stress-test a plan, get grilled on their design, or mentions \"grill me\"."
}

Interview me relentlessly about every aspect of this plan until we reach a shared understanding. Walk down each branch of the design tree, resolving dependencies between decisions one-by-one. For each question, provide your recommended answer.

Ask the questions one at a time.

If a question can be answered by exploring the codebase, explore the codebase instead.

通过不断追问和压力测试,将用户计划与现有领域模型及文档对齐。在对话中即时更新 CONTEXT.md 术语表,仅在必要时创建 ADR,确保设计决策清晰、一致且符合项目既定规范。
需要验证设计计划是否符合现有领域模型 希望统一团队术语并更新上下文文档 发现代码实现与设计描述存在矛盾
.agents/skills/grill-with-docs/SKILL.md
npx skills add moeru-ai/apeira --skill grill-with-docs -g -y
SKILL.md
Frontmatter
{
    "name": "grill-with-docs",
    "description": "Grilling session that challenges your plan against the existing domain model, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) inline as decisions crystallise. Use when user wants to stress-test a plan against their project's language and documented decisions."
}

Interview me relentlessly about every aspect of this plan until we reach a shared understanding. Walk down each branch of the design tree, resolving dependencies between decisions one-by-one. For each question, provide your recommended answer.

Ask the questions one at a time, waiting for feedback on each question before continuing.

If a question can be answered by exploring the codebase, explore the codebase instead.

Domain awareness

During codebase exploration, also look for existing documentation:

File structure

Most repos have a single context:

/
├── CONTEXT.md
├── docs/
│   └── adr/
│       ├── 0001-event-sourced-orders.md
│       └── 0002-postgres-for-write-model.md
└── src/

If a CONTEXT-MAP.md exists at the root, the repo has multiple contexts. The map points to where each one lives:

/
├── CONTEXT-MAP.md
├── docs/
│   └── adr/                          ← system-wide decisions
├── src/
│   ├── ordering/
│   │   ├── CONTEXT.md
│   │   └── docs/adr/                 ← context-specific decisions
│   └── billing/
│       ├── CONTEXT.md
│       └── docs/adr/

Create files lazily — only when you have something to write. If no CONTEXT.md exists, create one when the first term is resolved. If no docs/adr/ exists, create it when the first ADR is needed.

During the session

Challenge against the glossary

When the user uses a term that conflicts with the existing language in CONTEXT.md, call it out immediately. "Your glossary defines 'cancellation' as X, but you seem to mean Y — which is it?"

Sharpen fuzzy language

When the user uses vague or overloaded terms, propose a precise canonical term. "You're saying 'account' — do you mean the Customer or the User? Those are different things."

Discuss concrete scenarios

When domain relationships are being discussed, stress-test them with specific scenarios. Invent scenarios that probe edge cases and force the user to be precise about the boundaries between concepts.

Cross-reference with code

When the user states how something works, check whether the code agrees. If you find a contradiction, surface it: "Your code cancels entire Orders, but you just said partial cancellation is possible — which is right?"

Update CONTEXT.md inline

When a term is resolved, update CONTEXT.md right there. Don't batch these up — capture them as they happen. Use the format in CONTEXT-FORMAT.md.

CONTEXT.md should be totally devoid of implementation details. Do not treat CONTEXT.md as a spec, a scratch pad, or a repository for implementation decisions. It is a glossary and nothing else.

Offer ADRs sparingly

Only offer to create an ADR when all three are true:

  1. Hard to reverse — the cost of changing your mind later is meaningful
  2. Surprising without context — a future reader will wonder "why did they do it this way?"
  3. The result of a real trade-off — there were genuine alternatives and you picked one for specific reasons

If any of the three is missing, skip the ADR. Use the format in ADR-FORMAT.md.

识别代码库中的架构摩擦,基于领域语言和ADR提出深化重构机会。旨在通过减少浅层模块、解耦紧耦合组件,提升代码的可测试性和AI导航能力。
用户希望改进代码库架构 寻找重构机会 合并紧耦合模块 提高代码可测试性 使代码库更易被AI导航
.agents/skills/improve-codebase-architecture/SKILL.md
npx skills add moeru-ai/apeira --skill improve-codebase-architecture -g -y
SKILL.md
Frontmatter
{
    "name": "improve-codebase-architecture",
    "description": "Find deepening opportunities in a codebase, informed by the domain language in CONTEXT.md and the decisions in docs\/adr\/. Use when the user wants to improve architecture, find refactoring opportunities, consolidate tightly-coupled modules, or make a codebase more testable and AI-navigable."
}

Improve Codebase Architecture

Surface architectural friction and propose deepening opportunities — refactors that turn shallow modules into deep ones. The aim is testability and AI-navigability.

Glossary

Use these terms exactly in every suggestion. Consistent language is the point — don't drift into "component," "service," "API," or "boundary." Full definitions in LANGUAGE.md.

  • Module — anything with an interface and an implementation (function, class, package, slice).
  • Interface — everything a caller must know to use the module: types, invariants, error modes, ordering, config. Not just the type signature.
  • Implementation — the code inside.
  • Depth — leverage at the interface: a lot of behaviour behind a small interface. Deep = high leverage. Shallow = interface nearly as complex as the implementation.
  • Seam — where an interface lives; a place behaviour can be altered without editing in place. (Use this, not "boundary.")
  • Adapter — a concrete thing satisfying an interface at a seam.
  • Leverage — what callers get from depth.
  • Locality — what maintainers get from depth: change, bugs, knowledge concentrated in one place.

Key principles (see LANGUAGE.md for the full list):

  • Deletion test: imagine deleting the module. If complexity vanishes, it was a pass-through. If complexity reappears across N callers, it was earning its keep.
  • The interface is the test surface.
  • One adapter = hypothetical seam. Two adapters = real seam.

This skill is informed by the project's domain model. The domain language gives names to good seams; ADRs record decisions the skill should not re-litigate.

Process

1. Explore

Read the project's domain glossary and any ADRs in the area you're touching first.

Then use the Agent tool with subagent_type=Explore to walk the codebase. Don't follow rigid heuristics — explore organically and note where you experience friction:

  • Where does understanding one concept require bouncing between many small modules?
  • Where are modules shallow — interface nearly as complex as the implementation?
  • Where have pure functions been extracted just for testability, but the real bugs hide in how they're called (no locality)?
  • Where do tightly-coupled modules leak across their seams?
  • Which parts of the codebase are untested, or hard to test through their current interface?

Apply the deletion test to anything you suspect is shallow: would deleting it concentrate complexity, or just move it? A "yes, concentrates" is the signal you want.

2. Present candidates as an HTML report

Write a self-contained HTML file to the OS temp directory so nothing lands in the repo. Resolve the temp dir from $TMPDIR, falling back to /tmp (or %TEMP% on Windows), and write to <tmpdir>/architecture-review-<timestamp>.html so each run gets a fresh file. Open it for the user — xdg-open <path> on Linux, open <path> on macOS, start <path> on Windows — and tell them the absolute path.

The report uses Tailwind via CDN for layout and styling, and Mermaid via CDN for diagrams where a graph/flow/sequence reliably communicates the structure. Mix Mermaid with hand-crafted CSS/SVG visuals — use Mermaid when relationships are graph-shaped (call graphs, dependencies, sequences), and hand-built divs/SVG when you want something more editorial (mass diagrams, cross-sections, collapse animations). Each candidate gets a before/after visualisation. Be visual.

For each candidate, the same template as before, but rendered as a card:

  • Files — which files/modules are involved
  • Problem — why the current architecture is causing friction
  • Solution — plain English description of what would change
  • Benefits — explained in terms of locality and leverage, and how tests would improve
  • Before / After diagram — side-by-side, custom-drawn, illustrating the shallowness and the deepening
  • Recommendation strength — one of Strong, Worth exploring, Speculative, rendered as a badge

End the report with a Top recommendation section: which candidate you'd tackle first and why.

Use CONTEXT.md vocabulary for the domain, and LANGUAGE.md vocabulary for the architecture. If CONTEXT.md defines "Order," talk about "the Order intake module" — not "the FooBarHandler," and not "the Order service."

ADR conflicts: if a candidate contradicts an existing ADR, only surface it when the friction is real enough to warrant revisiting the ADR. Mark it clearly in the card (e.g. a warning callout: "contradicts ADR-0007 — but worth reopening because…"). Don't list every theoretical refactor an ADR forbids.

See HTML-REPORT.md for the full HTML scaffold, diagram patterns, and styling guidance.

Do NOT propose interfaces yet. After the file is written, ask the user: "Which of these would you like to explore?"

3. Grilling loop

Once the user picks a candidate, drop into a grilling conversation. Walk the design tree with them — constraints, dependencies, the shape of the deepened module, what sits behind the seam, what tests survive.

Side effects happen inline as decisions crystallize:

  • Naming a deepened module after a concept not in CONTEXT.md? Add the term to CONTEXT.md — same discipline as /grill-with-docs (see CONTEXT-FORMAT.md). Create the file lazily if it doesn't exist.
  • Sharpening a fuzzy term during the conversation? Update CONTEXT.md right there.
  • User rejects the candidate with a load-bearing reason? Offer an ADR, framed as: "Want me to record this as an ADR so future architecture reviews don't re-suggest it?" Only offer when the reason would actually be needed by a future explorer to avoid re-suggesting the same thing — skip ephemeral reasons ("not worth it right now") and self-evident ones. See ADR-FORMAT.md.
  • Want to explore alternative interfaces for the deepened module? See INTERFACE-DESIGN.md.
通过对话澄清需求,构思并设计功能规格。严格禁止直接实现,需先提出设计方案获用户批准,生成文档后停止。
用户希望头脑风暴创意 用户需要设计功能或规格说明
.agents/skills/spark/SKILL.md
npx skills add moeru-ai/apeira --skill spark -g -y
SKILL.md
Frontmatter
{
    "name": "spark",
    "version": "0.1.2",
    "description": "Use when the user wants to brainstorm an idea or design a feature\/spec. Explores intent and requirements through dialogue, then writes a spec document to docs\/spark\/ and STOPS. Does not auto-chain to implementation planning or any other skill."
}

Brainstorming Ideas Into Designs

Help turn ideas into fully formed designs and specs through natural collaborative dialogue.

Start by understanding the current project context, then ask questions one at a time to refine the idea. Once you understand what you're building, present the design and get user approval.

Do NOT invoke any implementation skill, write any code, scaffold any project, or take any implementation action until you have presented a design and the user has approved it. This applies to EVERY project regardless of perceived simplicity.

Anti-Pattern: "This Is Too Simple To Need A Design"

Every project goes through this process. A todo list, a single-function utility, a config change — all of them. "Simple" projects are where unexamined assumptions cause the most wasted work. The design can be short (a few sentences for truly simple projects), but you MUST present it and get approval.

Checklist

You MUST create a task for each of these items and complete them in order:

  1. Explore project context — check files, docs, recent commits
  2. Offer visual companion (if topic will involve visual questions) — this is its own message, not combined with a clarifying question. See the Visual Companion section below.
  3. Ask clarifying questions — one at a time, understand purpose/constraints/success criteria
  4. Propose 2-3 approaches — with trade-offs and your recommendation
  5. Present design — in sections scaled to their complexity, get user approval after each section
  6. Write design doc — save to docs/spark/YYYY-MM-DD-<topic>-design.md and commit
  7. Spec self-review — quick inline check for placeholders, contradictions, ambiguity, scope (see below)
  8. User reviews written spec — ask user to review the spec file before proceeding
  9. Deliver spec to user and STOP — report the spec file path; do not invoke any other skill or start implementation

Process Flow

digraph brainstorming {
    "Explore project context" [shape=box];
    "Visual questions ahead?" [shape=diamond];
    "Offer Visual Companion\n(own message, no other content)" [shape=box];
    "Ask clarifying questions" [shape=box];
    "Propose 2-3 approaches" [shape=box];
    "Present design sections" [shape=box];
    "User approves design?" [shape=diamond];
    "Write design doc" [shape=box];
    "Spec self-review\n(fix inline)" [shape=box];
    "User reviews spec?" [shape=diamond];
    "Deliver spec path to user and STOP" [shape=doublecircle];

    "Explore project context" -> "Visual questions ahead?";
    "Visual questions ahead?" -> "Offer Visual Companion\n(own message, no other content)" [label="yes"];
    "Visual questions ahead?" -> "Ask clarifying questions" [label="no"];
    "Offer Visual Companion\n(own message, no other content)" -> "Ask clarifying questions";
    "Ask clarifying questions" -> "Propose 2-3 approaches";
    "Propose 2-3 approaches" -> "Present design sections";
    "Present design sections" -> "User approves design?";
    "User approves design?" -> "Present design sections" [label="no, revise"];
    "User approves design?" -> "Write design doc" [label="yes"];
    "Write design doc" -> "Spec self-review\n(fix inline)";
    "Spec self-review\n(fix inline)" -> "User reviews spec?";
    "User reviews spec?" -> "Write design doc" [label="changes requested"];
    "User reviews spec?" -> "Deliver spec path to user and STOP" [label="approved"];
}

The terminal state is delivering the spec to the user. STOP. Do NOT invoke any other skill, do NOT start implementation planning, do NOT write code. Report the spec path and end your turn — the user will decide what to do with the spec.

The Process

Understanding the idea:

  • Check out the current project state first (files, docs, recent commits)
  • Before asking detailed questions, assess scope: if the request describes multiple independent subsystems (e.g., "build a platform with chat, file storage, billing, and analytics"), flag this immediately. Don't spend questions refining details of a project that needs to be decomposed first.
  • If the project is too large for a single spec, help the user decompose into sub-projects: what are the independent pieces, how do they relate, what order should they be built? Then brainstorm the first sub-project through the normal design flow. Each sub-project gets its own spec → plan → implementation cycle.
  • For appropriately-scoped projects, ask questions one at a time to refine the idea
  • Prefer multiple choice questions when possible, but open-ended is fine too
  • Only one question per message - if a topic needs more exploration, break it into multiple questions
  • Focus on understanding: purpose, constraints, success criteria

Exploring approaches:

  • Propose 2-3 different approaches with trade-offs
  • Present options conversationally with your recommendation and reasoning
  • Lead with your recommended option and explain why

Presenting the design:

  • Once you believe you understand what you're building, present the design
  • Scale each section to its complexity: a few sentences if straightforward, up to 200-300 words if nuanced
  • Ask after each section whether it looks right so far
  • Cover: architecture, components, data flow, error handling, testing
  • Be ready to go back and clarify if something doesn't make sense

Design for isolation and clarity:

  • Break the system into smaller units that each have one clear purpose, communicate through well-defined interfaces, and can be understood and tested independently
  • For each unit, you should be able to answer: what does it do, how do you use it, and what does it depend on?
  • Can someone understand what a unit does without reading its internals? Can you change the internals without breaking consumers? If not, the boundaries need work.
  • Smaller, well-bounded units are also easier for you to work with - you reason better about code you can hold in context at once, and your edits are more reliable when files are focused. When a file grows large, that's often a signal that it's doing too much.

Working in existing codebases:

  • Explore the current structure before proposing changes. Follow existing patterns.
  • Where existing code has problems that affect the work (e.g., a file that's grown too large, unclear boundaries, tangled responsibilities), include targeted improvements as part of the design - the way a good developer improves code they're working in.
  • Don't propose unrelated refactoring. Stay focused on what serves the current goal.

After the Design

Documentation:

  • Write the validated design (spec) to docs/spark/YYYY-MM-DD-<topic>-design.md
    • (User preferences for spec location override this default)
  • Commit the design document to git

Spec Self-Review: After writing the spec document, look at it with fresh eyes:

  1. Placeholder scan: Any "TBD", "TODO", incomplete sections, or vague requirements? Fix them.
  2. Internal consistency: Do any sections contradict each other? Does the architecture match the feature descriptions?
  3. Scope check: Is this focused enough for a single implementation plan, or does it need decomposition?
  4. Ambiguity check: Could any requirement be interpreted two different ways? If so, pick one and make it explicit.

Fix any issues inline. No need to re-review — just fix and move on.

User Review Gate: After the spec review loop passes, ask the user to review the written spec before proceeding:

"Spec written and committed to <path>. Please review it and let me know if you want to make any changes before we start writing out the implementation plan."

Wait for the user's response. If they request changes, make them and re-run the spec review loop. Only proceed once the user approves.

Done — STOP here:

  • Report the spec file path to the user and end your turn.
  • Do NOT invoke any other skill.
  • Do NOT start implementation planning or write any code.
  • The user will decide what to do with the spec on their own.

Key Principles

  • One question at a time - Don't overwhelm with multiple questions
  • Multiple choice preferred - Easier to answer than open-ended when possible
  • YAGNI ruthlessly - Remove unnecessary features from all designs
  • Explore alternatives - Always propose 2-3 approaches before settling
  • Incremental validation - Present design, get approval before moving on
  • Be flexible - Go back and clarify when something doesn't make sense

Visual Companion

A browser-based companion for showing mockups, diagrams, and visual options during brainstorming. Available as a tool — not a mode. Accepting the companion means it's available for questions that benefit from visual treatment; it does NOT mean every question goes through the browser.

Offering the companion: When you anticipate that upcoming questions will involve visual content (mockups, layouts, diagrams), offer it once for consent:

"Some of what we're working on might be easier to explain if I can show it to you in a web browser. I can put together mockups, diagrams, comparisons, and other visuals as we go. This feature is still new and can be token-intensive. Want to try it? (Requires opening a local URL)"

This offer MUST be its own message. Do not combine it with clarifying questions, context summaries, or any other content. The message should contain ONLY the offer above and nothing else. Wait for the user's response before continuing. If they decline, proceed with text-only brainstorming.

Per-question decision: Even after the user accepts, decide FOR EACH QUESTION whether to use the browser or the terminal. The test: would the user understand this better by seeing it than reading it?

  • Use the browser for content that IS visual — mockups, wireframes, layout comparisons, architecture diagrams, side-by-side visual designs
  • Use the terminal for content that is text — requirements questions, conceptual choices, tradeoff lists, A/B/C/D text options, scope decisions

A question about a UI topic is not automatically a visual question. "What does personality mean in this context?" is a conceptual question — use the terminal. "Which wizard layout works better?" is a visual question — use the browser.

If they agree to the companion, read the detailed guide before proceeding: skills/brainstorming/visual-companion.md

适用于 xsAI 及 @xsai/* 包的开发辅助,支持 OpenAI 兼容接口的文本生成、流式处理、工具调用等。强调轻量级、最小依赖原则,指导包选择、代码示例编写及配置规范。
用户正在使用或评估 xsAI 及其子包 需要构建基于 OpenAI 兼容 API 的轻量级 AI 工作流 比较 xsAI 与其他大型 SDK 的权衡
.agents/skills/xsai/SKILL.md
npx skills add moeru-ai/apeira --skill xsai -g -y
SKILL.md
Frontmatter
{
    "name": "xsai",
    "description": "Use this skill when the user is building with `xsai` or any `@xsai\/*` package, or is evaluating xsAI for a small OpenAI-compatible workflow with text generation, streaming, tool calling, structured output, embeddings, image generation, speech synthesis, or transcription."
}

xsAI

Use this skill for xsai code, package selection, API selection, canonical examples, and positioning.

Use xsAI when

  • The user is already using xsai or any @xsai/* package.
  • The user is evaluating xsAI for an OpenAI-compatible integration.
  • The target API is OpenAI-compatible.
  • The user wants a small runtime or package footprint.
  • The user needs text generation, streaming, structured output, or tool calling without a broad framework.
  • The user is comparing xsai with larger SDKs such as ai or pi and wants the tradeoffs framed clearly.

Do not use xsAI when

  • The user needs a universal provider abstraction beyond OpenAI-compatible APIs.
  • The user wants a batteries-included AI application framework.
  • The task depends on provider-specific APIs that are not exposed through an OpenAI-compatible surface.

Default workflow

  • First inspect the existing dependency and import style in the repo. Preserve xsai versus granular @xsai/* imports unless the user asks to change them.
  • If the user has not chosen xsAI yet, confirm the task fits an OpenAI-compatible surface before recommending it.
  • Prefer the smallest package that solves the task. Use the umbrella xsai package only when the user needs several features at once or explicitly wants one dependency.
  • When writing or editing code, read references/recipes.md first and start from the closest canonical example.
  • Keep examples minimal and runnable. Include baseURL and model explicitly. For hosted providers, show apiKey wired from process.env in Node.js and from localStorage in the browser; omit it only when the target endpoint truly does not need one. Do not recommend hardcoding secrets.
  • Preserve the project's existing schema library and provider wiring unless there is a clear reason to change them.
  • Keep recommendations aligned with xsAI's scope: OpenAI-compatible, Fetch-based, runtime-portable, and intentionally narrow.
  • If the user is optimizing for bundle or install size, explicitly prefer granular packages such as @xsai/generate-text over xsai.
  • If the user asks for broader provider abstraction, say xsAI intentionally does not optimize for that.

References

  • Read references/recipes.md when the user wants code, edits xsAI code, or needs a canonical minimal example.
  • Read references/package-selection.md when the user needs help choosing between xsai and granular packages.
  • Read references/text-stream-tools.md for generateText, streamText, tool calling, and common chat options.
  • Read references/structured-output.md for generateObject, streamObject, tool(), rawTool(), or schema guidance.
  • Read references/media-and-embeddings.md for embeddings, image generation, speech, or transcription.
  • Read references/extensions.md only when the user explicitly needs xsAI extensions such as predefined providers, the OpenAI Responses API, or OTEL telemetry.

API selection rules

  • Use generateText for unary text generation.
  • Use streamText for incremental text, reasoning deltas, tool events, or lightweight agent loops.
  • Use generateObject for validated structured output.
  • Use streamObject when the user needs incremental object parsing.
  • Use tool() when the user has a Standard Schema library such as Zod or Valibot.
  • Use rawTool() when the user already has raw JSON Schema.
  • Use a plain Tool object only when the repo already uses that shape or when avoiding tool()'s async setup matters.

Key constraints

  • baseURL and model are usually required in practice for xsAI calls.
  • apiKey is provider-dependent. Most hosted providers need it; local or proxy endpoints may not. In Node.js, prefer process.env. In browsers, prefer reading from localStorage. Do not recommend hardcoding API keys.
  • xsAI is OpenAI-compatible-first. Do not imply support for non-compatible provider APIs.
  • streamText() returns immediately; callers consume textStream, fullStream, and result promises asynchronously.
  • streamObject() is async because schema conversion happens before streaming starts.
  • stopWhen controls repeated tool-use loops with explicit stop predicates such as stepCountAtLeast() and hasToolCall().
  • generateObject(), streamObject(), and tool() rely on xsschema; some schema vendors need extra JSON Schema converter packages.
  • xsAI is designed to stay small. Avoid recommending the umbrella package when a smaller package is enough.

Positioning

  • Describe xsAI as an extra-small OpenAI-compatible runtime, not as a universal AI SDK.
  • When comparing with ai or pi, focus on size, runtime portability, OpenAI-compatible scope, and simpler primitives. Do not oversell feature breadth.

Docs

  • Public docs: https://xsai.js.org/docs

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