Connect app
Scaffold Nominal Connect apps: a directory containing an app.connect YAML and supporting Python scripts that the user can open in the Connect desktop app.
Available tools and files
Resolve bundled references and assets relative to this skill's installed directory, using the host's resource interface or provided filesystem location. Resolve output files relative to the user's target project; these are separate locations.
Check whether the target directory and file-writing tools are available in this environment. If the user's local project is inaccessible, author a downloadable app directory or archive when supported; otherwise provide the named file contents and setup instructions. Continue to settle the spec before authoring. Running the app requires Nominal Connect and any target devices or services. Distinguish file/schema checks from a successful run in Connect, and state any runtime checks the user still needs to perform.
What a Connect app is
A Nominal Connect app is a directory containing:
app.connect— YAML declaring the UI (tabs, panes, forms, plots, buttons, canvases).- One or more Python scripts launched by the UI. Scripts read UI values, publish to the message bus, stream data back to plots, handle commands, and/or orchestrate test workflows.
- Optional:
requirements.txt, canvas YAMLs, DBC files, device config JSONs, images,README.md.
A user launches the app by opening its directory in Connect. On first load, Connect creates a .venv/ inside the directory and installs connect-python (plus anything in python.packages in app.connect). The user never runs pip install by hand.
Workflow
Step 1. Elicit the spec
Before writing anything, confirm:
- Where does the app live? Ask for the target directory if it isn't obvious from the request.
- What is the UI? Which tabs, what's in each tab (plots, forms, buttons, markdown), what widgets the user interacts with. Sketch a rough layout.
- What Python scripts? One per long-running device/driver, plus any one-shot "run once" scripts and any test workflows. Each script owns exactly one concern.
- What streams and topics? Name each data stream (plot
stream_id) and each message-bus topic (<scope>/<action>). These are strings shared between YAML and Python. - External deps? Hardware libraries (
nominal-instro,pycan, etc.), the Devices panel, streaming persistence to Nominal Core.
If the user gave a freeform description and some of this is ambiguous, ask — don't guess on stream IDs or script boundaries, since they're load-bearing.
Step 2. Pick a starting point
- Trivial / "hello world"-shaped app (one tab, a few widgets, one script): copy
assets/hello-world/into the target directory and modify in place. - Non-trivial app: start from a blank
app.connectand build up, usingreferences/patterns.mdfor the shape of each script.
If the user has existing Connect apps on disk, read those for house conventions before inventing your own. Do not copy a large app wholesale — it drags in unrelated UI. Take the layout idioms and leave the rest.
Step 3. Write app.connect
The grammar is large. Read references/app_connect_schema.md to get the full element catalog (tiles, grids, panes, inputs, displays, plots, actions).
Every app must remain editable in Connect's no-code UI builder. This is a hard requirement, not a preference — users rearrange apps by hand, and an app that has dropped out of the UI builder cannot be fixed without hand-editing YAML. Nothing warns you at load time when an app breaks one of these:
- The top-level
tilesmust be exactly one tile, and it must belayout: tabs. Nest grids inside a tab; never hoist one to the top level. - No second
layout: tabsanywhere below the root — one nested tabs container turns editing off for the whole app. - Every pane must contain exactly one element. Zero renders nothing; two or more locks that pane against editing.
- Every pane must set
should_fill: true. lockdown:must be absent.
The one-element rule is the one that bites, because a useful pane usually needs several widgets. Collect them into a single form element — an element with inputs: counts as one element and can nest displays, inputs, and buttons together. To place widgets side by side, use a grid of one-element panes rather than one pane holding several elements.
Other invariants:
- Every
paneneeds a unique UUIDv4id. Generate one per pane at authoring time —uuidgen | tr '[:upper:]' '[:lower:]'(macOS/Linux) orpython -c "import uuid; print(uuid.uuid4())"— and paste the result directly into the YAML. Never hardcode placeholder strings like00000000-...or reuse IDs across panes; duplicates collide and make panes address the wrong widget. - Widget
ids (theid:on inputs and buttons) are the keys scripts use withclient.get_value(id). Usesnake_case; must be unique across the app. - Stream IDs referenced in plots (
stream_id: foo) are plain strings — scripts create them implicitly the first time they callclient.stream("foo", ...). on_click_actionhas three kinds:_kind: script(launches a Python script),_kind: message(publishes a dict to a message-bus topic, with$widget_idsubstituted from current UI values), and_kind: command(sends a registered command from the command registry).- For apps that persist data, populate
streaming.persistence[]with the target dataset RID and the list of streams to upload.
Step 4. Write the Python scripts
Read references/connect_python_api.md for the full API surface and references/patterns.md for the five idioms (one-shot, long-running driver + UI, closed-loop controller, TestWorkflow orchestrator, Command Registry). Pick the pattern that matches each script's role and adapt it.
Conventions:
- Every script starts with
@connect_python.mainwrapping amain(client)function. logger = connect_python.get_logger(__name__)— this routes to Connect's logs panel.- For any hardware handle, register
client.add_shutdown_callback(lambda: thing.close())early. - Stream IDs, topics, and channel names are plain strings shared between YAML and Python, and nothing type-checks them. A driver script exports its own topic constant and command classes; a
constants.pyholds only what several scripts share. The YAML side has to match by hand. - Reading UI:
client.get_value("id", default)orclient.get_values()(all at once). Writing UI:client.set_value("id", value). - Streaming:
client.stream(stream_id, timestamp, value, name="channel_name")for single-channel,client.stream(stream_id, timestamp, values=[...], names=[...])for multi-channel. - Driver scripts take typed commands: declare
@connect_python.Commandclasses, nest@connect_python.handle_commandhandlers insidemainso they close over the open hardware handle, and endmainwithclient.register_and_wait_for_commands()or the process exits. UI buttons reach them with_kind: command. - Raw message bus is the fallback for schema-less payloads:
client.send_message(topic, dict)to publish, orwith MessageBus(client) as bus: bus.subscribe_to_topic(...)to consume. Inside a loop usetry_receive_message()(non-blocking) rather thanwait_for_message(). - For test workflows, subclass
connect_python.TestWorkflow. Test methods (test_*) run in the order they are defined in the source file, not alphabetically, so give them descriptive names rather than ordering prefixes. Only methods in the class's own body are discovered — inheritedtest_*methods never run. Setself.asset_ridinstart_workflow(using itsclientargument;self.clientis not available yet there) to auto-upload to Nominal Core, and register safe-shutdown withself.add_cleanup(...)so it runs even when a step fails.
Step 5. Sanity-check
Before handing back:
- UI builder compatibility holds: top-level
tilesis exactly onelayout: tabstile, no tabs container is nested below it, every pane holds exactly one element and setsshould_fill: true, and there is nolockdown:key. Check this first — it is the easiest thing to break and the most disruptive to the user. - Every widget
idreferenced inclient.get_value/get_valueshas a matchinginput:entry inapp.connect. - Every
stream_idused inclient.streamappears in at least one plot,display: stream_value, orstreaming.persistence[].streams[]. - Every topic an action targets is served by a script:
_kind: messagetopics have a subscriber, and_kind: commandtopics have a registered command whosecommand_idmatches. - All pane
ids are UUIDv4s and unique. - Shutdown callbacks registered for anything that opens a hardware/network handle.
Do not attempt to run the app — it requires the Connect GUI on the user's machine and often physical hardware. Tell the user how to test manually (e.g. "open the directory in Connect, click Run on my_script.py, verify the plot populates").
Quick decision guide
- User wants one button that runs a script and shows a result? → Pattern 1 in
references/patterns.md. Start fromassets/hello-world/. - User wants live readings from a device + UI to command it? → Pattern 2. One long-running script per device, exposing typed commands.
- User wants live-tunable control loop? → Pattern 3. Control loop on a daemon thread, tunables applied by a command handler under a lock.
- User wants an automated pass/fail test? → Pattern 4.
TestWorkflowwithtest_*methods and acontrols: test_workflowelement. For a procedure with no pass/fail, useAutoSequenceWorkflowwithstep_*methods. - User wants the no-code Command Builder? → Pattern 5. Focus on the command schema;
command_idin YAML is the snake_case of the class name.
Resources
references/app_connect_schema.md— YAML schema: tiles, grids, panes, elements, inputs, actions, streaming. Read this before editingapp.connect.references/connect_python_api.md—connect_pythonAPI: Client methods, MessageBus, decorators, TestWorkflow. Read this before writing scripts.references/patterns.md— Five idiomatic patterns with full YAML+Python examples.assets/hello-world/— Copy-and-modify starter template (one tab, form, button, plot, one script).
Reporting back
When you finish, report concisely:
- Where the app was written (absolute path).
- Which scripts were created and their roles.
- Stream IDs and message-bus topics used.
- How to test manually (open directory in Connect, click Run on
<script>, expected behavior).
Do not narrate intermediate file reads or summarize the full YAML — the user can open the files themselves.


