MATLAB Slash Commands

March 25, 2026 ยท View on GitHub

Slash commands for MATLAB development workflows across multiple AI coding agents. Provides documentation generation, testing, optimization, code analysis, and live execution via MCP.

Multi-Agent Support

AgentFormatCommandsInstall
Claude CodePluginAll 13/plugin install github:matlab/slash-commands
GitHub Copilot.prompt.md6 key commandsCopy copilot/prompts/ to .github/prompts/
Cursor IDE.mdc rulesRules (always-on)Copy cursor/rules/ to .cursor/rules/
Any MCP agentMCP serverVia MATLAB MCP Core ServerSee MCP Guide

MCP Integration

When the MATLAB MCP Core Server is connected, commands gain live capabilities:

MCP ToolWhat It Enables
check_matlab_codeReal Code Analyzer diagnostics
evaluate_matlab_codeExecute MATLAB expressions, benchmark code
run_matlab_fileRun .m files and return output
run_matlab_test_fileExecute test suites and report results
detect_matlab_toolboxesList installed toolboxes

All commands work without MCP. They generate code and instructions as before. MCP adds validation, execution, and measurement. See MCP Integration Guide.

Installation

Claude Code (Full Support)

/plugin install github:matlab/slash-commands

GitHub Copilot

cp -r copilot/prompts/ .github/prompts/

Cursor IDE

mkdir -p .cursor/rules
cp cursor/rules/matlab-development.mdc .cursor/rules/

Manual / Development

git clone https://github.com/matlab/slash-commands.git

Available Commands

Core Commands

CommandDescriptionMCP Enhanced
/matlab-readmeGenerate project READMEYes
/matlab-docsDocument MATLAB functionsYes
/matlab-livescriptCreate formatted Live ScriptsYes
/matlab-checkRun Code Analyzer on codeMCP
/matlab-runExecute MATLAB code or filesMCP

Testing Commands

CommandDescriptionMCP Enhanced
/matlab-testGenerate unit testsYes
/matlab-property-testCreate property-based testsYes
/matlab-run-testsRun test suite and report resultsMCP

Quality Commands

CommandDescriptionMCP Enhanced
/matlab-optimizeOptimize code performanceYes
/matlab-errorsAdd error handling and validationYes

Development Commands

CommandDescriptionMCP Enhanced
/matlab-explainExplain code functionalityYes
/matlab-refineRefine requirements into specsYes
/matlab-toolboxesDetect installed toolboxesMCP

MCP Enhanced = works without MCP but gains live capabilities with it MCP = primarily designed for MCP, with static fallback

Quick Start

Generate and Validate Tests (with MCP)

/matlab-test myFunction        # Generate tests
/matlab-run-tests              # Run them via MCP, see pass/fail

Optimize with Real Benchmarks (with MCP)

/matlab-optimize               # Optimizes and benchmarks before/after

Full Development Pipeline

/matlab-refine "process sensor data"    # Clarify requirements
/matlab-test processData                # Generate tests
/matlab-check processData.m            # Run Code Analyzer
/matlab-optimize                        # Optimize performance
/matlab-errors                          # Add error handling
/matlab-docs processData               # Generate documentation
/matlab-readme                          # Generate project README

Documentation

Requirements

  • An AI coding agent (Claude Code, GitHub Copilot, Cursor, or any MCP-compatible agent)
  • MATLAB development environment (for running generated code)
  • Optional: MATLAB MCP Core Server for live execution

Contributing

See CONTRIBUTING.md for guidelines on adding commands, improving existing ones, and maintaining cross-agent formats.

License

BSD 3-Clause License. See LICENSE.

Copyright (c) 2025, The MathWorks, Inc.