agentleFS
WaniWani-AIWaniWani-AI/sdk/.claude/skills/create-flow-app/SKILL.md

create-flow-app

Skill18 starsChanged 5 months agoMITView on GitHub

Scaffold a new multi-step conversational flow with createFlow from @waniwani/sdk/mcp. Triggers when the user is inside this SDK repo and wants to add a new flow, replace legacy createTool/createResource patterns, or set up an MCP server using the open-source path (no API key required). Defaults to OSS-first: in-memory store for dev, adapter recipes for prod, API key as a one-line upgrade.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 1 is distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    When the user wants to build a new MCP server feature or replace legacy widget patterns, default to createFlow from @waniwani/sdk/mcp.

    line 11
  2. Very specific:

    If the flow should introduce the assistant or state a data/GDPR notice, put it on the config as intro — never as a first node.

    line 42
  3. Very specific:

    Add a field to FlowInternalState plus its entry in the SEEDS map, and a fresh session starts with it.

    line 70
  4. Very specific:

    Read it where you need it as internal.<field>, and use takeInternalField(internal, "<field>") when a field is meant to be used once …

    line 72
  5. Distinctive:

    If the user just wants something running locally, default to option 1.

    line 85
  6. Very specific:

    Never import interrupt or showWidget directly.

    line 102
  7. Very specific:

    Forgetting START / END edges: every flow needs addEdge(START, firstNode) and addEdge(lastNode, END).

    line 106
  8. Very specific:

    A greeting or disclaimer node: use the intro config option instead, or it may never reach the user.

    line 111

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Create a flow app

When the user wants to build a new MCP server feature or replace legacy widget patterns, default to createFlow from @waniwani/sdk/mcp. Never recommend createTool / createResource for new code — they're legacy.

Scaffolding template

import { createFlow, END, MemoryKvStore, START } from "@waniwani/sdk/mcp";
import { z } from "zod";

export const myFlow = createFlow({
  id: "my_flow",
  title: "My Flow",
  description: "Use when the user wants to X.",
  state: {
    // Required: every field needs .describe()
    field1: z.string().describe("..."),
  },
})
  .addNode("step1", ({ interrupt }) =>
    interrupt({ field1: { question: "What's your ...?" } }),
  )
  .addNode("done", ({ state }) => ({ summary: `Got ${state.field1}` }))
  .addEdge(START, "step1")
  .addEdge("step1", "done")
  .addEdge("done", END)
  .compile({ store: new MemoryKvStore() });

await myFlow.register(server);

Opening message (intro)

If the flow should introduce the assistant or state a data/GDPR notice, put it on the config as intro — never as a first node. An opening node is skipped once its fields are filled, by an earlier action or by an answer the user gave up front, so a greeting node is the one node most likely never to reach the user.

createFlow({
  id: "my_flow",
  title: "My Flow",
  description: "Use when the user wants to X.",
  intro: {
    verbatim: "Acme is the data controller. Your answers are deleted after 30 days.",
    instructions: "Introduce yourself as Léa from Acme in one short sentence first.",
  },
  state: { /* … */ },
})

verbatim is reproduced word for word, instructions is guidance the model writes from, and either alone is fine (a bare string means verbatim).

The intro is not a node. It is seeded into the session's internal state at start and attached to the first non-error response, whichever node the flow lands on, then taken off so it is never repeated. Internal state is the engine's own state for a session, stored under internal on FlowTokenContent and kept strictly apart from the flow's state: nothing in it is declared by the author, reaches a node, or can be written through stateUpdates. Everything about it lives in internal-state.ts:

  • Add a field to FlowInternalState plus its entry in the SEEDS map, and a fresh session starts with it. Seeds run at compile time, so a malformed config fails at startup.
  • Read it where you need it as internal.<field>, and use takeInternalField(internal, "<field>") when a field is meant to be used once (present = still pending, absent = done).
  • Fields the running version does not recognize are carried through untouched, so a record written by a newer engine survives a call served by an older one.

State store decision

Three options at .compile() time:

  1. MemoryKvStore — dev/tests. State lost on restart. No env vars required.
  2. Custom KvStore adapter — production self-hosting. Implement against Redis, Upstash, Cloudflare KV, DynamoDB, or any backend. See src/mcp/server/kv/kv-store.ts for the interface.
  3. No store argument + WANIWANI_API_KEY env var — auto-uses WaniwaniKvStore (hosted on app.waniwani.ai).

If the user just wants something running locally, default to option 1. Mention the upgrade paths once.

When to use action vs interrupt vs widget nodes

WantUseReturns
Ask the user a questioninterrupt({ field: { question } })Pauses flow
Run silent server work (API call, computation)Plain object { field: value }Auto-advances
Render a widget UI for selectionshowWidget({ tool: displayTool, data, field })Pauses flow

interrupt and showWidget come from the handler's context:

.addNode("ask", ({ interrupt }) => interrupt({ ... }))
.addNode("show", ({ showWidget }) => showWidget({ tool: displayTool, data: { ... } }))

Never import interrupt or showWidget directly.

Common gotchas

  • Forgetting START / END edges: every flow needs addEdge(START, firstNode) and addEdge(lastNode, END).
  • Missing .describe() on state fields: each question carries its field's description as fieldSchema, and the model reads it to phrase the question and to recognize an answer the user already gave. Skipping them degrades the flow significantly.
  • Putting a server-only value in state: the session's first question or widget lists every state field in fields, and any call may write a declared field whose value fits its schema. A lookup id or a price the user must not choose stays out of state: compute it in the node that needs it, or store it server-side keyed by ctx.sessionId. A node guarded with if (state.vehicleId) return {}; keeps whatever value the model sent.
  • Leaving a consent prefillable: wrap a consent, an attestation, or a widget pick that must happen on screen in neverPrefilled(schema). It stays out of fields and takes a value only once the flow asks for it.
  • Calling .compile() with no store and no API key: throws immediately with a clear migration message. Pick one.
  • A greeting or disclaimer node: use the intro config option instead, or it may never reach the user.
  • State is always Partial<TState>: at any node, only fields filled by earlier nodes are populated. Guard with if (!state.x) return {};.

Don't suggest

  • createTool, createResource, registerTools (legacy)
  • WidgetProvider, useWidgetClient, useToolOutput, useDisplayMode, etc. (legacy MCP-widget React hooks)
  • toNextJsHandler, toExpressJsHandler (legacy chat-server adapters)
  • @waniwani/sdk/evals (removed)

These are kept in the codebase but @deprecated. New code shouldn't use them.

Reading guide

User-facing docs are the source of truth for API shapes, and they are hosted, not in this repo. Fetch the page you need:

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.