Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Creates a MATLAB project for an existing folder of MATLAB files using the matlab.project.* APIs via MCP. Adds all existing files, configures the project path, generates a project name/description, and creates a README.md with a function table. Prompts the user before creating any new folders. Never overwrites existing files. Use when asked: "create a project", "set up a MATLAB project", "initialize project", "make this a MATLAB project", "configure project".
.claude/skills/matlab-matlab-create-project/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-09 | ✗→✓ | ▲ Improved | 64% | 0% |
| case-11 | ✗→✓ | ▲ Improved | 30% | 0% |
| case-12 | ✗→✓ | ▲ Improved | 83% | 0% |
| case-13 | ✗→✓ | ▲ Improved | 10% | 0% |
| case-14 | ✗→✓ | ▲ Improved | 19% | 0% |
Creates a fully configured MATLAB project from an existing folder of MATLAB code using matlab.project.* APIs via the MATLAB MCP server.
matlab-create-buildfile — a project must exist first.prj file with resources/project/ folder) — use openProject insteadmatlab-define-toolbox-apimatlab-create-buildfile (after the project exists)| Function | Purpose | |----------|---------| | matlab.project.createProject | Create a new project with specified definition type | | openProject | Open an existing project (fallback if one already exists) | | addFile | Add files to the project | | addPath | Add folders to the project path | | genpath | Generate path string for folder tree (excludes +pkg, @class, private) |
mkdir.| Input | Required | Description | |-------|----------|-------------| | Project path | Yes | Absolute path to the folder to make into a project | | Project name | No | Override auto-detected name (default: inferred from code) |
.prj file exists, ask the user — it could be a MATLAB project or a legacy deploytool file:> A) This is a MATLAB project — open it with openProject instead of creating a new one > B) This is a legacy deploytool file — proceed with creating a new MATLAB project
Contents.m if present — it provides authoritative function descriptions and categorizationContents.m, read the H1 line (first % comment) of each .m file to understand purpose.m (functions/scripts), data (.mat, .dat, .csv), text (.txt), images (.png, .jpg), otherBased on the code analysis:
Contents.m title line, folder name, or dominant theme of functionsUse MATLAB MCP (mcp__matlab__evaluate_matlab_code) to execute:
matlabproj = matlab.project.createProject("Folder", '<projectFolder>', ... "Name", "<inferred name>", ... "DefinitionType", "FixedPathMultiFile"); proj.Description = "<generated description>";
Why FixedPathMultiFile: Produces a .prj + resources/project/ structure that is SCM-friendly (isolated XML files, no merge conflicts). This is the target format for toolbox projects.
Add every file in the project folder to the project. Process by extension category:
matlab% Add .m files mFiles = dir(fullfile(proj.RootFolder, '*.m')); for i = 1:numel(mFiles) addFile(proj, fullfile(mFiles(i).folder, mFiles(i).name)); end % Repeat for data/text/image/other file extensions found % Also recursively add files from any existing subfolders
Important: Use dir(..., '**', '*.<ext>') for recursive discovery in subfolders.
Add folders to the project path based on layout:
matlab% Determine path root based on project layout if isfolder(fullfile(proj.RootFolder, "toolbox")) % toolbox/ layout — only toolbox content goes on path % (project root, tests/, buildUtilities/ stay OFF the path) pathRoot = fullfile(proj.RootFolder, "toolbox"); else % Flat layout — all subfolders go on path pathRoot = proj.RootFolder; end allFolders = strsplit(genpath(pathRoot), pathsep); for i = 1:numel(allFolders) if ~isempty(allFolders{i}) && ~contains(allFolders{i}, filesep + "internal") addPath(proj, allFolders{i}); end end
Why this logic: genpath already excludes +pkg/, @class/, private/, and dot-folders — but NOT internal/ folders. The internal/ folder uses MATLAB's scoping convention: functions inside are only visible from the parent folder, never from the global path. The filter above ensures internal/ is never added via addPath. When toolbox/ exists, only its contents should be on the MATLAB path — this matches what end users get when the toolbox is installed. If toolbox/ doesn't exist yet (flat layout), adding root and subfolders is correct since the user's code lives at root.
If the user later adopts toolbox/ (via Step 7), the path should be reconfigured — suggest re-running this skill or manually adjusting path entries.
Only if README.md does not already exist at the project root.
Generate a README.md containing:
| function_name | one-line description |license.txt or copyright info existsAdd the README.md to the project after creation:
matlabaddFile(proj, fullfile(proj.RootFolder, 'README.md'));
Based on mathworks/toolboxdesign conventions, present the user with a table of recommended folders:
| Folder | Purpose | |--------|---------| | tests/ | Unit tests using the MATLAB Testing Framework | | examples/ | Live Script examples and tutorials | | doc/ | Documentation (e.g., GettingStarted.m) | | toolbox/ | Distributable content separated from dev infrastructure |
ASK the user which (if any) they want created. Do not create them without confirmation. Present as lettered options: > A) All — create all recommended folders > B) Select — pick specific folders (e.g., "tests and examples") > C) Skip — don't create any new folders
When confirmed, create the folders and add them to the project path:
matlabmkdir(fullfile(proj.RootFolder, '<folderName>')); addPath(proj, fullfile(proj.RootFolder, '<folderName>'));
Run a summary check:
matlabproj = currentProject; disp("Name: " + proj.Name); disp("Files: " + numel(proj.Files)); disp("Path entries: " + numel(proj.ProjectPath));
Report the final state to the user.
matlab.project.createProject fails because a project already exists, use openProject instead and inform the useraddFile fails for a specific file (e.g., it's already tracked), catch and continueaddPath fails for a folder, catch the error and report which folder was skippedProvide the user with:
.prj file for opening in MATLAB/matlab-document-toolbox — generate README, function signatures, GettingStarted guide, and examples/matlab-create-buildfile — define the build plan with code checks, tests, and packaging tasksCopyright 2026 The MathWorks, Inc.
Other measured skills in the registry, with their headline benchmark lift.