matlab/agent-skills-playground / demos/mbse-with-agentic-ai/skills/system-composer
system-composer
VerifiedUse this skill when authoring reusable, idempotent MATLAB scripts that build System Composer architecture models via the architecture-modeling API — `systemcomposer.createModel`, `addComponent`, `addPort`, `setInterface`, `connect(srcPort, dstPort)`, interface dictionaries (.sldd) with `addInterface`/`addElement`, profiles/stereotypes with `Profile.createProfile` and `addStereotype`, or `systemcomposer.allocation.createAllocationSet`. Also trigger when debugging these APIs (connections that don't appear, interfaces that don't resolve, profile save errors, `createAllocationSet` signature-mismatch errors). Do NOT trigger for ad-hoc structural edits to an already-built model (adding one SubSystem, rewiring a port) — use `building-simulink-models` with `model_edit` for that.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 29.8 KB |
| code/addCommonInterfaces.m | other | 2.2 KB |
| code/buildMySequenceDiagram.m | other | 4.6 KB |
| code/buildMySystemModel.m | other | 2.5 KB |
| code/buildMySystemProfile.m | other | 2.0 KB |
| code/buildMyVariantComposite.m | other | 7.2 KB |
| code/buildMyViews.m | other | 3.7 KB |
| code/checkUnconnectedPorts.m | other | 887 B |
| code/tradeStudy.m | other | 8.1 KB |
code/buildMySystemModel.m
View on GitHubfunction buildMySystemModel(modelName, dictFile, archDir)
% BUILDMYSYSTEMMODEL Create a System Composer architecture model with interface dictionary.
% Deletes and recreates the model and dictionary on every run (idempotent).
%
% Inputs:
% modelName - Name of the System Composer model (string)
% dictFile - Path to the interface dictionary file (.sldd) (string)
% archDir - Directory in which to save the model file (string)
%% Interface Dictionary
if isfile(dictFile)
Simulink.data.dictionary.closeAll("-discard");
delete(dictFile);
end
dict = systemcomposer.createDictionary(dictFile);
% Interfaces — use Type="double" for all elements; document units in comments.
% Do NOT use addValueType for physical quantities — it creates Simulink.ValueType
% objects the bus compiler cannot resolve, causing "update diagram" to fail.
thermalIface = addInterface(dict, "ThermalFluid");
addElement(thermalIface, "Temperature", Type="double"); % K
addElement(thermalIface, "MassFlowRate", Type="double"); % kg/s
% ... add more interfaces here ...
% CRITICAL: save dictionary before creating model, then re-fetch interfaces
dict.save();
thermalIface = dict.getInterface("ThermalFluid"); % re-fetch after save
% ... re-fetch all interfaces ...
%% Architecture Model
if bdIsLoaded(modelName), close_system(modelName, 0); end
model = systemcomposer.createModel(modelName);
arch = model.Architecture;
linkDictionary(model, dictFile);
%% Components
compA = addComponent(arch, "ComponentA");
compB = addComponent(arch, "ComponentB");
%% Ports
addTypedPort(compA.Architecture, "OutPort1", "out", thermalIface);
addTypedPort(compB.Architecture, "InPort1", "in", thermalIface);
%% Connections — use connect(srcPort, dstPort), NO architecture argument
connect(compA.getPort("OutPort1"), compB.getPort("InPort1"));
%% Layout, Save, and Open
Simulink.BlockDiagram.arrangeSystem(modelName);
save_system(char(modelName), char(fullfile(archDir, modelName)));
open_system(char(modelName));
fprintf("Model created: %s\n", modelName);
end
% ── Helpers ──────────────────────────────────────────────────────────────────
function addTypedPort(compArch, name, direction, iface)
port = addPort(compArch, name, direction);
port.setInterface(iface);
end
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |