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
In this repository26 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- agent-browserSkill
- copySkill
- deploy-prodSkill
- linear-oneshotSkill
- project-planningSkill
- project-updateSkill
- pull-requestSkill
- wani-code-reviewSkill
- frontend-designSkill
- knowledge-baseSkill
- release-migrationSkill
- translationsSkill
- visualize-flowSkill
- audit-trackingSkill
- instrument-trackingSkill
- migrate-waniwani-sdk-0.15-to-0.16Skill
- migrate-waniwani-sdk-0.16-to-0.17Skill
- migrate-waniwani-sdk-0.17-to-0.18Skill
- migrate-waniwani-sdk-0.18-to-0.19Skill
- migrate-waniwani-sdk-0.19-to-0.20Skill
- migrate-waniwani-sdk-0.22-to-0.23Skill
- migrate-waniwani-sdk-0.23-to-0.24Skill
- migrate-waniwani-sdk-0.24-to-0.25Skill
- waniwani-sdkSkill
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
- Very specific: line 11
When the user wants to build a new MCP server feature or replace legacy widget patterns, default to createFlow from @waniwani/sdk/mcp.
- Very specific: line 42
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.
- Very specific: line 70
Add a field to FlowInternalState plus its entry in the SEEDS map, and a fresh session starts with it.
- Very specific: line 72
Read it where you need it as internal.<field>, and use takeInternalField(internal, "<field>") when a field is meant to be used once …
- Distinctive: line 85
If the user just wants something running locally, default to option 1.
- Very specific: line 102
Never import interrupt or showWidget directly.
- Very specific: line 106
Forgetting
START/ENDedges: every flow needs addEdge(START, firstNode) and addEdge(lastNode, END). - Very specific: line 111
A greeting or disclaimer node: use the intro config option instead, or it may never reach the user.
≈ “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.
Files
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
FlowInternalStateplus its entry in theSEEDSmap, 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 usetakeInternalField(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:
MemoryKvStore— dev/tests. State lost on restart. No env vars required.- Custom
KvStoreadapter — production self-hosting. Implement against Redis, Upstash, Cloudflare KV, DynamoDB, or any backend. Seesrc/mcp/server/kv/kv-store.tsfor the interface. - No store argument +
WANIWANI_API_KEYenv var — auto-usesWaniwaniKvStore(hosted onapp.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
| Want | Use | Returns |
| Ask the user a question | interrupt({ field: { question } }) | Pauses flow |
| Run silent server work (API call, computation) | Plain object { field: value } | Auto-advances |
| Render a widget UI for selection | showWidget({ 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/ENDedges: every flow needsaddEdge(START, firstNode)andaddEdge(lastNode, END). - Missing
.describe()on state fields: each question carries its field's description asfieldSchema, 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 infields, 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 ofstate: compute it in the node that needs it, or store it server-side keyed byctx.sessionId. A node guarded withif (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 offieldsand 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
introconfig 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 withif (!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:
- Flow API: docs.waniwani.ai/sdk/flows/overview and the pages under
/sdk/flows/ - KV adapters: docs.waniwani.ai/sdk/flows/kv-store
- Self-hosting walkthrough: docs.waniwani.ai/sdk/deployment/self-hosting
- Tier model + free tier: docs.waniwani.ai/sdk/introduction
- Full page index: docs.waniwani.ai/llms.txt
- Project conventions:
CLAUDE.mdin the repo root
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
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.

