Loading...
Loading...
Use when writing or reviewing n8n SDK code that wires IF, Switch, Merge, error outputs, or any multi-input/multi-output connection. Triggers on .add(), .to(), .input(n), .output(n), .onTrue, .onFalse, .onCase, .onError, useDataOfInput, merge, switch, IF nodes, error branches, fan-out, fan-in, or any review of the workflow's connections object.
npx skill4agent add n8n-io/skills n8n-connections.to().to().add().add(node.output(0)).to(target) // ❌ connection silently dropped
.add(node.output(0).to(target)) // ✅validate_workflow.add(...).to(...).add(source.output(n).to(target))source.output(n).to(target).to(target.input(m)).add().add()Wiring a connection?
├── Linear (one source → one target, single output, single input)?
│ └── .add(source).to(target). The simple case; .to() outside is fine here
│ because there's no .output(n) selector inside .add()
│
├── Selector involved (.output(n) or composite handlers)?
│ └── .to() MUST go inside .add(). See "the trap" above
│
├── Targeting a specific input slot on a multi-input node (Merge)?
│ └── .add(source.output(n).to(target.input(m)))
│ AND check useDataOfInput. See references/MERGE_INDEX_RULES.md
│
├── Error branch?
│ └── .add(node.output(1).to(handler))
│ AND set onError: 'continueErrorOutput' on the node config.
│ See references/ERROR_OUTPUTS.md
│
└── Fan-out (one source → many targets) or fan-in (many sources → one target)?
└── See references/FAN_OUT_FAN_IN.md.onTrue.onFalse.onCase.onError.add(ifNode.onTrue(targetA)) // same as .add(ifNode.output(0).to(targetA))
.add(ifNode.onFalse(targetB)) // same as .add(ifNode.output(1).to(targetB))
.add(sw.onCase(2, target)) // same as .add(sw.output(2).to(target))
.add(node.onError(handler)) // same as .add(node.output(1).to(handler)).output(n).add(ifNode.onTrue(targetA))
.add(ifNode.output(0).to(targetB))
// Result: BOTH targetA and targetB on IF's main[0]. Composite + .output(n) merge..add(selector).to(target)validate_workflowcreate_workflow_from_codeupdate_workflowget_workflow_detailsconnectionsmain[i]useDataOfInputonError: 'continueErrorOutput'main[1]references/VERIFICATION.md| File | Read when |
|---|---|
| One source → many targets, or many sources → one target |
| Wiring a Merge node, or you see |
| Adding error handling on an individual node (not error workflow, that's |
| Just created or updated a workflow with non-trivial connections |
| Anti-pattern | What goes wrong | Fix |
|---|---|---|
| Wire silently dropped, validation passes | Move |
Mixing | Off-by-one, wire feeds the wrong input | Use |
Error branch wired without | Branch is unreachable, and node fails the whole workflow on error | Set |
Skipping | Silently broken workflows ship | Always pull and inspect after create/update |
| Reading all four reference files before wiring one connection | Wasted context | Read only the file matching the situation |