MATLAB Runner
Use this skill to execute MATLAB work safely and repeatably through the official MATLAB MCP server, preferably in auto mode, and only use terminal batch workflows when the user explicitly asks for them. It is the foundation skill for all other MATLAB skills.
Execution Rules
- Prefer the official MATLAB MCP auto mode for MATLAB work on this machine.
- Do not silently fall back to
matlab -batch when MCP is expected.
- Capture logs, version info, working directory, and artifact paths where applicable.
- Run from a project root, not from a random temporary folder, unless isolation is required.
- Put generated files under
artifacts/ or a user-specified output folder.
- Keep scripts deterministic: seed random generators and record data sources.
MCP Required By Default
When using this repository on this machine, use this decision rule:
- Prefer official MATLAB MCP auto mode, so the server can reuse an existing shared session or start MATLAB automatically.
- If the task requires repeated model edits, parameter sweeps with live inspection, or user-visible desktop interaction, stay on MCP.
- Batch mode is reserved for explicit user requests such as CI, headless smoke tests, or reproducible one-shot runs.
- If MCP is unavailable, report the blocker instead of silently changing execution mode.
Preferred Wrapper
If the user explicitly requests batch execution in this repository, prefer:
powershell -ExecutionPolicy Bypass -File .\scripts\Invoke-MatlabBatch.ps1 -Script .\path\to\script.m
For official MCP auto-mode setup and validation in this repository, prefer:
powershell -ExecutionPolicy Bypass -File .\scripts\Setup-MatlabMcpExistingSession.ps1
powershell -ExecutionPolicy Bypass -File .\scripts\Test-MatlabMcpExistingSession.ps1
For a full local smoke test:
powershell -ExecutionPolicy Bypass -File .\scripts\Test-MatlabSkills.ps1
If the wrapper is not available, call MATLAB directly:
matlab -batch "disp(version); v=ver; disp({v.Name}')"
MATLAB Discovery
Use this order to find MATLAB:
- Official MATLAB MCP auto configuration
- Existing official MATLAB shared session metadata when present
$env:MATLAB_EXE, Get-Command matlab, and known install paths only for setup/verification of the MCP environment
Verify before running expensive work:
disp(version)
v = ver;
{v.Name}'
Error Handling
When MATLAB fails:
- Read the first error and the deepest stack frame.
- Check missing toolbox with
license('test', product) and ver.
- Check path ambiguity with
which functionName -all.
- Re-run a minimal reproduction before editing large code.
- Save the failing command and log path.
- If the failure was on MCP, report the exact MCP blocker and stop hiding it behind a batch rerun.
Acceptance Checks
Choose at least one:
- Unit test passes with
runtests and assertSuccess.
- Numerical tolerance check passes.
- Simulink model simulates to stop time and logged signals are nonempty.
- Figure, data file, report, or generated code exists and has nonzero size.
- Static checks such as
checkcode return no critical issues for touched files.
Paper Reproduction Mode
For open-source paper projects:
- Record paper URL, commit hash, dataset URL, MATLAB release, toolbox list.
- Run the smallest official example first.
- Reproduce one figure or table before scaling to the whole paper.
- Save
manifest.json, raw logs, processed data, and generated figures.
- Mark differences from the paper explicitly instead of smoothing them over.
1---2name: matlab-runner3description: Run MATLAB R2026a tasks from Codex with reliable MCP-based execution, logs, artifacts, toolbox inventory, smoke tests, and reproducible validation. Use whenever MATLAB code, .m/.mlx scripts, MATLAB tests, local toolbox probing, or command-line automation is needed.4---56# MATLAB Runner78Use this skill to execute MATLAB work safely and repeatably through the official MATLAB MCP server, preferably in `auto` mode, and only use terminal batch workflows when the user explicitly asks for them. It is the foundation skill for all other MATLAB skills.910## Execution Rules11121. Prefer the official MATLAB MCP auto mode for MATLAB work on this machine.132. Do not silently fall back to `matlab -batch` when MCP is expected.143. Capture logs, version info, working directory, and artifact paths where applicable.154. Run from a project root, not from a random temporary folder, unless isolation is required.165. Put generated files under `artifacts/` or a user-specified output folder.176. Keep scripts deterministic: seed random generators and record data sources.1819## MCP Required By Default2021When using this repository on this machine, use this decision rule:22231. Prefer official MATLAB MCP auto mode, so the server can reuse an existing shared session or start MATLAB automatically.242. If the task requires repeated model edits, parameter sweeps with live inspection, or user-visible desktop interaction, stay on MCP.253. Batch mode is reserved for explicit user requests such as CI, headless smoke tests, or reproducible one-shot runs.264. If MCP is unavailable, report the blocker instead of silently changing execution mode.2728## Preferred Wrapper2930If the user explicitly requests batch execution in this repository, prefer:3132```powershell33powershell -ExecutionPolicy Bypass -File .\scripts\Invoke-MatlabBatch.ps1 -Script .\path\to\script.m34```3536For official MCP auto-mode setup and validation in this repository, prefer:3738```powershell39powershell -ExecutionPolicy Bypass -File .\scripts\Setup-MatlabMcpExistingSession.ps140powershell -ExecutionPolicy Bypass -File .\scripts\Test-MatlabMcpExistingSession.ps141```4243For a full local smoke test:4445```powershell46powershell -ExecutionPolicy Bypass -File .\scripts\Test-MatlabSkills.ps147```4849If the wrapper is not available, call MATLAB directly:5051```powershell52matlab -batch "disp(version); v=ver; disp({v.Name}')"53```5455## MATLAB Discovery5657Use this order to find MATLAB:58591. Official MATLAB MCP auto configuration602. Existing official MATLAB shared session metadata when present613. `$env:MATLAB_EXE`, `Get-Command matlab`, and known install paths only for setup/verification of the MCP environment6263Verify before running expensive work:6465```matlab66disp(version)67v = ver;68{v.Name}'69```7071## Error Handling7273When MATLAB fails:7475- Read the first error and the deepest stack frame.76- Check missing toolbox with `license('test', product)` and `ver`.77- Check path ambiguity with `which functionName -all`.78- Re-run a minimal reproduction before editing large code.79- Save the failing command and log path.80- If the failure was on MCP, report the exact MCP blocker and stop hiding it behind a batch rerun.8182## Acceptance Checks8384Choose at least one:8586- Unit test passes with `runtests` and `assertSuccess`.87- Numerical tolerance check passes.88- Simulink model simulates to stop time and logged signals are nonempty.89- Figure, data file, report, or generated code exists and has nonzero size.90- Static checks such as `checkcode` return no critical issues for touched files.9192## Paper Reproduction Mode9394For open-source paper projects:95961. Record paper URL, commit hash, dataset URL, MATLAB release, toolbox list.972. Run the smallest official example first.983. Reproduce one figure or table before scaling to the whole paper.994. Save `manifest.json`, raw logs, processed data, and generated figures.1005. Mark differences from the paper explicitly instead of smoothing them over.