matlab-modernize-code — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited matlab-modernize-code (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Replace removed or discouraged MATLAB functions and anti-patterns with modern equivalents. This skill is the resolver — the MCP tool check_matlab_code (MATLAB's Code Analyzer) is the detector.
Terms used in this skill:
check_matlab_code reports a lifecycle diagnostic — any of these threewordings, matched case-insensitively (STRMATCH is not recommended is the same signal as the lowercase form):
'X' is not recommended... (severity: info)'X' will be removed in a future release... (severity: warning)'X' has been removed... (severity: error — the code errors today)containers.Map, bsxfun, str2num, eval, clear all — scan the source, not just the diagnostics (see Conventions)This skill swaps removed or discouraged APIs for modern equivalents. It does not:
matlab-optimize-performancearguments blocks, inputParser/validateattributes → mustBe* validators, repeating args, name-value forwarding) → hand off to matlab-validate-function-arguments| Topic | Recommendation | Since | Category | Rationale |
|---|---|---|---|---|
csvread / dlmread | readmatrix | R2019a | File I/O | |
csvwrite / dlmwrite | writematrix | R2019a | File I/O | |
xlsread | readtable, readmatrix | R2019a | File I/O | |
xlswrite | writetable, writematrix | R2019a | File I/O | |
datenum / datestr / now | datetime (use string/char to format) | R2022b | Date/Time (Not recommended) | Flagged by Code Analyzer |
eval / evalc / evalin | Dynamic field names s.(name), function handles / feval, cells for sequential names | — | Anti-pattern | Not compiled (slow); can overwrite workspace vars; hard to debug; injection risk |
str2num | str2num(text, Evaluation="restricted") | R2022a | Security | Unrestricted form runs input via eval (injection risk); see references |
uicontrol | uibutton, uidropdown, etc. | R2016a | UI/App | |
guide | appdesigner | R2025a | UI (Removed) | |
strmatch | startsWith, matches | R2019b | Strings | |
clear all | clearvars | — | Workspace | Clears functions from memory; forces recompilation |
`datestr` nuance:datestr's job was to format a date as text, so its modern replacement isstring(dt)/char(dt)or settingdt.Format— not a baredatetime(...)call. Usedatetimeto replacedatenum/now(the numeric/serial-date path). Neither is removed; both are Code Analyzer "not recommended" as of R2022b.
>
``matlab s = datestr(t, 'yyyy-mm-dd HH:MM:SS'); % old s = string(t, 'yyyy-MM-dd HH:mm:ss'); % new — note the specifiers change: % datetime uses MM=month, mm=minute (datestr had mm=month, MM=minute) ``Prefer these in all new code:
data = readtable('sensors.csv');
data.Timestamp = datetime(data.Timestamp);
data.Status = categorical(data.Status);
recentData = data(data.Timestamp > datetime('today') - days(7), :);
summary = groupsummary(recentData, 'SensorID', 'mean', 'Value');name = "John"; % not 'John'
names = ["John", "Jane", "Bob"]; % not {'John','Jane','Bob'}
fullName = firstName + " " + lastName; % not [first,' ',last]
idx = contains(names, "Jo"); % not cellfun + strfindfunction result = processData(data, options)
arguments
data (:,:) double
options.Method (1,1) string {mustBeMember(options.Method, ["fast","accurate"])} = "fast"
options.Verbose (1,1) logical = false
end
end% Old → Modern
M = csvread('data.csv'); % M = readmatrix("data.csv");
M = dlmread('data.txt','\t'); % M = readmatrix("data.txt", Delimiter="\t");
[n,t,r] = xlsread('f.xlsx'); % T = readtable("f.xlsx");
csvwrite('out.csv', M); % writematrix(M, "out.csv");
xlswrite('out.xlsx', data); % writetable(T, "out.xlsx");Avoid eval/evalc/evalin: the text isn't compiled (slower), can silently overwrite workspace variables, and is hard to read/debug. Match the intent to a construct — see references/core-functions-guidance.md for the full set (sequential names, sprintf filenames, try/catch).
% Old: eval([varName ' = 42;']); -> dynamic field name
s.(varName) = 42;
% Old: result = eval(['process_' method '(x)']); -> handle dispatch table
handlers.fast = @processFast;
handlers.slow = @processSlow;
result = handlers.(method)(x);
% Old: for n=1:10, eval(['A' int2str(n) '=magic(n);']); end -> index a cell
A = cell(10,1);
for n = 1:10, A{n} = magic(n); endLoad these when working in a specific domain:
| Load when... | Reference |
|---|---|
Core MATLAB functions (file I/O, strings, UI); security anti-patterns (eval/str2num), containers.Map→dictionary, bsxfun→implicit expansion | references/core-functions-guidance.md |
| Deep Learning (trainNetwork→trainnet, LayerGraph/SeriesNetwork/DAGNetwork→dlnetwork, classify, activations) | references/deep-learning-guidance.md |
| Signal processing functions | references/signal-processing-guidance.md |
| Audio/video I/O migration (wavread, aviread) | references/audio-video-guidance.md |
| Optimization toolbox (optimset, optimtool) | references/optimization-guidance.md |
| Control systems plot options | references/control-systems-guidance.md |
| Image processing ROI objects | references/image-processing-guidance.md |
| Statistics/ML (svmtrain, dataset, classregtree) | references/statistics-ml-guidance.md |
| Communications System objects | references/communications-guidance.md |
| Mapping Toolbox (webmap, wmmarker, wmline, geotiffread, mfwdtran, makerefmat) | references/mapping-guidance.md |
check_matlab_code first — let static analysis find removed or discouraged usagestr2num (framed only as a perf tip); containers.Map (see next point).containers.Map usage, and that handle-sharing warning on a property, as a containers.Map→dictionary trigger.subplot code.'X' has been removed diagnostic (severity error) means the function errors today — treat it as a break-fix modernization, ahead of "not recommended" (info) and "will be removed" (warning) cases°, µ, ±) survived — a diff showing an unrelated one-line change on a comment or string is usually a re-encoded byte, not your edit.----
Copyright 2026 The MathWorks, Inc.
----
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.