agentsclimarketplace

Simulink automation

Skill Mistakey/simulink-automation-suite/skills/simulink_automation

Use when working with Simulink models — analyzing topology, inspecting parameters, modifying values, or managing model lifecycle via MATLAB Engine.From its SKILL.md

Install
npx -y skills add Mistakey/simulink-automation-suite --skill simulink_automation

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 9 stars9 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

12.0 KB, as published. Nobody here has run it

Unified skill for all Simulink CLI operations (read-only analysis and parameter editing). Canonical skill name is simulink-automation (module path simulink_cli is internal only). This skill belongs to plugin simulink-automation-suite.

Prerequisites

  • MATLAB Engine for Python installed in the active Python environment.
  • A shared MATLAB session started via matlab.engine.shareEngine in MATLAB.

Discovery

Call schema to get the full runtime contract (actions, fields, types, defaults, error codes):

python -m simulink_cli schema
python -m simulink_cli --json '{"action":"schema"}'

Schema output is the authoritative reference for command syntax. Do not rely on static docs for field names or types.

Workflow Strategy

  1. Discover — list_opened to see available models; session list if multiple MATLAB sessions exist.
  2. Quick lookup — inspect with a specific target and specific param for single-value checks; highlight for visual location.
  3. Deep analysis — delegate to simulink-analyzer agent (see Responsibility & Handoff).
  4. Modify — set_param with dry-run preview before any write; block_add for placing new blocks (note: some library source paths contain literal newlines — use JSON \n escape, common in SPS libraries); line_add for connecting ports (supports both numeric signal ports and physical port names like LConn1/RConn1 for SPS connections); line_delete to remove a signal connection; block_delete to remove a block (also silently removes connected lines). See Write Safety Model below.
  5. Simulate — simulate to run the model simulation after the modeling workflow is complete.
  6. Update — model_update to compile/update diagram after structural changes.
  7. Verify — inspect the target after write to confirm the change took effect.
  8. Finalize — model_save then model_close when done.

Both single-param (param/value) and multi-param (params object) modes available. Always read and understand the model before modifying.

Responsibility & Handoff

This skill and the simulink-analyzer agent have non-overlapping responsibilities.

Direct Handling (this skill)

The following actions are handled directly without dispatching the agent:

ActionReason
session (list/current/use/clear)Meta-query; main agent needs session context for dispatch decisions
list_openedMeta-query; main agent needs model list for dispatch decisions
schemaSelf-discovery; main agent may need the action catalog
highlightUI side-effect; no analysis output to isolate
inspect (specific target + specific param)Single-value response; main agent needs the value in context
set_paramWrite operation; requires user interaction for safety
model_new / model_open / model_saveWrite/lifecycle operations
model_close / model_updateLifecycle operations; direct execution
block_addWrite operation; structural mutation
line_addWrite operation; signal routing
line_deleteWrite operation; signal disconnection
block_deleteWrite operation; structural removal (also removes connected lines)
simulateOperational; runs model simulation
matlab_evalOperational; executes arbitrary MATLAB code

Delegate to simulink-analyzer agent

The following actions are delegated to the analyzer agent for context isolation:

ActionReason
scan (any configuration)Topology output; potentially large
find (any criteria)Search results; potentially large
connections (any configuration)Connection graph; potentially large
inspect (no specific param or param=All)Full parameter list; potentially large
Multi-step read analysis workflowsWorkflow-level context isolation

Before dispatching, resolve session and model via direct session current or list_opened, then provide them explicitly to the agent.

Delegate to sim-analyst agent

ActionReason
Post-simulation signal analysisWaveform data can be millions of points; isolate from main context
Dynamic performance evaluationRise time, overshoot, settling time, steady-state error
Multi-signal comparisonCross-correlation, phase analysis

Before dispatching, ensure simulate has been run (so sl_sim_result exists in workspace). Provide session, model, and specific analysis goals.

Composite Requests

When a user request involves both analysis and modification (e.g., "check the PID parameters, then set Kp to 2.0"):

  1. Dispatch the simulink-analyzer agent for the analysis portion first.
  2. Use the analysis results to execute the write workflow directly via this skill.

Always analyze before writing. Never combine analysis delegation and write execution in a single step.

Write Safety Model

All writes go through a guarded preview-execute-verify cycle:

  1. Preview — set_param defaults to dry_run=true. Returns current_value, proposed_value, apply_payload, and rollback.
  2. Execute — Replay the returned apply_payload verbatim in JSON mode. It carries expected_current_value as a precondition guard.
  3. Verify — Check the verified field in the response. If false, investigate before proceeding.
  4. Rollback — Use the rollback payload from any response to restore the prior value.

If the model changed between preview and execute, precondition_failed is returned without writing. If read-back fails, verification_failed is returned with rollback and write-state data.

For response shape examples, see reference.md.

Recovery Routing

Error-driven next actions (consult schema for the full error code list):

