Run your first automation
A piece of automation running, and its result where you can see it.
When you finish you will have the edit-run loop every other guide here builds on, on both surfaces.
Why bother
Section titled “Why bother”The alternative to a direct runner is testing your logic by running the thing that uses it.
| Without this | With this |
|---|---|
| To test a five-line transform you run a whole pipeline | You run the five lines |
| A syntax error surfaces after a deploy | It surfaces in under a second |
| The feedback loop is minutes | It is milliseconds |
Before you start
Section titled “Before you start”The kis CLI. Nothing else — no service, no network.
Step 1 — write it
Section titled “Step 1 — write it”hello.yaml:
name: hellotasks: - name: greet print: message: "hello, {{name}}"A flow is a list of named nodes. This one has a single node that writes into the run log, and
{{name}} reads a run variable.
hello.js:
function main(who) { return { greeting: `hello, ${who}` };}The engine calls main by default, and what it returns is the result. A bare return at file
scope is a syntax error — the body must be inside a function:
return { greeting: "hello" }; // SyntaxError: Illegal return statementStep 2 — run it
Section titled “Step 2 — run it”kis flow -f hello.yaml -v name=worldhello, worldexecution engine instance Status: completed Completed Nodes: [greet]-v sets a run variable. The last line is the part worth reading: the engine reports which nodes
completed, which is the record a flow keeps and a script does not.
kis script run hello.js world>> Script: hello.js executed in 0.62msIt ran, and it did not tell you what it returned. That is the thing everyone hits first.
Step 3 — see the result
Section titled “Step 3 — see the result”A flow’s output is whatever its nodes write, plus the completion line. To carry a value between
nodes, capture it with setvar and read it back with {{ }}:
name: hellolist: truetasks: - name: whoami shell: script: whoami setvar: user
- name: greet print: message: "hello, {{user}}"Note list: true. A flow is a graph and there is no fall-through — without it, or without
next: on each node, only the first node runs and the run still reports completed. See
Graphs and sequences.
kis script run hello.js world --debugCompiled in 405.798µsExecution time: 445.436µsResult: {"greeting":"hello, world"}>> Script: hello.js executed in 1.18ms--debug is what prints Result:. The default is quiet on purpose, so the command composes in a
pipeline where the return value goes onward rather than to your terminal.
The two timings are worth separating: compile is paid once per run here, but is amortised when a flow runs the same script repeatedly. Execution is the number that scales with your data.
The same file, both ways
Section titled “The same file, both ways”These are not alternatives you must choose between at the start. A script runs unchanged inside a flow, with the same entry point and the same arguments:
name: hellolist: truetasks: - name: greet script: language: javascript file: ./hello.js args: ["world"] setvar: out
- name: show print: message: "{{out.greeting}}"hello, worldexecution engine instance Status: completed Completed Nodes: [greet show]That is the working order most people settle on: prototype as a script because the loop is a second long, then move it into a flow when it needs to run somewhere other than your terminal.
Verify
Section titled “Verify”| Surface | You should see |
|---|---|
| Flow | Your message, then Status: completed naming every node you expected |
| Script | Your object on the Result: line |
If the flow reports completed but ran fewer nodes than you wrote, that is the fall-through trap —
add list: true or next:. If the script printed a timing line and nothing else, you omitted
--debug.
Adapt it
Section titled “Adapt it”| Change | Flow | Script |
|---|---|---|
| Pass values in | -v k=v, or -e file.yaml | positional args, or --vars k=v |
| Choose what runs | -n <flow-name>, -t <nodes> | --func handler |
| Longer-running work | let the node run; the flow has no wall clock of its own | --timeout ms, default 5000 |
| See more | -l debug | --debug |
Related
Section titled “Related”- Pass data in and get results out
- Validate before you ship
- Flows and scripts — choosing between them