Matlab Review Code
MathWorksOfficialCreated by MathWorks
- Skill
- Review and audit
- Software development
- BSD-2-Clause
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured approach to auditing MATLAB code. It combines automated static analysis using built-in tools with a manual inspection checklist to ensure code meets professional standards for maintainability, readability, and modern API usage. It is designed to help developers prepare code for publication, handoff, or general quality assurance by identifying code smells, structural issues, and legacy patterns.
What it does
- Performs static analysis on MATLAB files to identify potential errors and warnings.
- Validates naming conventions for functions, classes, and variables.
- Assesses function structure, including nesting depth and complexity.
- Checks for the use of modern MATLAB APIs and recommended coding patterns.
- Identifies high-risk practices such as dynamic evaluation or missing input validation.
- Generates a structured review report categorizing findings by severity.
When to use it
- When you need to audit MATLAB code for quality and maintainability.
- Before handing off code to a team or preparing it for public release.
- When you want to ensure your code follows official MathWorks conventions.
- When you suspect code smells or inefficient patterns in your implementation.
Advantages
- Ensures consistency across MATLAB projects by enforcing standard naming and structure.
- Reduces technical debt by flagging legacy patterns and deprecated functions.
- Provides a clear, actionable report for code improvement.
- Helps identify hidden dependencies and potential runtime risks.
Usage examples
- “Review my file src/dataProcessor.m for quality and adherence to standards.”
- The agent runs static analysis, checks naming conventions, verifies the presence of arguments blocks, and provides a report highlighting any structural issues or legacy code patterns.
- “Audit the entire src directory for code smells and modern API usage.”
- The agent performs a directory-wide analysis, flags instances of legacy functions like datenum or subplot, and suggests modern alternatives like datetime and tiledlayout.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/matlab/matlab-review-code/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip matlab-review-code.zip -d .agents/skills
Documentation by MathWorks
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-codeinsteadUser 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 filesLoad coding standards — Read the
matlab_coding_guidelinesMCP resourceCheck 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);
endFor 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 riskGrowing arrays inside loops without preallocation — performance
Shadowing built-in functions —
sum = 5shadowssum()Missing
argumentsblock in public-facing functionsHardcoded 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/nexttileShadowed builtin variables —
sum = 0shadowssum(), checkcode may not flag itDeep 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
endCheck 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);
endReview 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 handlingConventions
Always run
check_matlab_codeas the first step — it catches issues automaticallyLoad
matlab_coding_guidelinesfor the authoritative standardReport findings by severity: errors (must fix) > warnings (should fix) > suggestions (nice to have)
Flag any use of
eval,assignin, orevalinas high-severityCheck
requiredFilesAndProductsto verify toolbox dependencies are documentedVerify 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.
Files
- ATTRIBUTION.mdAdded by AutoGineer1.0 KiB
- LICENSELicence file added by AutoGineer1.4 KiB
- SKILL.md7.2 KiB
- manifest.yaml518 B
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- MathWorks
- Publisher
- MathWorks (Official)
- Source
- matlab/matlab-agentic-toolkit · skills-catalog/matlab-core/matlab-review-code · commit 2a7f215
- Licence
- BSD 2-Clause License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE.md)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by MathWorks.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download matlab-review-code.zip