Skip to main content
ClaudeWave
Skill618 repo starsupdated 8d ago

matlab-create-project

The matlab-create-project skill generates a new MATLAB project structure from an existing folder of MATLAB code using the MATLAB MCP server's project APIs. Use this skill when a user requests project creation or initialization for unorganized MATLAB files, before setting up build automation or defining toolbox specifications. The skill discovers existing code, avoids overwriting files, prompts for folder confirmation, and configures project paths and file organization.

Install in Claude Code
Copy
git clone --depth 1 https://github.com/matlab/matlab-agentic-toolkit /tmp/matlab-create-project && cp -r /tmp/matlab-create-project/skills-catalog/matlab-software-development/matlab-create-project ~/.claude/skills/matlab-create-project
Then start a new Claude Code session; the skill loads automatically.

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:

```matlab
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:

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

### 5. Configure Project Path

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.

### 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:
```matlab
addFile(proj, fullfile(proj.RootFolder, 'README.md'));
```

### 7. Suggest Best-Practice Folders

Based on [mathworks/toolboxdesign](https://github.com/mathworks/toolboxdesign) conventions, present the user with a table of recommended folders:

| Folder | Purpose |
|--------|---------|
| `tests/` | Unit tests using the MATLAB Testing Framewo
matlab-train-networkSkill

>

matlab-driving-data-importerSkill

Import recorded driving sensor data (GPS, camera, lidar, actor tracks, lanes) into scenariobuilder.* objects (GPSData, CameraData, LidarData, ActorTrackData, Trajectory, laneData) and run preprocessing — synchronize, offset correction, crop, normalizeTimestamps, convertTimestamps. Also: compute actor tracks from lidar when no annotations exist, attach camera/lidar mounting + intrinsics, export to MAT/workspace/timetable/script. Use for raw driving dataset files (KITTI, nuScenes, Waymo, Pandaset, ROS/ROS2 bags, .mat, .csv, .mp4) or driving/vehicle/sensor logs that need wrapping. drivingLogAnalyzer (DLA) is OPT-IN ONLY — invoke only on explicit user request ('DLA', 'open in DLA', 'inspect/explore/analyze the recording') or reported sensor problem (sync drift, timestamp mismatch, overlay misalignment). NEVER auto-launch DLA after wrapping (Rule 0). For 'build scenario / export to RoadRunner / drivingScenario / OpenSCENARIO / Unreal / simulate', hand off to matlab-scenario-builder.

matlab-scenario-builderSkill

Generate driving scenes, scenarios, road surfaces, and 3D content from already-wrapped scenariobuilder.* sensor data (GPS, camera, lidar, actor tracks) using Scenario Builder for Automated Driving Toolbox. Use to BUILD, EXPORT, or AUGMENT a virtual scenario/scene/map: ego or actor trajectories, trajectory smoothing, OpenCRG road-surface extraction, 3D asset generation, static-object placement, point-cloud georeferencing + elevation, lane-based ego localization, sensor-fusion tracking, scenario-event extraction (cut-ins, hard brakes, near-misses, ADAS disengagements), or export to RoadRunner, drivingScenario, OpenDRIVE, OpenCRG, OpenSCENARIO, or Unreal Engine. Also: log-to-scenario, scenario harvesting, accident/near-miss reconstruction, SOTIF (ISO 21448) and ISO 26262 scenario coverage, USGS-aerial-lidar scene augmentation, traffic-sign placement from camera+lidar logs. NOT for raw-data import or multi-sensor sync/crop/offset/timestamp normalization — route those to matlab-driving-data-importer.

roadrunner-asset-mappingSkill

>

roadrunner-convert-lanelet2-to-rrhdSkill

>

roadrunner-import-sceneSkill

>

roadrunner-rrhd-authoringSkill

>

matlab-build-simbiology-modelSkill

Build, modify, and diagram SimBiology models — API reference, helper functions, and layout patterns. Use when constructing or editing models programmatically or visually.