Skip to content

matlab/agent-skills-playground / demos/mbse-with-agentic-ai/skills/system-composer

system-composer

Verified

Use 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.

code/buildMyViews.m

View on GitHub
function buildMyViews(modelName, profilePrefix, viewSpecs)
% BUILDMYVIEWS Create stereotype-query architecture views on an SC model.
%   Views are filtered lenses on a large architecture — components matching
%   a query over stereotype properties. Useful for review dashboards (cost
%   drivers, high-power components, throughput contributors) and for
%   anything else where you want to answer "which components satisfy X?"
%
%   Idempotent: deletes any existing view with the same name before
%   recreating. Run this AFTER buildXxx.m rebuilds the model — a rebuild
%   wipes previously-created views along with everything else.
%
%   Inputs:
%     modelName      - Name of the SC model to add views to (string)
%     profilePrefix  - Stereotype property path prefix, e.g.
%                      'MyProfile.ComponentProperties.'
%                      (MUST end with a '.')
%     viewSpecs      - N-by-4 cell array of view definitions, each row:
%                        {name, propertyName, op, value, color}
%                      where propertyName is relative to profilePrefix,
%                      op is one of 'gt'|'lt'|'ge'|'le'|'eq'|'ne', and
%                      color is a hex string (e.g. '#D62728'). Named colors
%                      like 'red' / 'blue' work, but only a subset — 'magenta'
%                      fails — so prefer hex. The color column is optional;
%                      default is '#1F77B4' (blue).
%
%   Example:
%     buildMyViews('MySystem', 'MyProfile.ComponentProperties.', {
%         'CostDrivers',      'Cost_credits', 'gt',  150000, 'red';
%         'HighPowerConsumers','Power_kW',     'gt',  20,     'orange';
%         'StructuralMass',   'Mass_kg',      'gt',  1000,   'yellow';
%         'ZeroCost_Flag',    'Cost_credits', 'eq',  0,      'magenta';
%         'ProductionPipeline','Throughput',  'gt',  0,      'green';
%     });
%
%   Views appear in the Views Gallery (openViews(model)) and as a dropdown
%   in the System Composer model canvas.
%
%   For allocation-driven or hand-picked views (no single-property query
%   fits), omit Select and use v.Root.addElement(comp) for each member
%   component. See the 'Explicit element views' note in the skill doc.

    arguments
        modelName     (1,1) string
        profilePrefix (1,1) string
        viewSpecs     cell
    end

    assert(endsWith(profilePrefix, '.'), ...
        'profilePrefix must end with a ''.'' (e.g. ''MyProfile.Stereotype.'')');

    import systemcomposer.query.*;

    model = systemcomposer.openModel(modelName);

    nCreated = 0;
    for i = 1:size(viewSpecs, 1)
        name  = viewSpecs{i, 1};
        prop  = viewSpecs{i, 2};
        op    = viewSpecs{i, 3};
        value = viewSpecs{i, 4};
        color = '#1F77B4';
        if size(viewSpecs, 2) >= 5 && ~isempty(viewSpecs{i, 5})
            color = viewSpecs{i, 5};
        end

        % Idempotent — drop any existing view with the same name first
        try, deleteView(model, name); end %#ok<TRYNC>

        fullProp = char(profilePrefix) + string(prop);
        pv       = PropertyValue(fullProp);
        switch lower(op)
            case 'gt', q = pv >  value;
            case 'lt', q = pv <  value;
            case 'ge', q = pv >= value;
            case 'le', q = pv <= value;
            case 'eq', q = pv == value;
            case 'ne', q = pv ~= value;
            otherwise, error('buildMyViews:badOp', 'Unknown op: %s', op);
        end

        v = createView(model, name, Select=q, Color=color);
        n = numel(find(model, q));
        fprintf('  %-28s %s %s %g  ->  %d match(es)\n', ...
                name, prop, op, value, n);
        nCreated = nCreated + 1;
    end

    save_system(modelName);
    fprintf('Created %d view(s) on %s.\n', nCreated, modelName);
end
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: 471kUpdated Claude CodeCodexVerifiedInstall
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: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
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 availableStars: 322kUpdated Claude CodeCodexVerifiedInstall