
matlab-review-code
Review MATLAB code for quality, performance, maintainability, and adherence to MathWorks coding standards. Uses checkmatlabcode and matlabcodingguidelines. Use when reviewing code, checking style, finding code smells, assessing quality, or preparing code for handoff or publication.
- Installs
- 193
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-review-code- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads matlab-review-code automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Code Review
Systematically review MATLAB code for quality, correctness, performance, and adherence to MathWorks coding conventions using static analysis and manual inspection patterns.
When to Use
- User asks to review, audit, or improve code quality
- User wants to check adherence to MathWorks coding standards
- Preparing code for handoff, publication, or open-source release
- After a significant implementation — verify before committing
- User reports "code smells" or asks for cleanup suggestions
When NOT to Use
- User wants to debug a runtime error — use
matlab-debug-codeinstead - User wants to optimize performance — use performance profiling skills
- User wants to generate tests — use
matlab-write-testsinstead
Workflow
- Run static analysis — Use
check_matlab_codeMCP tool on all target files - Load coding standards — Read the
matlab_coding_guidelinesMCP resource - Check naming — Verify functions, classes, variables, and files follow conventions
- Review function signatures — Arguments blocks, input/output counts, name-value patterns
- Assess structure — Function length, nesting depth, complexity
- Check patterns — Vectorization, preallocation, modern API usage
- Summarize — Report findings by severity: errors > warnings > suggestions
Step 1: Static Analysis
Use the check_matlab_code MCP tool on each file. Then inspect results programmatically:
info = checkcode("src/computeArea.m", "-struct");
for k = 1:numel(info)
fprintf('Line %d (col %d-%d): %s\n', ...
info(k).line, info(k).column(1), info(k).column(end), info(k).message);
end
For directory-wide analysis (R2022b+):
issues = codeIssues("src");
disp(issues.Issues);
Step 2: Load Coding Standards
Read the matlab_coding_guidelines MCP resource to get the authoritative MathWorks coding standards. Use these as the baseline for all naming, formatting, and structural checks.
Review Checklist
Naming
| Element | Convention | Example |
|---|---|---|
| Functions | lowerCamelCase, verb phrase | computeArea, loadData |
| Classes | PascalCase | SensorReader, DataProcessor |
| Variables | lowerCamelCase, descriptive | sampleRate not sr |
| Constants | UPPER_SNAKE or Constant property | MAX_ITERATIONS |
| Test files | t prefix | tComputeArea.m |
| App files | PascalCase | DashboardApp.m |
| File = function | File name matches primary function | computeArea.m → function computeArea |
Function Quality
| Check | Standard | Severity |
|---|---|---|
| Input count | Max 6 positional inputs | Warning |
| Output count | Max 4 outputs | Warning |
| Validation | arguments block present | Warning |
| Name-value args | options.Name pattern (not varargin) | Suggestion |
| Length | Flag if >50 lines | Suggestion |
| Nesting | Flag if >3 levels deep | Warning |
end keyword | All functions terminated with end | Warning |
| Help text | H1 line present for public functions | Suggestion |
Code Patterns
| Check | Modern | Legacy (flag it) |
|---|---|---|
| Multi-panel figures | tiledlayout/nexttile | subplot |
| Date/time | datetime | datenum/datestr |
| Strings | string type | char arrays for text |
| Vectorization | .*, ./, logical indexing | Loops over elements |
| Preallocation | zeros(n,1) before loop | Growing arrays in loops |
| Data containers | table/timetable | Raw matrices for named data |
| Dynamic eval | Direct function calls | eval, evalin, assignin |
High-Severity Flags
These should always be reported as errors:
- Use of
eval,assignin, orevalin— security and maintainability risk - Growing arrays inside loops without preallocation — performance
- Shadowing built-in functions —
sum = 5shadowssum() - Missing
argumentsblock in public-facing functions - Hardcoded file paths with backslashes
What checkcode Misses
check_matlab_code does NOT catch all issues. After running static analysis, always scan the source code for these common problems that require visual inspection:
subplotusage — not flagged by checkcode, but should usetiledlayout/nexttile- Shadowed builtin variables —
sum = 0shadowssum(), checkcode may not flag it - Deep nesting (>3 levels) — checkcode does not measure nesting depth
- Hardcoded backslash paths — checkcode flags unused variables but not path style
- Magic numbers — unlabeled constants in code (e.g.,
if length(x) > 10) - Missing H1 help text — checkcode does not require help text
Do not skip Steps 3-6 of the workflow just because checkcode returns few results.
Patterns
Complexity Assessment
function complexity = assessComplexity(filePath)
%assessComplexity Estimate cyclomatic complexity of a MATLAB function.
arguments
filePath (1,1) string {mustBeFile}
end
code = fileread(filePath);
branchKeywords = ["if " "elseif " "case " "while " "for " "catch "];
complexity = 1;
for kw = branchKeywords
complexity = complexity + numel(strfind(code, kw));
end
end
Check Toolbox Dependencies
[files, products] = matlab.codetools.requiredFilesAndProducts('src/myFunction.m');
fprintf('Required products:\n');
for k = 1:numel(products)
fprintf(' %s (ID: %d)\n', products(k).Name, products(k).ProductNumber);
end
Review Report Format
Present findings in this format:
## Code Review: computeArea.m
### Static Analysis (checkcode)
- 2 warnings, 0 errors
### Naming ✓
- [x] Function: lowerCamelCase
- [x] Variables: descriptive
- [x] File name matches function
### Structure
- [x] arguments block present
- [x] Function under 50 lines
- [ ] ⚠ Nesting depth reaches 4 levels (line 32)
### Patterns
- [x] Vectorized
- [x] Modern graphics API
- [ ] ⚠ Uses datenum (line 18) — migrate to datetime
### Suggestions
1. Extract nested logic at line 32 into a local function
2. Replace datenum with datetime for date handling
Conventions
- Always run
check_matlab_codeas the first step — it catches issues automatically - Load
matlab_coding_guidelinesfor the authoritative standard - Report findings by severity: errors (must fix) > warnings (should fix) > suggestions (nice to have)
- Flag any use of
eval,assignin, orevalinas high-severity - Check
requiredFilesAndProductsto verify toolbox dependencies are documented - Verify every public function has an H1 help text line
- Use
codeIssuesfor directory-wide analysis (R2022b+) - Do not suggest changes that alter behavior — review is read-only assessment
- For deprecated API migration details, use the
matlab-modernize-codeskill
Copyright 2026 The MathWorks, Inc.
FAQ
What does the matlab-review-code skill do?
Review MATLAB code for quality, performance, maintainability, and adherence to MathWorks coding standards. Uses checkmatlabcode and matlabcodingguidelines. Use when reviewing code, checking style, finding code smells, assessing quality, or preparing code for handoff or publication.
How do I install matlab-review-code?
Run npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-review-code in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/matlab-review-code/ (personal) or .claude/skills/matlab-review-code/ (project).
Which AI agents can use matlab-review-code?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is matlab-review-code safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains matlab-review-code?
It is published by matlab in matlab/matlab-agentic-toolkit. It has 193 recorded installs.
More from matlab/matlab-agentic-toolkit
matlab-analyze-data
matlab/matlab-agentic-toolkit
Analyze data using MATLAB. Use when the task involves tables, timetables, time-series data, numeric arrays, sensor matrices, or gridded data — including but not limited to exploring, row filtering, sorting, cleaning, transforming, aggregating, smoothing, padding, trimming, and answering questions about data. MATLAB provides extensive, easy-to-use built-in functions for these workflows with no additional products required.
matlab-design-digital-filter
matlab/matlab-agentic-toolkit
Design and validate digital filters in MATLAB. Use when cleaning up noisy signals, removing interference, filtering signals, designing FIR/IIR filters (lowpass/highpass/bandpass/bandstop/notch), or comparing filters in Filter Analyzer.
matlab-modernize-code
matlab/matlab-agentic-toolkit
Modernize removed or discouraged MATLAB functions and patterns. Use when the checkmatlabcode MCP tool reports that a function "is not recommended", "will be removed in a future release", or "has been removed" — at any severity (info, warning, or error) — when migrating legacy code, or when replacing removed or discouraged APIs with current equivalents. Also applies to discouraged patterns Code Analyzer does not flag (containers.Map, bsxfun, str2num, eval, clear all) and to removed or discouraged functions such as trainNetwork, csvread, xlsread, datenum, guide, svmtrain, ltln2val, webmap.
matlab-create-live-script
matlab/matlab-agentic-toolkit
Create, edit, and run plain-text MATLAB live scripts (.m files) with rich text formatting, LaTeX equations, section breaks, and inline figures. Use when generating tutorials, analysis notebooks, reports, documentation, or educational content, when modifying existing live scripts, or when converting existing binary .mlx files to .m for version control. Requires R2025a+.
matlab-agentic-toolkit-setup
matlab/matlab-agentic-toolkit
Install and configure the MATLAB Agentic Toolkit — detect MATLAB, install the MCP server, register with your AI coding agent, and verify the environment. Supports Claude Code, Codex, GitHub Copilot, Amp, and Gemini CLI.
matlab-build-app
matlab/matlab-agentic-toolkit
Build MATLAB apps from requirements to working code. Asks discovery questions (or skips them when the path is known), recommends UIFigure or UIHTML architecture, identifies layout archetype (Dashboard, Explorer, Tabbed, Wizard, Canvas), produces an implementation plan, and executes the build. For UIFigure apps, optionally serializes as App Designer (.mlapp or plain-text .m + .xml). Use when a user wants to build a MATLAB app, create a GUI, make an interactive tool, build a uifigure app, build a uihtml app, build an App Designer app, build a .mlapp app, build a plain-text App Designer app, or asks which approach to use. Also use when user describes spatial layout needs: dashboard, control panel, sidebar, tabs, wizard, stepper, canvas, workspace.
Popular code quality & workflow skills
grill-me
mattpocock/skills
A relentless interview to sharpen a plan or design.
improve-codebase-architecture
mattpocock/skills
Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
handoff
mattpocock/skills
Compact the current conversation into a handoff document for another agent to pick up.
domain-modeling
mattpocock/skills
Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.
codebase-design
mattpocock/skills
Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.
diagnosing-bugs
mattpocock/skills
Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.