Agent SkillsTanStack/ai › add-example-tutorial

add-example-tutorial

GitHub

用于生成和发布面向公众的 TanStack AI React 教学示例及文档教程。涵盖从代码生成、精简适配到撰写教程页面及提交 PR 的全流程规范。

.claude/skills/add-example-tutorial/SKILL.md TanStack/ai

Trigger Scenarios

创建新的公开技术教程 添加示例应用代码 编写框架使用指南

Install

npx skills add TanStack/ai --skill add-example-tutorial -g -y
More Options

Non-standard path

npx skills add https://github.com/TanStack/ai/tree/main/.claude/skills/add-example-tutorial -g -y

Use without installing

npx skills use TanStack/ai@add-example-tutorial

指定 Agent (Claude Code)

npx skills add TanStack/ai --skill add-example-tutorial -a claude-code -g -y

安装 repo 全部 skill

npx skills add TanStack/ai --all -g -y

预览 repo 内 skill

npx skills add TanStack/ai --list

SKILL.md

Frontmatter
{
    "name": "add-example-tutorial",
    "description": "Use when adding a public teaching example or a docs tutorial. Don't use for an internal Nx playground (that is new-react-playground), for a package API change with no walkthrough, or for a docs-only copy edit."
}

Add Example Tutorial

Start from the Nx React app generator. Land at examples/react/<slug>/. Then slim the generated lab to the one scenario this tutorial teaches. examples/react/basic-chat and docs/tutorials/basic-chat.md show a finished public example. Do not copy that app. Use the generator as the starting tree.

Load docs, simple-english, and i-have-adhd before writing tutorial pages. Load pr-description before gh pr create and after an agent push on an open PR.

