AGENT SKILL

matlab-create-project

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".

License 许可
BSD-2-Clause
最近更新
2026-11-14
Stars
★ 12
Forks
5

01 前言 Front Matter

name
matlab-create-project
license
MathWorks BSD-3-Clause
metadata
{ "author": "MathWorks", "version": "1.0" }
description
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".

02 资源文件 2

03 SKILL.md 正文

MATLAB Project Creation

Creates a fully configured MATLAB project from an existing folder of MATLAB code using matlab.project.* APIs via the MATLAB MCP server.

When to Use

  • User says "create a project", "set up a MATLAB project", or "initialize project"
  • User has a folder of MATLAB files that needs project infrastructure
  • Before matlab-create-buildfile — a project must exist first

When NOT to Use

  • A MATLAB project already exists (.prj file with resources/project/ folder) — use openProject instead
  • User wants to create a toolbox spec — use matlab-define-toolbox-api
  • User wants build automation — use matlab-create-buildfile (after the project exists)

Key Functions

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)

Critical Rules

  1. NEVER overwrite existing files. Before creating any file (README.md, etc.), check if it already exists. If it does, skip or ask the user.
  2. ALWAYS prompt the user before creating new folders. Present recommended folders in a table with their purpose and wait for confirmation before mkdir.
  3. Do NOT move or rename any existing files.

Inputs

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)

Workflow

1. Discover Existing Content

  • List all files in the project folder (recursively)
  • If a .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

  • Read Contents.m if present — it provides authoritative function descriptions and categorization
  • If no Contents.m, read the H1 line (first % comment) of each .m file to understand purpose
  • Identify file types: .m (functions/scripts), data (.mat, .dat, .csv), text (.txt), images (.png, .jpg), other
  • Identify any existing subfolders

2. Determine Project Identity

Based on the code analysis:

  • Name: Derive from Contents.m title line, folder name, or dominant theme of functions
  • Description: 1–3 sentence summary covering the scope, domain, and purpose of the code

3. Create the MATLAB Project

Use MATLAB MCP (mcp__matlab__evaluate_matlab_code) to execute:

proj = 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.

4. Add All Existing Files

Add every file in the project folder to the project. Process by extension category:

% 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.

5. Configure Project Path

Add folders to the project path based on layout:

% 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.

6. Create README.md

Only if README.md does not already exist at the project root.

Generate a README.md containing:

  • Project title (H1)
  • Description paragraph
  • Project organization overview
  • Function table grouped by category (GUI demos, algorithm implementations, utilities, data files, etc.)
    • Each row: | function_name | one-line description |
  • Getting Started section (how to open/use the project)
  • License/copyright note if license.txt or copyright info exists

Add the README.md to the project after creation:

addFile(proj, fullfile(proj.RootFolder, 'README.md'));

7. Suggest Best-Practice Folders

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:

mkdir(fullfile(proj.RootFolder, '<folderName>'));
addPath(proj, fullfile(proj.RootFolder, '<folderName>'));

8. Final Verification

Run a summary check:

proj = currentProject;
disp("Name: " + proj.Name);
disp("Files: " + numel(proj.Files));
disp("Path entries: " + numel(proj.ProjectPath));

Report the final state to the user.

Error Handling

  • If matlab.project.createProject fails because a project already exists, use openProject instead and inform the user
  • If addFile fails for a specific file (e.g., it's already tracked), catch and continue
  • If addPath fails for a folder, catch the error and report which folder was skipped

Output

Provide the user with:

  1. Confirmation that the project was created
  2. Project name, description, file count, and path entries
  3. Location of the .prj file for opening in MATLAB
  4. The recommended-folders prompt (Step 7)

Next Steps

  • /matlab-document-toolbox — generate README, function signatures, GettingStarted guide, and examples
  • /matlab-create-buildfile — define the build plan with code checks, tests, and packaging tasks

Copyright 2026 The MathWorks, Inc.


04 同仓库更多 Skills

stanfish06
stanfish06/skillquarium

zarr-python

Stores and queries chunked N-D scientific arrays with Zarr-Python 3, including codecs, sharding, S3/GCS storage, and NumPy/Dask/Xarray integration. Use for array layout, bounded I/O, format migration, or scientific metadata preservation.

★ 12
stanfish06
stanfish06/skillquarium

yeet

Publish local changes to GitHub by confirming scope, committing intentionally, pushing the branch, and opening a draft PR through the GitHub app from this plugin, with `gh` used only as a fallback where connector coverage is insufficient.

★ 12
stanfish06
stanfish06/skillquarium

xarray

N-dimensional labeled arrays and datasets in Python. Built on top of NumPy and Dask. It introduces labels in the form of dimensions, coordinates, and attributes on top of raw NumPy-like arrays, making data analysis in physical sciences more intuitive and less error-prone. Use for working with multi-dimensional scientific data, NetCDF/GRIB/Zarr files, climate/weather/oceanographic datasets, remote sensing, geospatial imaging, large out-of-memory datasets with Dask, and labeled array operations.

★ 12
stanfish06
stanfish06/skillquarium

writing-mstest-tests

Use when asked to fix, rewrite, update, improve, modernize, show corrected code for, or explain existing MSTest tests or MSTest-specific configuration. Use for "review" when corrected code or edits are wanted, even for one pasted assertion or passing tests with bad failure output. Covers expected/actual labels; generic Boolean, collection, string, numeric, null, identity, exception, hard-cast, and object[] checks; TestContext/lifecycle; timeout/cancellation; OS/CI conditions, retry, cleanup, parallelization, MSTest.Sdk project setup, and MSTESTxxxx. Honor the installed MSTest version. DO NOT USE to design new test cases (code-testing), perform report-only audits, create project files rather than explain MSTest setup, run tests, migrate frameworks, or handle non-MSTest/non-.NET code.

★ 12
stanfish06
stanfish06/skillquarium

wgs-prs

End-to-end WGS to polygenic risk score pipeline. Takes paired-end FASTQ files (or a pre-existing VCF) through nf-core/sarek for variant calling, applies VCF QC (normalisation, hard filtering, Ti/Tv and Het/Hom checks), then computes polygenic risk scores via the PGS Catalog. Fills the FASTQ to VCF gap upstream of the gwas-prs skill.

★ 12
stanfish06
stanfish06/skillquarium

webapp-testing

Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

★ 12