pma-draw
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
typefromreferences/node-types.md. Never invent new types unless the user asks and the viewer supports them. - Use predefined edge types only. Pull every edge
typefromreferences/edges.md. Avoid rawdefaultunless 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 agrouptype parent. - Every relationship needs an edge. Proximity alone is not a connection.
- No local render: the skill emits
.rfd.jsononly. Rendering and export happen in pma-viewer (SPA). Quality must be enforced at JSON level — seereferences/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),evidencenodes 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
typefrom the catalog. - Each relationship → pick an edge
typethat matches its semantics (flow, stream, callback, dependency, comparison). - For technical diagrams, add
evidencenodes 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'snodes+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.jsonby default, or a path the user specifies. Extension.rfd.jsonmarks 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.mdcovers the handoff. - Embedding: four paths in
references/integration.md:- React / MDX sites →
<PmaViewer src="..." />component - Plain HTML →
pma-viewerUMD<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
- React / MDX sites →
Reference Packs
references/design.mdVisual pattern library, evidence artifacts, multi-zoom architecture, concept-to-pattern mapping.references/json-schema.mdFile wrapper,nodes/edges/viewportstructure,parentNodegrouping rules, handles.references/node-types.mdPreset custom node catalog with data-schema per type. Semantic, structural, and utility categories.references/edges.mdPreset edge catalog: flow, stream, callback, dependency, comparison, annotated. Handle positions, animation, labels.references/colors.mdSemantic color palette (default / AWS / Azure / GCP / K8s) and text hierarchy. Styled presets in node-types reference this file.references/layouts.mdLayout templates (vertical flow, horizontal pipeline, hub-and-spoke, swimlanes, timeline, matrix) with grid math.references/templates.mdCopy-paste node / edge JSON and full starter diagrams (3-tier, microservices, event-driven, data pipeline, CI/CD).references/validation.mdPre-flight algorithm, checklists, common bug recipes.references/render.mdpma-viewer SPA contract, handoff format, in-viewer export, troubleshooting.references/integration.mdHow 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, thenreferences/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.
More from zzci/skills
pma
Project development lifecycle management with a strict three-phase workflow (investigate -> proposal -> implement), file-based plan tracking in docs/plan/, task tracking in docs/task/, and claim-before-work multi-agent coordination. Use when handling feature development, bug fixes, refactors, planning, progress tracking, or multi-agent execution in an existing codebase. English-first for repository docs and remote-visible metadata; use Chinese docs only when the user explicitly requests a specific document in Chinese.
116pma-web
Frontend implementation guide for PMA-managed React 19 + TypeScript + Vite 8 SPA projects. Defaults to a single-app layout (the right choice for a Rust/Go service that ships a UI); promotes to a Bun monorepo only when multiple apps or shared packages exist. UI is hard-locked to shadcn/ui (base-nova) + `@base-ui/react` — Radix and other UI ecosystems (MUI / Mantine / Chakra / Ant Design / Headless UI / Ariakit / NextUI / …) are forbidden. Covers required quality gates, file-based type-safe routing with TanStack Router, state conventions (TanStack Query + Zustand), Tailwind CSS v4 patterns, Vitest 4 testing, dual-channel theming, i18n, nsl-based dev integration with backend services, and delivery rules for frontend applications.
108pma-rust
Rust implementation guide for PMA-managed multi-crate workspace projects. Covers workspace config, pinned stable toolchains, strict linting with clippy and cargo-cranky, async data access (Diesel-async or SQLx), Axum/Tokio service patterns, layered config with figment + clap, rustls-only TLS, OpenTelemetry observability, and CI quality gates.
94bkd
Operate a BKD kanban board over its REST API. Use when the user wants to manage BKD projects, issue execution workflows, cron jobs, or execution capacity through a reachable BKD server.
93pma-cr
Stack-aware review for local diffs, pull requests, and repository-wide audits. Routes review across shared policy plus language packs for TypeScript frontend, TypeScript backend/Bun, Go, Rust, and Python. Use after implementation, before merge, or when auditing an existing codebase.
91pma-go
Go implementation guide for PMA-managed service and CLI projects. Covers project layout (cmd/internal), strict linting with golangci-lint v2, database access (sqlc + pgx or GORM), HTTP patterns (stdlib + Chi or Gin), layered config with koanf, structured logging with slog, OpenTelemetry observability, and CI quality gates.
91