ErrorRecovery
engine_unavailableInstall/configure MATLAB Engine for Python, retry
no_sessionRun matlab.engine.shareEngine in MATLAB, retry
session_requiredsession list → session use <name> or pass --session
session_not_foundsession list → copy exact name, retry
model_requiredlist_opened → retry with explicit --model
model_not_foundlist_opened → open or create the model first
block_not_foundscan or find to locate valid block path
param_not_foundinspect --param All to list available parameters
subsystem_not_foundShallow root scan → select valid subsystem
inactive_parameterUse --resolve-effective or --strict-active
precondition_failedRerun dry-run to refresh, replay new apply_payload
set_param_failedInspect target/value constraints; prefer rollback if write may have occurred
verification_failedInspect target again or use rollback payload
model_already_loadedUse a different name or close existing model
model_save_failedCheck file permissions and disk space
source_not_foundVerify library source path; use find to browse available library blocks
block_already_existsUse a different destination name or inspect existing block
model_dirtymodel_save first, or retry with force: true to discard changes
line_already_existsCheck existing connections with connections; use a different port
line_not_foundVerify src/dst block and port names with connections; confirm the line exists before deleting
simulation_failedCheck model for errors with model_update; fix unconnected ports or type mismatches, then retry
update_failedCheck model for errors (unconnected ports, type mismatches); fix with set_param or line_add, retry
eval_failedCheck MATLAB code syntax and referenced variables/functions; retry with corrected code
eval_timeoutIncrease timeout or simplify the code; avoid infinite loops
state_write_failed / state_clear_failedCheck plugin state-file permissions or pass explicit --session
invalid_json / json_conflict / unknown_parameter / invalid_inputCorrect request payload per schema, retry
find returns emptyBroaden name pattern, try different block_type, widen scope

Common Patterns

Recipes for tasks that combine multiple actions. These patterns use existing CLI capabilities — no additional tools required.

Query Bus Selector signal list

The signal names live in the InputSignals parameter, which is populated only after model compilation:

  1. model_update — compile the model diagram.
  2. inspect with --target MyModel/BusSel --param InputSignals — returns the comma-separated signal list.

Discover library block paths

Library paths vary by toolbox. block_add auto-loads the library root on first use, so you only need the correct path:

  • Standard library: simulink/Math Operations/Gain, simulink/Sources/Step
  • SPS / Simscape: powerlib/powergui, spsUniversalBridgeLib/Universal Bridge
  • Some paths contain literal newlines: simulink/Signal\nRouting/Mux. In JSON mode use the \n escape.

When source_not_found persists after auto-load, verify the path in MATLAB documentation or via find_system('<library>', 'Type', 'block').

SPS physical connections

SPS (Simscape / Specialized Power Systems) blocks use physical ports (LConn1, RConn1, etc.) instead of numbered signal ports. line_add supports these directly:

{"action": "line_add", "model": "MyModel", "src_block": "DC_Source", "src_port": "LConn1", "dst_block": "Inverter", "dst_port": "LConn1"}

Use connections on a block to discover its physical port names — they appear in physical_neighbors with "type": "physical".

Multi-line MATLAB code via matlab_eval

matlab_eval accepts multi-line code as a single JSON string. Use \n for line breaks in the JSON payload:

{"action": "matlab_eval", "code": "x = 42;\nfprintf('value = %d\\n', x);\ndisp(x)"}

Key points:

  • Output is captured via MATLAB evalc — both disp() and fprintf() output appear in the output field.
  • MATLAB \n in fprintf format strings must be double-escaped in JSON: \\n (so MATLAB receives \n).
  • Use timeout to guard long-running code (default: 30s).

Access simulation results

After simulate runs, the SimulationOutput object is stored in the base workspace as sl_sim_result. Use matlab_eval to query it:

{"action": "matlab_eval", "code": "signals = sl_sim_result.logsout.getElementNames; for i=1:numel(signals), fprintf('%s\\n', signals{i}); end"}

For detailed waveform analysis, dispatch the sim-analyst agent (see Responsibility & Handoff).

Read block port connections

To understand how a block is wired:

  1. connections with the block as target — returns upstream/downstream signal edges and physical neighbors.
  2. Signal edges carry "type": "signal" with numeric port indices. SPS physical connections carry "type": "physical" and appear in physical_neighbors (direction-agnostic).
  3. For port names on masked blocks, inspect --param PortNames or related mask parameters.

Known Limitations

Current CLI capability boundaries. For operations beyond these limits, use direct MATLAB Engine access or run_matlab (when available):

LimitationImpactWorkaround
No workspace accessCannot read/write base workspace variables or simulation results.evalin/assignin via matlab_eval

Output Discipline

  • Ground claims in tool JSON output — do not hallucinate parameter values.
  • Keep stdout to a single JSON payload; warnings must not leak as raw text.
  • Keep outputs compact: selected model, scan root, key findings.
  • Do not dump full recursive trees unless explicitly requested.
  • JSON mode (--json / --json-file) is first-class and mutually exclusive with flag-mode arguments.
  • Both JSON mode and flag mode produce JSON output on stdout. Flag mode is not plain-text — it returns the same JSON envelope as --json.

Related Docs

  • Response shape examples: reference.md

Keep looking

Skills are one crate of 627,801. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.