NiFi Flow Layout
Use this universal skill when any Apache NiFi flow must be readable a year later: clear names, useful comments, compact vertical flow, and connections that do not cross blocks. The skill has no environment-specific defaults: pass the NiFi URL, credentials/certificates, and target process group explicitly.
Workflow
Inspect first
- Read the target process group through NiFi REST.
- Save a JSON snapshot before changing anything.
- Run audit/dry-run before
apply.
Apply the house style
- Main route goes top-to-bottom.
- Input/source nodes go to the top boundary; output/terminal sinks go to the bottom boundary.
- Errors/logs/fallback/notification branches go to a side lane.
- Connections are orthogonal: vertical/horizontal, no diagonals.
- Connection names stay empty. Connections do not support comments in NiFi.
- Every commentable object gets a useful human comment: processor, process group, input port, output port.
- Names use hierarchical numbering:
10, 20, 30, then 30.10, 30.20, then 30.20.10. Never use .00.
- Move processors/ports before drawing long detours. A cleaner node position is better than a giant route rectangle.
Verify visually
- Use Playwright when available to capture real DOM bounding boxes and a screenshot.
- Treat route/label overlap with processors, process groups, ports, or queued boxes as a defect.
Scripts
scripts/nifi_layout.py — REST audit, dry-run, apply, geometry tests.
scripts/nifi_visual_check.cjs — Playwright screenshot and DOM bounding-box capture.
references/layout-rules.md — detailed rules and routing decisions.
Typical commands
python3 scripts/nifi_layout.py \
--base-url https://nifi.example.com/nifi-api \
--group-id <process-group-id> \
--cert /path/client.crt --key /path/client.key \
--mode audit --recursive
python3 scripts/nifi_layout.py \
--base-url https://nifi.example.com/nifi-api \
--group-id <process-group-id> \
--cert /path/client.crt --key /path/client.key \
--mode dry-run --recursive --backup-dir ./nifi-backups
python3 scripts/nifi_layout.py \
--base-url https://nifi.example.com/nifi-api \
--group-id <process-group-id> \
--cert /path/client.crt --key /path/client.key \
--mode apply --recursive --backup-dir ./nifi-backups
Non-negotiable visual rules from real reviews
- Verify with Playwright screenshots after changes; REST geometry is not enough.
- Use boundary-aware layers: sources at top, business processors in middle, terminal outputs at bottom.
- Before adding bends, try moving the source/destination into a cleaner layer or closer side lane.
- Do not leave a huge empty left/right canvas area while another side is overloaded with route loops.
- For dense fan-in, evaluate all useful target sides. Do not force every branch into one side or one shared point.
- Dense fan-in must stay local and comb-shaped. Do not move a sink far away just to make route scoring pass.
- If a lower source crosses the central bus/labels when entering from the left, try right-side entry, but only after checking the full candidate route for component and label blockers.
- Treat connection labels as real obstacles. Lines must not pass through
Name/Queued boxes, even if they do not touch processors.
- Side handler returns should avoid queue labels between main-lane processors. Use a clear side/bottom lane instead of a short route that hides under labels.
- Side handler → output port should not add tiny doglegs when the output centerline is clear; prefer the compact side route.
- Always inspect screenshots for the whole affected area, not only one cropped defect. If the flow is larger than a viewport, pan/scroll and capture more screenshots.
Safety rules
- Do not print secrets or certificate passphrases.
- Do not edit processor business properties unless the user explicitly asked.
- Default to
audit/dry-run; use apply only when implementation is requested.
- Preserve revisions and current processor state; only update names, comments, positions, connection bends, labelIndex, and empty connection names.
- Before
apply, always write a backup flow JSON using --backup-dir.
Review hardening additions
scripts/nifi_layout.py supports --single-group, --group-order top-down, --report-dir, --screenshots-dir, --visual-gate, and PKCS#12 auth via --p12.
- Apply mode is state-preserving by default: processor/port metadata updates do not stop running components; connection updates first try without stopping and only retry by stopping the two endpoint components when the connection queue is empty.
scripts/nifi_visual_check.cjs supports --tile-grid CxR and --tile-dir for large-canvas evidence.
- Dense fan-in, same-column side chains, side-column handler returns, hard label packing, 12px visual label/component clearance, and 32px visual line spacing are handled to prevent merged wires, processor overlaps, queued-label overlaps, and near-touching lines.
- Treat visual X/T line crossings as hard defects; use wider bus lanes instead of ambiguous intersections.
- Non-adjacent segments of the same connection must also keep wide spacing; self-overlapping U-turns are defects.
- Reports include
topology_blockers when a clean visual layout likely requires a graph decision, such as adding a funnel, collector processor, split sink, or separate process group.
1---2name: nifi-flow-layout3description: Use when arranging Apache NiFi processors, process groups, ports, comments, numbering, crossing connections, dense fan-in/fan-out, or reusable readable canvas layouts.4---56# NiFi Flow Layout78Use this universal skill when any Apache NiFi flow must be readable a year later: clear names, useful comments, compact vertical flow, and connections that do not cross blocks. The skill has no environment-specific defaults: pass the NiFi URL, credentials/certificates, and target process group explicitly.910## Workflow11121. **Inspect first**13 - Read the target process group through NiFi REST.14 - Save a JSON snapshot before changing anything.15 - Run audit/dry-run before `apply`.16172. **Apply the house style**18 - Main route goes top-to-bottom.19 - Input/source nodes go to the top boundary; output/terminal sinks go to the bottom boundary.20 - Errors/logs/fallback/notification branches go to a side lane.21 - Connections are orthogonal: vertical/horizontal, no diagonals.22 - Connection names stay empty. Connections do not support comments in NiFi.23 - Every commentable object gets a useful human comment: processor, process group, input port, output port.24 - Names use hierarchical numbering: `10`, `20`, `30`, then `30.10`, `30.20`, then `30.20.10`. Never use `.00`.25 - Move processors/ports before drawing long detours. A cleaner node position is better than a giant route rectangle.26273. **Verify visually**28 - Use Playwright when available to capture real DOM bounding boxes and a screenshot.29 - Treat route/label overlap with processors, process groups, ports, or queued boxes as a defect.3031## Scripts3233- `scripts/nifi_layout.py` — REST audit, dry-run, apply, geometry tests.34- `scripts/nifi_visual_check.cjs` — Playwright screenshot and DOM bounding-box capture.35- `references/layout-rules.md` — detailed rules and routing decisions.3637## Typical commands3839```bash40python3 scripts/nifi_layout.py \41 --base-url https://nifi.example.com/nifi-api \42 --group-id <process-group-id> \43 --cert /path/client.crt --key /path/client.key \44 --mode audit --recursive45```4647```bash48python3 scripts/nifi_layout.py \49 --base-url https://nifi.example.com/nifi-api \50 --group-id <process-group-id> \51 --cert /path/client.crt --key /path/client.key \52 --mode dry-run --recursive --backup-dir ./nifi-backups53```5455```bash56python3 scripts/nifi_layout.py \57 --base-url https://nifi.example.com/nifi-api \58 --group-id <process-group-id> \59 --cert /path/client.crt --key /path/client.key \60 --mode apply --recursive --backup-dir ./nifi-backups61```6263## Non-negotiable visual rules from real reviews6465- Verify with Playwright screenshots after changes; REST geometry is not enough.66- Use boundary-aware layers: sources at top, business processors in middle, terminal outputs at bottom.67- Before adding bends, try moving the source/destination into a cleaner layer or closer side lane.68- Do not leave a huge empty left/right canvas area while another side is overloaded with route loops.69- For dense fan-in, evaluate all useful target sides. Do not force every branch into one side or one shared point.70- Dense fan-in must stay local and comb-shaped. Do not move a sink far away just to make route scoring pass.71- If a lower source crosses the central bus/labels when entering from the left, try right-side entry, but only after checking the full candidate route for component and label blockers.72- Treat connection labels as real obstacles. Lines must not pass through `Name`/`Queued` boxes, even if they do not touch processors.73- Side handler returns should avoid queue labels between main-lane processors. Use a clear side/bottom lane instead of a short route that hides under labels.74- Side handler → output port should not add tiny doglegs when the output centerline is clear; prefer the compact side route.75- Always inspect screenshots for the whole affected area, not only one cropped defect. If the flow is larger than a viewport, pan/scroll and capture more screenshots.7677## Safety rules7879- Do not print secrets or certificate passphrases.80- Do not edit processor business properties unless the user explicitly asked.81- Default to `audit`/`dry-run`; use `apply` only when implementation is requested.82- Preserve revisions and current processor state; only update names, comments, positions, connection bends, labelIndex, and empty connection names.83- Before `apply`, always write a backup flow JSON using `--backup-dir`.84## Review hardening additions8586- `scripts/nifi_layout.py` supports `--single-group`, `--group-order top-down`, `--report-dir`, `--screenshots-dir`, `--visual-gate`, and PKCS#12 auth via `--p12`.87- Apply mode is state-preserving by default: processor/port metadata updates do not stop running components; connection updates first try without stopping and only retry by stopping the two endpoint components when the connection queue is empty.88- `scripts/nifi_visual_check.cjs` supports `--tile-grid CxR` and `--tile-dir` for large-canvas evidence.89- Dense fan-in, same-column side chains, side-column handler returns, hard label packing, 12px visual label/component clearance, and 32px visual line spacing are handled to prevent merged wires, processor overlaps, queued-label overlaps, and near-touching lines.90- Treat visual X/T line crossings as hard defects; use wider bus lanes instead of ambiguous intersections.91- Non-adjacent segments of the same connection must also keep wide spacing; self-overlapping U-turns are defects.92- Reports include `topology_blockers` when a clean visual layout likely requires a graph decision, such as adding a funnel, collector processor, split sink, or separate process group.