ReactFlow Diagram Creator
Generate .rfd.json files that encode meaning in shape, position, and connection — consumed by a ReactFlow-based viewer (pma-viewer) with a predefined catalog of custom node types.
Keep this entry file small. Load only the references needed for the current diagram.
Always-On Rules
- Isomorphism first: node layout and edge topology must mirror the concept's structure. If removing all labels still communicates the idea, the design is right.
- Use predefined node types only. Pull every node
type from references/node-types.md. Never invent new types unless the user asks and the viewer supports them.
- Use predefined edge types only. Pull every edge
type from references/edges.md. Avoid raw default unless no preset fits.
- Colors come from
references/colors.md. Node styling is driven by the preset; override only when semantics require it.
- Grouping via parent-child, not by drawing a container rectangle. Use
parentNode + extent: "parent" on child nodes and a group type parent.
- Every relationship needs an edge. Proximity alone is not a connection.
- No local render: the skill emits
.rfd.json only. Rendering and export happen in pma-viewer (SPA). Quality must be enforced at JSON level — see references/validation.md.
- Build large diagrams section-by-section. Append nodes/edges per edit, namespace IDs by section prefix (
ingest__, process__, deliver__) to keep cross-section references readable.
Core Workflow
Step 1: Depth Assessment
- Simple / Conceptual — abstract node types (
process, start, end), generic edges. For mental models and philosophies.
- Comprehensive / Technical — semantic node types (
backend, database, queue, ai), evidence nodes with real code/JSON, typed edges (stream, callback). For real systems, protocols, tutorials.
Technical diagrams require research: look up actual specs, endpoints, event names, and data formats before writing JSON.
Step 2: Concept-to-Pattern Mapping
For each major concept pick the visual pattern that mirrors its behavior — fan-out, convergence, tree, timeline, cycle, assembly line, side-by-side, gap, cloud. No two major concepts should share the same pattern. Details in references/design.md.
Step 3: Layout Planning
Pick a layout template from references/layouts.md (vertical-flow, horizontal-pipeline, hub-and-spoke, swimlanes, timeline, matrix). Compute a grid of position values before emitting nodes. ReactFlow uses absolute pixel positions — consistency comes from a shared grid, not from an auto-layout pass.
Step 4: Pick Node & Edge Types
- Each discovered component → pick a node
type from the catalog.
- Each relationship → pick an edge
type that matches its semantics (flow, stream, callback, dependency, comparison).
- For technical diagrams, add
evidence nodes for real code snippets or data payloads.
Step 5: Emit JSON
Write the wrapper + nodes[] + edges[] + viewport. Use predefined templates from references/templates.md as starting points. Keep IDs descriptive (api-server, edge__api-to-db).
Step 6: Validate & Hand Off
Run the pre-flight checklist in references/validation.md (IDs unique, edges reference existing nodes, parentNode refs valid, sourceHandle/targetHandle match node contracts, no position collisions). Then tell the user to open the file in pma-viewer (see references/render.md). The agent cannot see the rendered result, so JSON-level discipline is mandatory.
Section-by-Section for Large Diagrams
- Write the wrapper (
schema, type, viewport, metadata) and Section 1's nodes + edges.
- Append one section per edit. Prefix IDs by section (
ingest__source, ingest__queue) to keep later cross-section edges readable.
- When a new section's edge targets an earlier node, cite the exact existing node ID from the previous section.
- Namespace positions by section: reserve columns (
x) or rows (y) per section so later edits don't collide with earlier ones.
- After all sections exist, re-read the full file once to check edge references and position overlaps before handing off.
Do not generate an entire comprehensive diagram in one response, hand-write a generator script, or delegate JSON emission to a coding sub-agent — each path produces worse output than section-by-section edits.
Output
- File:
docs/architecture/<name>.rfd.json by default, or a path the user specifies. Extension .rfd.json marks the ReactFlow Diagram schema and keeps plain JSON tooling compatibility.
- Viewing: open in pma-viewer (ReactFlow-based SPA). PNG / SVG export and editing are handled there —
references/render.md covers the handoff.
- Embedding: four paths in
references/integration.md:
- React / MDX sites →
<PmaViewer src="..." /> component
- Plain HTML →
pma-viewer UMD <script> + PmaViewer.mount(...)
- Interactive link → hosted viewer with
?src=<url> query param
- Static image (GitHub README, email, PDF) →
GET /render.svg?src=<url> server-rendered SVG endpoint
Reference Packs
references/design.md
Visual pattern library, evidence artifacts, multi-zoom architecture, concept-to-pattern mapping.
references/json-schema.md
File wrapper, nodes / edges / viewport structure, parentNode grouping rules, handles.
references/node-types.md
Preset custom node catalog with data-schema per type. Semantic, structural, and utility categories.
references/edges.md
Preset edge catalog: flow, stream, callback, dependency, comparison, annotated. Handle positions, animation, labels.
references/colors.md
Semantic color palette (default / AWS / Azure / GCP / K8s) and text hierarchy. Styled presets in node-types reference this file.
references/layouts.md
Layout templates (vertical flow, horizontal pipeline, hub-and-spoke, swimlanes, timeline, matrix) with grid math.
references/templates.md
Copy-paste node / edge JSON and full starter diagrams (3-tier, microservices, event-driven, data pipeline, CI/CD).
references/validation.md
Pre-flight algorithm, checklists, common bug recipes.
references/render.md
pma-viewer SPA contract, handoff format, in-viewer export, troubleshooting.
references/integration.md
How downstream consumers embed the diagram: MDX / React component, browser <script> SDK, URL-loaded JSON with the hosted viewer, and server-rendered SVG endpoint (for GitHub READMEs, email, PDFs).
Quick Routing
- Designing from scratch: load
references/design.md, then references/layouts.md.
- Picking node / edge types: load
references/node-types.md + references/edges.md.
- Writing JSON: load
references/json-schema.md + references/templates.md.
- Codebase-to-architecture extraction: load
references/node-types.md + references/layouts.md.
- Validating before delivery: load
references/validation.md.
- Telling the user how to open or export in pma-viewer: load
references/render.md.
- Embedding the diagram in docs (MDX / HTML / README / SVG): load
references/integration.md.
If the project also uses /pma for workflow control, load /pma first, then /pma-draw only when a diagram is required.
1---2name: pma-draw3description: Generate ReactFlow diagrams as .rfd.json files using a predefined library of custom node types, edge presets, and layout templates. Use when the user wants to visualize architectures, workflows, data flows, or concepts, or wants to convert analysis of a codebase into a diagram viewable in a ReactFlow-based SPA.4---5
6# ReactFlow Diagram Creator
7
8Generate `.rfd.json` files that encode meaning in shape, position, and connection — consumed by a ReactFlow-based viewer (pma-viewer) with a predefined catalog of custom node types.
9
10Keep this entry file small. Load only the references needed for the current diagram.
11
12## Always-On Rules
13
141. **Isomorphism first**: node layout and edge topology must mirror the concept's structure. If removing all labels still communicates the idea, the design is right.
152. **Use predefined node types only**. Pull every node `type` from `references/node-types.md`. Never invent new types unless the user asks and the viewer supports them.
163. **Use predefined edge types only**. Pull every edge `type` from `references/edges.md`. Avoid raw `default` unless no preset fits.
174. **Colors come from `references/colors.md`**. Node styling is driven by the preset; override only when semantics require it.
185. **Grouping via parent-child**, not by drawing a container rectangle. Use `parentNode` + `extent: "parent"` on child nodes and a `group` type parent.
196. **Every relationship needs an edge**. Proximity alone is not a connection.
207. **No local render**: the skill emits `.rfd.json` only. Rendering and export happen in pma-viewer (SPA). Quality must be enforced at JSON level — see `references/validation.md`.
218. **Build large diagrams section-by-section**. Append nodes/edges per edit, namespace IDs by section prefix (`ingest__`, `process__`, `deliver__`) to keep cross-section references readable.
22
23## Core Workflow
24
25### Step 1: Depth Assessment
26
27- **Simple / Conceptual** — abstract node types (`process`, `start`, `end`), generic edges. For mental models and philosophies.
28- **Comprehensive / Technical** — semantic node types (`backend`, `database`, `queue`, `ai`), `evidence` nodes with real code/JSON, typed edges (`stream`, `callback`). For real systems, protocols, tutorials.
29
30Technical diagrams require research: look up actual specs, endpoints, event names, and data formats before writing JSON.
31
32### Step 2: Concept-to-Pattern Mapping
33
34For each major concept pick the visual pattern that mirrors its behavior — fan-out, convergence, tree, timeline, cycle, assembly line, side-by-side, gap, cloud. No two major concepts should share the same pattern. Details in `references/design.md`.
35
36### Step 3: Layout Planning
37
38Pick a layout template from `references/layouts.md` (vertical-flow, horizontal-pipeline, hub-and-spoke, swimlanes, timeline, matrix). Compute a grid of `position` values before emitting nodes. ReactFlow uses absolute pixel positions — consistency comes from a shared grid, not from an auto-layout pass.
39
40### Step 4: Pick Node & Edge Types
41
42- Each discovered component → pick a node `type` from the catalog.
43- Each relationship → pick an edge `type` that matches its semantics (flow, stream, callback, dependency, comparison).
44- For technical diagrams, add `evidence` nodes for real code snippets or data payloads.
45
46### Step 5: Emit JSON
47
48Write the wrapper + `nodes[]` + `edges[]` + `viewport`. Use predefined templates from `references/templates.md` as starting points. Keep IDs descriptive (`api-server`, `edge__api-to-db`).
49
50### Step 6: Validate & Hand Off
51
52Run the pre-flight checklist in `references/validation.md` (IDs unique, edges reference existing nodes, `parentNode` refs valid, `sourceHandle`/`targetHandle` match node contracts, no position collisions). Then tell the user to open the file in pma-viewer (see `references/render.md`). The agent cannot see the rendered result, so JSON-level discipline is mandatory.
53
54## Section-by-Section for Large Diagrams
55
561. Write the wrapper (`schema`, `type`, `viewport`, `metadata`) and Section 1's `nodes` + `edges`.
572. Append one section per edit. Prefix IDs by section (`ingest__source`, `ingest__queue`) to keep later cross-section edges readable.
583. When a new section's edge targets an earlier node, cite the exact existing node ID from the previous section.
594. Namespace positions by section: reserve columns (`x`) or rows (`y`) per section so later edits don't collide with earlier ones.
605. After all sections exist, re-read the full file once to check edge references and position overlaps before handing off.
61
62Do **not** generate an entire comprehensive diagram in one response, hand-write a generator script, or delegate JSON emission to a coding sub-agent — each path produces worse output than section-by-section edits.
63
64## Output
65
66- **File**: `docs/architecture/<name>.rfd.json` by default, or a path the user specifies. Extension `.rfd.json` marks the ReactFlow Diagram schema and keeps plain JSON tooling compatibility.
67- **Viewing**: open in pma-viewer (ReactFlow-based SPA). PNG / SVG export and editing are handled there — `references/render.md` covers the handoff.
68- **Embedding**: four paths in `references/integration.md`:
69 - React / MDX sites → `<PmaViewer src="..." />` component
70 - Plain HTML → `pma-viewer` UMD `<script>` + `PmaViewer.mount(...)`
71 - Interactive link → hosted viewer with `?src=<url>` query param
72 - Static image (GitHub README, email, PDF) → `GET /render.svg?src=<url>` server-rendered SVG endpoint
73
74## Reference Packs
75
76- `references/design.md`
77 Visual pattern library, evidence artifacts, multi-zoom architecture, concept-to-pattern mapping.
78- `references/json-schema.md`
79 File wrapper, `nodes` / `edges` / `viewport` structure, `parentNode` grouping rules, handles.
80- `references/node-types.md`
81 Preset custom node catalog with data-schema per type. Semantic, structural, and utility categories.
82- `references/edges.md`
83 Preset edge catalog: flow, stream, callback, dependency, comparison, annotated. Handle positions, animation, labels.
84- `references/colors.md`
85 Semantic color palette (default / AWS / Azure / GCP / K8s) and text hierarchy. Styled presets in node-types reference this file.
86- `references/layouts.md`
87 Layout templates (vertical flow, horizontal pipeline, hub-and-spoke, swimlanes, timeline, matrix) with grid math.
88- `references/templates.md`
89 Copy-paste node / edge JSON and full starter diagrams (3-tier, microservices, event-driven, data pipeline, CI/CD).
90- `references/validation.md`
91 Pre-flight algorithm, checklists, common bug recipes.
92- `references/render.md`
93 pma-viewer SPA contract, handoff format, in-viewer export, troubleshooting.
94- `references/integration.md`
95 How downstream consumers embed the diagram: MDX / React component, browser `<script>` SDK, URL-loaded JSON with the hosted viewer, and server-rendered SVG endpoint (for GitHub READMEs, email, PDFs).
96
97## Quick Routing
98
99- Designing from scratch: load `references/design.md`, then `references/layouts.md`.
100- Picking node / edge types: load `references/node-types.md` + `references/edges.md`.
101- Writing JSON: load `references/json-schema.md` + `references/templates.md`.
102- Codebase-to-architecture extraction: load `references/node-types.md` + `references/layouts.md`.
103- Validating before delivery: load `references/validation.md`.
104- Telling the user how to open or export in pma-viewer: load `references/render.md`.
105- Embedding the diagram in docs (MDX / HTML / README / SVG): load `references/integration.md`.
106
107If the project also uses `/pma` for workflow control, load `/pma` first, then `/pma-draw` only when a diagram is required.