$npx -y skills add matlab/matlab-agentic-toolkit --skill matlab-build-toolboxExecute the build plan — introspect buildfile.m, run its dependency chain, and produce the .mltbx toolbox package. Mechanical execution with no human checkpoint. Works with any buildplan shape.
| 1 | # matlab-build-toolbox — Build Executor |
| 2 | |
| 3 | You execute the build pipeline. You are an operator — you introspect the plan to find the right task to invoke, run it, report results at each stage, and stop on failure. This is the only skill in the pipeline with no human checkpoint. |
| 4 | |
| 5 | ## When to Use |
| 6 | |
| 7 | - After `matlab-assess-toolbox` reports READY (no blockers) |
| 8 | - User says "build it", "run the build", or "build package" |
| 9 | - User has their own `buildfile.m` and wants to execute it |
| 10 | - As part of the full pipeline after readiness gate passes |
| 11 | |
| 12 | ## When NOT to Use |
| 13 | |
| 14 | - No `buildfile.m` exists — use `matlab-create-buildfile` first |
| 15 | - User wants to create or modify build tasks — use `matlab-create-buildfile` |
| 16 | - User wants to publish/release — use `matlab-publish-toolbox` after a successful build |
| 17 | - User wants a readiness check — use `matlab-assess-toolbox` |
| 18 | |
| 19 | ## Key Functions |
| 20 | |
| 21 | | Function | Purpose | |
| 22 | |----------|---------| |
| 23 | | `matlab.buildtool.Plan.load` | Introspect the build plan to discover tasks and dependencies | |
| 24 | | `buildtool` | Execute the build pipeline (runs task dependency chain) | |
| 25 | | `dir` | Locate and verify the `.mltbx` artifact after packaging | |
| 26 | |
| 27 | ## Inputs |
| 28 | |
| 29 | - **project_root**: Path to the project (default: current directory) |
| 30 | - **target** (optional): The buildtool task to execute. If omitted, auto-detected from the plan (see Step 2). |
| 31 | |
| 32 | ## Workflow |
| 33 | |
| 34 | ### Step 1 — Verify Preconditions |
| 35 | |
| 36 | Before executing: |
| 37 | 1. Confirm `buildfile.m` exists at the project root |
| 38 | 2. Determine pipeline context: |
| 39 | - **Full pipeline** (`buildUtilities/toolboxSpecification.m` and `buildUtilities/tbxManifest.m` exist): readiness was run, proceed with full context |
| 40 | - **Standalone buildplan** (only `buildfile.m` exists): user has their own plan not generated by `matlab-create-buildfile`. Skip spec/manifest checks, proceed with introspection. |
| 41 | 3. If full pipeline context exists, confirm no blockers from last readiness check |
| 42 | |
| 43 | If `buildfile.m` does not exist, stop and direct the user to `matlab-create-buildfile` or ask them to provide one. |
| 44 | |
| 45 | ### Step 2 — Introspect the Build Plan |
| 46 | |
| 47 | Load the plan and discover its structure: |
| 48 | |
| 49 | ```matlab |
| 50 | plan = matlab.buildtool.Plan.load("buildfile.m"); |
| 51 | disp({plan.Tasks.Name}) |
| 52 | ``` |
| 53 | |
| 54 | Identify the **target task** (in priority order): |
| 55 | 1. Use the `target` input if provided |
| 56 | 2. Look for a task named `package` |
| 57 | 3. Find the terminal task — one with no downstream dependents that produces the `.mltbx` |
| 58 | 4. If ambiguous (multiple candidates), ask the user which to run |
| 59 | |
| 60 | Identify the **dependency chain** leading to the target: |
| 61 | |
| 62 | ```matlab |
| 63 | % The chain executes in topological order when you run the target |
| 64 | % e.g., buildtool package → runs check, test, package |
| 65 | ``` |
| 66 | |
| 67 | Report what will execute: |
| 68 | ``` |
| 69 | Build target: "package" |
| 70 | Dependency chain: check → test → package |
| 71 | ``` |
| 72 | |
| 73 | ### Step 3 — Execute Build Pipeline |
| 74 | |
| 75 | Run via MATLAB, stopping on first failure: |
| 76 | |
| 77 | ```matlab |
| 78 | buildtool <target> |
| 79 | ``` |
| 80 | |
| 81 | Monitor each stage dynamically based on what's in the chain: |
| 82 | |
| 83 | | Task Type | Success Condition | On Failure | |
| 84 | |-----------|-------------------|------------| |
| 85 | | `CodeIssuesTask` or "check" | 0 error-severity findings | Report findings, stop | |
| 86 | | `TestTask` or "test" | All tests pass | Report failures, stop | |
| 87 | | Coverage (if present) | Reports coverage | Log warning if below threshold (does not stop) | |
| 88 | | `MexTask` | MEX file produced | Report error, stop | |
| 89 | | `PcodeTask` | P-code files produced | Report error, stop | |
| 90 | | Packaging task | `.mltbx` file produced | Report error, stop | |
| 91 | |
| 92 | Not all chains have all stages. Report only what exists in this plan. |
| 93 | |
| 94 | ### Step 4 — Verify Artifact |
| 95 | |
| 96 | After successful packaging, locate and verify the `.mltbx`. First check the task's declared `Outputs` (authoritative), then fall back to scanning `release/` and the project root: |
| 97 | |
| 98 | ```matlab |
| 99 | mltbxFile = dir(fullfile("release", "*.mltbx")); |
| 100 | assert(~isempty(mltbxFile), "No .mltbx file found in release/"); |
| 101 | assert(mltbxFile(1).bytes > 0, "Package file is empty"); |
| 102 | fprintf("Package: %s (%.1f KB)\n", fullfile(mltbxFile(1).folder, mltbxFile(1).name), mltbxFile(1).bytes / 1024); |
| 103 | ``` |
| 104 | |
| 105 | If no `.mltbx` in `release/`, check the task's declared `Outputs` or scan the project root. A zero-byte file counts as a failure. |
| 106 | |
| 107 | ### Step 5 — Report Results |
| 108 | |
| 109 | ``` |
| 110 | ## Build Complete |
| 111 | |
| 112 | - Package: release/MyToolbox.mltbx (142.3 KB) |
| 113 | - Target: "package" |
| 114 | - Chain: check → test → package |
| 115 | - Static analysis: 0 errors, 2 warnings |
| 116 | - Tests: 25/25 passed |
| 117 | - Coverage: 85% |
| 118 | - Duration: 12.3s |
| 119 | |
| 120 | ### Next Steps |
| 121 | - Run `matlab-publish-toolbox` to version-tag and release |
| 122 | - Test installation: matlab.addons.toolbox.installToolbox("release/MyToolbox.mltbx") |
| 123 | ``` |
| 124 | |
| 125 | Adapt the report to what actually ran — omit sections for stages not in this plan (e.g., if no |