End state

  • App at examples/react/<slug>/ (not examples/<slug>/, not examples/ts-*).
  • pnpm-workspace.yaml includes examples/react/*.
  • Tutorial at docs/tutorials/<slug>.md on "tab": "tutorial".
  • Examples tab child framework/react/examples/<slug> in docs/config.json.
  • Overview / Quick Start (and any recipe) point at the tutorial.
  • GitHub link at the bottom: https://github.com/TanStack/ai/tree/main/examples/react/<slug>.
  • Live sandbox comment on the tutorial page.
  • One PR on this repo.

1. Shape the app

  1. Pick a kebab-case slug.
  2. From the repo root: pnpm nx g @tanstack/workspace-plugin:react-app <slug>. The files land at examples/react/<slug>/.
  3. Slim the generated lab to this tutorial. One adapter. Keep workspace:* for @tanstack/ai* deps. Do not add @tanstack/ai-client (framework packages re-export the client and /byok).
  4. Inline the model id. Read the adapter's current chat model list and pass the latest flagship id as a string literal into the adapter factory. Do not add a model const, a chat-model.ts, a handle-chat-post.ts, or any other one-off helper for the model or the POST body. The route file owns chat().

Do not commit the unused generator extras (every adapter, PKCE, model picker, thinking UI) unless this tutorial teaches them.

2. File layout

Match Basic Chat only for the Start routes folder:

  • src/routes/index.tsx is the page.
  • src/routes/api.chat.ts is the server route (next to index.tsx). Start maps api.chat.ts to /api/chat.
  • tsconfig.json is self-contained (Start-style). Do not extend the repo root.

Add other files only when this tutorial needs them (a key form, a tool, a store). Many examples will not use BYOK. Do not add BYOK files by default.

3. Tutorial page

Load docs. Run its persona and tone gates unless this conversation already chose them.

Open with the problem the reader has, why it matters, and how this tutorial solves it (one short block). Then walk through steps. Each step teaches one piece of that solution and says why that piece exists.

Typical shape (adapt to the scenario; do not force BYOK):

  1. Create a Start app (npx @tanstack/cli@latest create) and install with package-manager tabs. React-only line, no @tanstack/ai-client: react: @tanstack/ai @tanstack/ai-react @tanstack/ai-<adapter>.
  2. Client vs server: what each side is for in this scenario.
  3. Client pieces, one step each, each with why.
  4. Server pieces, one step each, each with why. Put the route at src/routes/api.chat.ts and say that.

Put the sandbox comment and the GitHub link on the page (see End state). Do not add a numbered "try it" step that only repeats those.

Sandbox comment:

<!-- ::client-example library=ai framework=react slug=<slug> -->

Do not mention Nx, generators, or PRs in the tutorial. Code on the page must match the example files.

Install tabs: <!-- ::start:tabs variant="package-manager" mode="install" -->. See the docs skill.

4. Nav and pointers

docs/config.json:

  • Tutorials section "tab": "tutorial", child tutorials/<slug>.
  • Examples section "tab": "examples", child framework/react/examples/<slug>.

Point Overview and Quick Start at the tutorial. Cross-link any recipe that covers the same UI.

examples/README.md: list the new example.

PRs

  • Do not add tests under the example app.
  • Do not commit docs/superpowers/, plans, screenshots, or .agent/.
  • Example-only / docs: no changeset unless a published package changed.
  • Conventional commit. No Co-authored-by.
  • Fill the PR template honestly. Do not tick test:pr if it was not run.

Common mistakes

Mistake Fix
Copy Basic Chat file-for-file Generate, then slim to this scenario
Generate under examples/<slug> The generator writes examples/react/<slug>/
Model const or extra handler file Inline the latest model id in the route
BYOK files on a tutorial that does not need keys Skip them
Tutorial is only commands and code Problem, why, how, then each step as one piece
Skip nav or the sandbox comment Add the Examples tab child and the ::client-example comment
tsconfig.json extends ../../../tsconfig.json Keep a self-contained Start-style tsconfig in the example

Version History

  • 645757a Current 2026-09-22 03:41

Same Skill Collection

.agents/skills/add-example-tutorial/SKILL.md
.agents/skills/gap-analysis/SKILL.md
.agents/skills/i-have-adhd/SKILL.md
.agents/skills/pr-description/SKILL.md
.claude/skills/gap-analysis/SKILL.md
.claude/skills/i-have-adhd/SKILL.md
.claude/skills/pr-description/SKILL.md
.grok/skills/add-example-tutorial/SKILL.md
.grok/skills/gap-analysis/SKILL.md
.grok/skills/i-have-adhd/SKILL.md
.grok/skills/pr-description/SKILL.md
examples/ts-remix-chat/.agents/skills/remix/SKILL.md
packages/ai-code-mode/skills/ai-code-mode/SKILL.md
packages/ai-mcp/skills/ai-mcp/SKILL.md
packages/ai-memory/skills/tanstack-ai-memory-hindsight/SKILL.md
packages/ai-memory/skills/tanstack-ai-memory-honcho/SKILL.md
packages/ai-memory/skills/tanstack-ai-memory-in-memory/SKILL.md
packages/ai-memory/skills/tanstack-ai-memory-mem0/SKILL.md
packages/ai-memory/skills/tanstack-ai-memory-redis/SKILL.md
packages/ai-memory/skills/tanstack-ai-memory/SKILL.md
packages/ai-persistence/skills/ai-persistence/build-cloudflare-adapter/SKILL.md
packages/ai-persistence/skills/ai-persistence/build-cloudflare-artifact-store/SKILL.md
packages/ai-persistence/skills/ai-persistence/build-custom-adapter/SKILL.md
packages/ai-persistence/skills/ai-persistence/build-drizzle-adapter/SKILL.md
packages/ai-persistence/skills/ai-persistence/build-prisma-adapter/SKILL.md
packages/ai-persistence/skills/ai-persistence/server/SKILL.md
packages/ai-persistence/skills/ai-persistence/SKILL.md
packages/ai-persistence/skills/ai-persistence/stores/SKILL.md
packages/ai/skills/ai-core/ag-ui-protocol/SKILL.md
packages/ai/skills/ai-core/chat-experience/SKILL.md
packages/ai/skills/ai-core/custom-backend-integration/SKILL.md
packages/ai/skills/ai-core/debug-logging/SKILL.md
packages/ai/skills/ai-core/locks/SKILL.md
packages/ai/skills/ai-core/middleware/SKILL.md
packages/ai/skills/ai-core/SKILL.md
packages/ai/skills/ai-core/tool-calling/SKILL.md
testing/panel/skills/emoji-storyteller/SKILL.md
testing/panel/skills/haiku/SKILL.md
testing/panel/skills/pirate-speak/SKILL.md
.agents/skills/bugfix-pr/SKILL.md
.agents/skills/docs/SKILL.md
.agents/skills/ponytail/SKILL.md
.agents/skills/pr-sweep/SKILL.md
.agents/skills/simple-english/SKILL.md
.agents/skills/triage-github/SKILL.md
.claude/skills/bugfix-pr/SKILL.md
.claude/skills/docs/SKILL.md
.claude/skills/ponytail/SKILL.md
.claude/skills/pr-sweep/SKILL.md

Metadata

Files
0
Version
645757a
Hash
34eac875
Indexed
2026-09-22 03:41

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-22 11:01
浙ICP备14020137号-1