Generated banner for Matlab Build App
Generated logo for Matlab Build App

Matlab Build App

MathWorksOfficialCreated by MathWorks

  • Skill
  • Workflow
  • Software development
  • BSD-2-Clause
  • No issues found

From the author

Build MATLAB apps from requirements to working code. Asks discovery questions (or skips them when the path is known), recommends UIFigure or UIHTML architecture, identifies layout archetype (Dashboard, Explorer, Tabbed, Wizard, Canvas), produces an implementation plan, and executes the build. For UIFigure apps, optionally serializes as App Designer (.mlapp or plain-text .m + .xml). Use when a user wants to build a MATLAB app, create a GUI, make an interactive tool, build a uifigure app, build a uihtml app, build an App Designer app, build a .mlapp app, build a plain-text App Designer app, or asks which approach to use. Also use when user describes spatial layout needs: dashboard, control panel, sidebar, tabs, wizard, stepper, canvas, workspace.
— the description by MathWorks

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides a structured approach to developing MATLAB applications, guiding users from initial requirements to a fully implemented codebase. It helps determine the optimal architecture (UIFigure or UIHTML) and layout archetype (e.g., Dashboard, Explorer, Wizard) based on the user's specific needs, team expertise, and maintenance requirements. The skill enforces a rigorous planning phase, requiring an implementation plan before any code is written, and supports multiple serialization formats for UIFigure apps, including App Designer (.mlapp) and plain-text (.m + .xml) formats.

What it does

  • Conducts discovery to identify app purpose, maintenance needs, and visual requirements.
  • Recommends the best architecture (UIFigure or UIHTML) and layout archetype.
  • Produces a detailed implementation plan and writes it to a markdown file.
  • Supports building UIFigure apps with optional App Designer serialization.
  • Ensures structural integrity by enforcing grid-based layouts and proper background task handling.
  • Provides a clear, step-by-step build sequence based on internal documentation.

When to use it

  • When you need to build a new MATLAB GUI or interactive tool.
  • When you are unsure whether to use UIFigure or UIHTML for a specific project.
  • When you need to define a clear development plan for a complex MATLAB application.
  • When you want to create an App Designer app using either binary or plain-text formats.

Advantages

  • Ensures consistent, maintainable application architecture.
  • Prevents common pitfalls by enforcing proven layout and background task patterns.
  • Provides clear guidance on choosing between App Designer and programmatic approaches.
  • Facilitates collaboration by requiring a documented implementation plan before coding.

Usage examples

“I need to build a MATLAB dashboard to monitor sensor data. What approach should I take?”
The agent will ask discovery questions about the app's lifespan, team skills, and visual needs, then recommend an architecture and layout archetype before creating a plan.
“Build me a UIHTML app for visualizing experimental results.”
The agent will skip the architecture recommendation, ask for any missing requirements, and proceed to generate an implementation plan for a UIHTML-based app.

Install

Documentation by MathWorks

MATLAB Build App

Determine the best architecture for a MATLAB application, produce an implementation plan grounded in internal references, and execute the build. For UIFigure apps, optionally serialize into an App Designer format.

When to Use This Skill

Use this skill when:

  • User wants to build a MATLAB app, GUI, or interactive tool

  • User asks "how should I build this app?" or "which approach should I use?"

  • User describes an application — with or without specifying an implementation path

  • User mentions: MATLAB app, GUI, uifigure, uihtml, interactive tool, dashboard, visualization app, App Designer, .mlapp, plain-text app

  • User describes spatial layout needs: dashboard, control panel, sidebar, tabs, wizard, stepper, canvas, workspace

  • User has already chosen a path (e.g., "build me a uihtml app") — handle directly

When Not to Use

  • The request is purely about MATLAB computation with no UI component

  • The user is asking about an existing app they want to modify → read references/editing-guide.md

  • The user wants to convert between App Designer formats (e.g., .mlapp to plain-text or vice versa) → tell them to use File > Save As in App Designer. Do NOT attempt the conversion programmatically.

Critical Rules

  • MUST ask discovery questions before recommending a path — unless the user already specified one

  • MUST confirm the path choice with the user before producing the implementation plan

  • MUST produce an implementation plan grounded in internal references before writing any code

  • MUST write the plan to a file (<app-name>-plan.md) in the working directory

  • NEVER recommend a path without understanding the user's constraints (unless path was pre-specified)

  • NEVER apply dark mode, custom colors, or visual themes unless the user explicitly requests them

  • ALWAYS present the recommendation as guidance, not a mandate — the user decides

  • MUST choose archetype based on the user's primary task, not aesthetics

  • NEVER treat two archetypes as equals within one app — one is always the primary container

  • UIFigure app: MUST use uigridlayout for all structural layout — never Position-based sizing

  • UIHTML/web app: MUST use CSS Grid or Flexbox for chrome — no absolute positioning for structural panels

  • The chrome (header, sidebar, tabs, step indicator) MUST remain spatially stable

  • Background execution (any operation taking more than ~1 second) requires a class-structured app and MUST be read up first in references/background-tasks.md — do NOT hand-write parfeval/backgroundPool/DataQueue plumbing from memory. For an App Designer app (.mlapp or plain text) you MUST use the addBackgroundTask verb and NEVER hand-roll the infrastructure or reuse the standalone-programmatic manual wiring. For a standalone programmatic app, use the MVVM structure per that doc. A flat nested-function app that needs background work MUST escalate to one of these.

  • App Designer serialization: MUST read references/app-designer/agent-guide-shared.md (covers ownership models, editing discipline, property rules, quoting) plus the format-specific guide (agent-guide-mlapp.md or agent-guide-plaintext.md) before building. Those docs are the single source of truth; do not attempt to edit app files without reading them first.

Workflow

User request arrives
        │
        ├── Path NOT specified → Full Discovery
        │       │
        │       ▼
        │   Ask Q1-Q4 (purpose, lifespan, polish, team skills)
        │       │
        │       ▼
        │   Identify layout archetype
        │       │
        │       ▼
        │   Recommend UIFigure vs UIHTML based on Q1-Q4
        │       │
        │       ▼
        │   *** STOP: Present recommendation and WAIT for user confirmation ***
        │   (Do NOT produce a plan or read references until user says yes)
        │       │
        │       ▼
        │   Ask Q5 (FINAL): Serialization format? (UIFigure apps only)
        │       │
        │       ├── App Designer → release check, present format choice,
        │       │       continue with UIFigure references + add serialization step
        │       │
        │       └── Standalone programmatic → no extra step
        │       │
        │       ▼
        │   Produce Implementation Plan → write to <app-name>-plan.md
        │       │
        │       ▼
        │   User reviews plan → confirms or adjusts
        │       │
        │       ▼
        │   Begin building (read references per the plan)
        │
        └── Path IS specified
                │
                ├── Serialization explicit (e.g., ".mlapp app", "plain-text app")
                │       → Skip Q5, proceed with stated format
                │       → Ask only missing requirements + archetype if unclear
                │       → Produce Implementation Plan
                │
                ├── Architecture explicit but serialization not stated
                │   (e.g., "build me a uifigure app")
                │       → Still ask Q5 (serialization) before planning
                │       → Ask missing requirements + archetype if unclear
                │       → Produce Implementation Plan
                │
                └── UIHTML or standalone programmatic explicit
                        → Skip Q5 entirely (not applicable)
                        → Ask missing requirements + archetype if unclear
                        → Produce Implementation Plan

Discovery Questions

Ask these conversationally — not as a rigid checklist. Gather requirements and layout intent first; ask the serialization question last, once you understand what the app needs to do.

Core Questions

1. What does the app do and who is it for?

What will this app do? Who will use it?

Listen for archetype signals: "dashboard", "control panel", "step-by-step", "workspace".

2. Is this a quick tool or something you'll maintain over time?

Is this meant to be maintained and evolved, or is it more of a quick, proof-of-concept tool?

  • Maintained → proceed to remaining questions; team skills matter

  • Ephemeral → favor UIHTML app path; can skip team question

3. How polished does the UI need to look?

Are standard MATLAB buttons, sliders, tables, and plots enough? Or do you need custom visuals — branded, animated, or visually richer?

  • Standard controls sufficient → UIFigure app signal

  • Custom visuals needed → UIHTML app signal

4. Who will work on this app going forward?

Will this be maintained by people comfortable only with MATLAB, or by people also comfortable with web technologies?

Only ask for maintained apps.

  • MATLAB-only team → UIFigure app

  • Web-comfortable team → UIHTML app

5. (FINAL) How should this app be saved?

Do you want this app to open and edit inside App Designer, or do you prefer a standalone programmatic file (no App Designer dependency)?

This is a serialization question, not an architecture question. The app's structure (components, layout, callbacks) is designed using UIFigure knowledge regardless of the answer. Q5 only determines how that design is persisted to disk.

  • App Designer → .mlapp or plain-text .m + .xml. Check release (plain-text needs R2026b+). If Q3 indicated custom visuals, note that App Designer constrains visual customization vs UIHTML and confirm.

  • Standalone programmatic → programmatic .m code, no App Designer dependency. MVVM may warrant multiple files; that is decided at build time.

Follow-up Probes (only if path isn't clear)
  • Interaction style: Real-time feedback needed? → slight UIFigure lean

  • Existing work: Existing MATLAB UI code? → UIFigure. Existing web assets? → UIHTML

  • Distribution: May need to work outside MATLAB? → UIHTML

  • Long computations: Will any operation take more than a second? → use a background task (read references/background-tasks.md). Note this requires a class-structured app: App Designer serialization, or MVVM if standalone programmatic. Heavy, long, or one-shot work is ALWAYS a background task, never a timer; a timer fits only scheduled, cheap-per-tick work that must update the UI on the main thread (read references/timers.md).

Path Decision Logic

Two stages: first determine architecture (Q1-Q4), then determine serialization format (Q5).

Stage A — Architecture (from Q1-Q4):

Ephemeral app? → Strong default to UIHTML app

Maintained app? → Weigh signals:

Strong UIFigure signals:
  ✓ Maintained + MATLAB-only team
  ✓ Standard UI components sufficient
  ✓ Tight real-time interaction
  ✓ Existing MATLAB UI code

Strong UIHTML signals:
  ✓ Ephemeral (regardless of team)
  ✓ Maintained + web-skilled team
  ✓ Custom visuals, branded look, animations
  ✓ Existing web assets
  ✓ Future portability outside MATLAB

UIFigure + uihtml accent:
  Mostly standard app but needs one custom visualization panel.

Stage B — Serialization format (Q5, UIFigure apps only):

Q5 = Standalone → programmatic code (no App Designer). Done.

Q5 = App Designer → adds a serialization layer ON TOP of Stage A.
  UIFigure references still apply in full. Serialization is IN ADDITION TO,
  not instead of, the normal UIFigure build.
  → Check release, present format choice (plain text vs .mlapp).
  → If Stage A indicated UIHTML for custom visuals, surface the trade-off:
    App Designer constrains custom visuals — confirm before committing.

Weighting: 1. Architecture (Q1-Q4) 2. Serialization (Q5, applies only to UIFigure)

Paths at a Glance

ArchitectureKey strength
UIFigure appSingle language, any MATLAB dev can maintain
UIHTML appFull visual control, rich interactivity
UIFigure + accentBest of both when you need one custom visual

For UIFigure apps, three serialization formats:

FormatTrade-off
Programmatic .mStandalone, no App Designer dependency
App Designer .mlappBinary, works on any release, opens in App Designer
App Designer plain text .m + .xmlSource-controllable, AI-editable, R2026b+

Layout Archetype

Pick based on the user's primary task:

ArchetypePrimary user taskStructure
DashboardMonitor and compare at a glanceKPI cards + charts + table; read-only
ExplorerAdjust parameters, observe live resultsSidebar controls + live display
TabbedNavigate between independent sectionsTab bar + content panels
WizardComplete a sequential workflowStep indicator + one-step-at-a-time
CanvasCreate, inspect, or edit spatial artifactsCentral workspace + tools

If unclear, ask: "Will users mostly be watching results (Dashboard), tweaking controls (Explorer), switching sections (Tabbed), going through steps (Wizard), or working on a central figure (Canvas)?"

Implementation Plan

After confirming path and archetype, produce a plan and write it to <app-name>-plan.md in the working directory. Present a concise summary inline with the approval request.

Plan Template
**Implementation Plan: [App Name]**

**Architecture:** [UIFigure app / UIHTML app / UIFigure + accent]
**Serialization:** [Programmatic .m / App Designer .mlapp / App Designer plain text]
**Layout:** [Archetype] — [one sentence describing spatial structure]

**Structure:**
- [Major panel/area — spatial description]
- [e.g., "Left sidebar (220px) with date range picker, category filter, refresh button"]
- [e.g., "Main area with line chart showing filtered results"]

**Key behaviors:**
- [User-visible interaction effects]

**Internal references that will be used:**

| Reference | Role in this app |
|-----------|-----------------|
| `references/path/file.md` | [what it provides] |
| ... | ... |

**External skills:**
- `matlab-build-chart` — [role, if applicable]
- `matlab-apply-theme` — [role, if applicable]

**File organization:**
[app directory tree]

**Implementation sequence:**
1. [First reference read] — [what it establishes]
2. [Next reference] — [what it adds]
3. [...]

Each reference pointer carries provenance: [src: references/uifigure/grid-layout.md §Spanning]

Plan Quality Checks

Before presenting:

  • [ ] Every reference listed has a concrete role

  • [ ] Structure uses spatial terms the user can visualize

  • [ ] Behaviors describe user-visible effects

  • [ ] Implementation sequence shows a logical build order

  • [ ] Plan is specific enough for "yes, that's what I want" or "change X"

Reference Router

After plan approval, read the relevant internal references to execute the build.

UIFigure Path
When building...Read
Grid layout, sizing, componentsreferences/uifigure/guide.md
Grid details (spanning, collapse)references/uifigure/grid-layout.md
Panels, tab groups, nested gridsreferences/uifigure/containers.md
Component reference (controls, display)references/uifigure/components.md
Callback patterns, data sharingreferences/uifigure/callbacks.md
Layout recipes (sidebar, form, split)references/uifigure/layout-patterns.md
MVVM architecture (complex apps)references/uifigure/mvvm-guide.md
View binding patternsreferences/uifigure/mvvm-view-binding.md
ViewModel testingreferences/uifigure/mvvm-testing.md
Background execution — concepts + routing (read first)references/background-tasks.md
Background execution — standalone programmatic (MVVM) wiringreferences/uifigure/mvvm-background-tasks.md
Timers — periodic main-thread work (NOT for offloading heavy work)references/timers.md
UIHTML Path
When building...Read
MATLAB-JS bridge, setup(), eventsreferences/uihtml/bridge-guide.md
Communication patterns (4 patterns)references/uihtml/communication-patterns.md
Data type conversionreferences/uihtml/data-types.md
Platform constraintsreferences/uihtml/platform-limitations.md
uihtml creation, hybrid layoutsreferences/uihtml/setup.md
Error handling (both sides)references/uihtml/error-handling.md
JS MVVM architecturereferences/uihtml/mvvm-guide.md
Observable/Computed classesreferences/uihtml/mvvm-observable-classes.md
JS View bindingreferences/uihtml/mvvm-view-binding.md
JS coding patterns, modulesreferences/uihtml/js-coding-guide.md
JS testing & debuggingreferences/uihtml/js-testing-debugging.md
Chart.js setup & patternsreferences/uihtml/charting-guide.md
Chart type selectionreferences/uihtml/chart-type-selection.md
Chart.js initializationreferences/uihtml/chartjs-setup.md
Line & bar chartsreferences/uihtml/line-bar-charts.md
Doughnut & scatter chartsreferences/uihtml/doughnut-scatter-charts.md
Chart data updatesreferences/uihtml/chart-updates.md
Chart ↔ bridge integrationreferences/uihtml/chart-bridge-integration.md
Chart performancereferences/uihtml/chart-performance.md
CSS styling & tokensreferences/uihtml/styling-guide.md
Component CSS (buttons, inputs)references/uihtml/component-styles.md
CSS layout patternsreferences/uihtml/css-layout-patterns.md
Brand design tokensreferences/uihtml/brand-design-tokens.md
Dark modereferences/uihtml/dark-mode.md
External color schemesreferences/uihtml/external-color-schemes.md
App Designer Serialization (UIFigure apps only)

Important: App Designer serialization is an additional step AFTER the normal UIFigure build. You MUST also read the UIFigure path references above (components, grid-layout, callbacks, containers, layout-patterns) to design the app's structure. The serialization references below cover only how to persist that design to disk.

Both formats use the same AppDesignerAgentInterface API via the bundled scripts/ tool; only the file extension passed to create()/open() differs.

Read first (both formats):

When building...Read
Verbs, build sequence, editing, save()/validate()/finalize(), inspect()references/app-designer/agent-guide-shared.md
Background execution — concepts + routing (read first)references/background-tasks.md
Background execution — addBackgroundTask verb referencereferences/app-designer/background-tasks.md

Plain-text (.m + .xml):

When building...Read
Ownership model, .xml authoring, flow, gotchasreferences/app-designer/agent-guide-plaintext.md
classdef structure & block ordering rulesreferences/app-designer/plaintext/classdef-template.md
XML structure and which properties to setreferences/app-designer/plaintext/xml-template.md
Per-component property names, types, defaultsreferences/app-designer/plaintext/property-reference.md
Authoritative XML schemareferences/app-designer/plaintext/matlabAppSchema.xsd

Binary .mlapp:

When building...Read
Build flow, native property values, save()/finalize()references/app-designer/agent-guide-mlapp.md
Editing an Existing App
When editing...Read
Any existing app (determines format, routes to approach)references/editing-guide.md
Archetype References
ArchetypeFile
Dashboardreferences/archetypes/dashboard.md
Explorerreferences/archetypes/explorer.md
Tabbedreferences/archetypes/tabbed.md
Wizardreferences/archetypes/wizard.md
Canvasreferences/archetypes/canvas.md
External Skills (invoked, not read)
  • matlab-build-chart — when the app includes MATLAB plots (UIFigure path or UIFigure+accent)

  • matlab-apply-theme — when the app needs dark mode, brand colors, or custom palettes (UIFigure path)

After Plan Approval

All UIFigure apps (regardless of serialization format)
  1. Read the archetype reference for the spatial skeleton

  2. If MVVM warranted (Explorer, Wizard, Canvas, or complex apps): read the architecture reference

  3. Read the UIFigure guide to establish layout (grid, components, containers)

  4. Layer in path-specific references per the implementation sequence

  5. For visual polish: invoke matlab-apply-theme (UIFigure) or read styling references (UIHTML accent)

  6. For charts: invoke matlab-build-chart (UIFigure) or read charting references (UIHTML accent)

  7. If App Designer serialization: read the app-designer reference docs (shared guide + format-specific guide), then use the AppDesignerAgentInterface API to persist the app. The docs contain the complete build flow, property rules, and editing discipline.

UIHTML path
  1. Read the archetype reference for the spatial skeleton

  2. If MVVM warranted: read the JS MVVM architecture reference

  3. Read the bridge guide to establish the MATLAB-JS connection

  4. Layer in path-specific references per the implementation sequence

  5. For visual polish: read styling/CSS references

  6. For charts: read charting references

Format Fallback

If the plain text path produces errors that cannot be resolved (e.g., version mismatch, unsupported component), fall back to the .mlapp path — the same verbs drive both formats; re-create the handle with a .mlapp extension. Only fall back to fully programmatic UIFigure code as a last resort.

Recommendation Template

Recommended architecture: [UIFigure app / UIHTML app / UIFigure + accent]

Based on what you've described:

  • [Key signal 1]

  • [Key signal 2]

  • [Key signal 3, if applicable]

What this means: [1-2 sentences on development experience]

Trade-off: [Main thing they'd give up vs the other path]

Serialization (if App Designer): I'd recommend [.mlapp / plain text] because [reason]. This doesn't change the app's structure, just how it's saved.

Want to proceed with this approach, or would you prefer the other path?


Copyright 2026 The MathWorks, Inc.


Files

references/app-designer/agent-guide-mlapp.md

AppDesignerAgentInterface: .mlapp Guide

Read agent-guide-shared.md first. This file covers what is specific to binary .mlapp apps.

Ownership model: the tool owns everything

For .mlapp, the tool owns the whole app — the component tree AND the code. You build the entire app through verbs; nothing is hand-edited on disk (a .mlapp is a single binary file). So all verbs are available, including the component verbs (addComponent, setProperty, removeComponent, moveComponent, addCallback).

This is the opposite of plaintext, where you hand-author the component tree in .xml.

Build flow

appBuilder = AppDesignerAgentInterface.create("C:/path/MyApp.mlapp");

% Figure (root, already exists as "UIFigure")
appBuilder.setProperty("UIFigure", "Position", [100 100 320 400]);
appBuilder.setProperty("UIFigure", "Name", "My App");

% Components
appBuilder.addComponent("Label", "StatusLabel", "UIFigure", struct( ...
    'Position', [20 350 280 30], 'Text', 'Hello', 'FontSize', 16));
appBuilder.addComponent("Button", "GoButton", "UIFigure", struct( ...
    'Position', [110 175 100 32], 'Text', 'Go'));

% Callbacks: wire the event, then set the body
appBuilder.addCallback("GoButton", "ButtonPushedFcn", "onGo");
appBuilder.setCallbackCode("onGo", "app.StatusLabel.Text = ""Clicked!"";");

% App-level state + startup
appBuilder.addProperty("Count", "", "private");
appBuilder.addCallback("UIFigure", "StartupFcn", "startupFcn");
appBuilder.setCallbackCode("startupFcn", "app.Count = 0;");

% Helper methods (FULL function text)
appBuilder.addMethod("reset", strjoin([ ...
    "function reset(app)" ...
    "    app.Count = 0;" ...
    "end" ], newline), "private");

appBuilder.save();
Property values are native MATLAB values

Unlike plaintext .xml, mlapp props go straight through the verb as real MATLAB values. Pass them natively:

  • color: [0.2 0.6 0.9] (RGB triplet, or a column vector is coerced)

  • string: 'Go' or "Go"

  • numeric: 28

  • logical: true

No quoting-inside-a-string dance — that is a plaintext-only concern.

Cell-valued properties need DOUBLE braces in the struct(...) call. A property whose value is itself a cell array (e.g. a DropDown/ListBox Items list) is a MATLAB struct() trap: struct() treats a single cell array as struct-array construction, so struct('Items', {'10%','20%'}) builds a 1x2 struct array, not one struct with a two-element Items. Wrap the cell in an outer brace to keep it as a scalar struct field:

% WRONG — makes a 1x2 struct array, not what you want:
%   struct('Items', {'10%','20%'})
% RIGHT — double brace keeps Items as one cell-array value on one struct:
appBuilder.addComponent("DropDown", "TipDrop", "UIFigure", struct( ...
    'Position', [20 20 120 22], 'Items', {{'10%','20%'}}, 'Value', '20%'));

This applies to any cell-valued property (Items, ItemsData, etc.). Scalar values (numbers, chars, RGB triplets, logicals) need no such wrapping.

Exactly DOUBLE braces — never triple. The outer brace is consumed by struct(); one pair leaves the flat cell you want. A third pair over-wraps it into a cell containing a cell, which stores silently and then fails at save(). This is easy to hit with a mixed cell like a grid's RowHeight:

% WRONG — triple brace over-wraps to {{80 '1x' 60}} (a cell holding a cell):
%   struct('RowHeight', {{{80, '1x', 60}}})
% RIGHT — double brace gives the flat {80, '1x', 60}:
appBuilder.addComponent("GridLayout", "Grid", "UIFigure", struct( ...
    'RowHeight', {{80, '1x', 60}}, 'ColumnWidth', {{'1x', '1x'}}));

For the known flat-cell props (RowHeight, ColumnWidth, Items, ItemsData) the AppDesignerAgentInterface rejects the over-wrapped form with AppDesignerAgentInterface:overWrappedCell rather than letting it fail opaquely at save.

Property order does not matter (coupled properties handled for you)

Some components have coupled properties that must be applied in a specific order. The classic case: a DropDown's Value must be one of its Items, so Items has to be set before Value. If you set Value first, the product rejects it ('Value' must be an element defined in the 'Items' property).

You do not have to worry about this. Pass properties in whatever order is natural in your struct — the tool reorders them into App Designer's own canonical order at materialization time, using the same ordering the product uses for code generation (VisualComponentAdapter.getCodeGenPropertyNames). So both of these are equivalent and both work:

% Value listed before Items in the struct — still fine:
appBuilder.addComponent("DropDown", "ModeDrop", "UIFigure", struct( ...
    'Position', [20 20 120 22], 'Value', 'Fast', 'Items', {{'Slow','Fast'}}));

This also means a save() -> open() -> save() round-trip on an app containing one of these components no longer fails (an earlier version reordered the property bag on reopen and broke re-save; that is fixed).

The components with order-dependent property pairs, grouped by pattern (the tool handles all of them; this is reference, not a checklist you must follow):

Coupling patternComponentsRule the tool enforces
Selection list -> selected valueDropDown, ListBox, Switch, ToggleSwitch, RockerSwitch, DiscreteKnobItems / ItemsData before Value
Numeric range -> valueSlider, Knob, NumericEditField, SpinnerLimits (and ticks / Step) before Value
Gauge range -> valueGauge, LinearGauge, SemicircularGauge, NinetyDegreeGaugeLimits / MajorTicks / MajorTickLabels before Value
Date range -> valueDatePickerLimits / DisabledDates / DisplayFormat before Value

Two notes for the curious: ValueIndex is ignored by codegen for DropDown/Switch (the Items-before-Value constraint is enforced at set-time, not via an index), and ButtonGroup has no Value at all (its selection is SelectedObject, a child handle). None of this changes what you do — set properties in any order.

Placing a component into a GridLayout cell

To place a component in a grid cell, pass Layout as a struct with Row and Column fields. NOT a [row col] vector (rejected with AppDesignerAgentInterface:invalidLayoutValue) and NOT dot-path ("Layout.Row").

appBuilder.addComponent("Button", "GoButton", "MainGrid", struct( ...
    'Text', 'Go', 'Layout', struct('Row', 1, 'Column', 2)));

save() for mlapp: atomic, gate-then-write

Because a partial write to a binary file is unrecoverable corruption, mlapp save() is atomic:

  1. Materialize the model into live component objects once.

  2. Write to a unique temp path.

  3. Round-trip re-read it (serialization integrity), then run the real product loader on the temp (the same strict gate as opening it in App Designer).

  4. Only if both pass, atomically copy onto the real path.

If the gate fails, the real file is never touched and save() throws (MlappBackend:loadFailed or MlappBackend:erroredComponents, naming the component).

finalize(): bake it runnable and open it for viewing

mlapp only. save() writes a lightweight stub: component handle properties, callback bodies, custom props/methods, and a bare AppBase constructor — but NOT the runnable body (createComponents, registerApp, callback wiring, runStartupFcn). App Designer regenerates that body itself. finalize() automates exactly that, headlessly:

AppDesignerAgentInterface.finalize("C:/path/MyApp.mlapp");            % default 60s deadline
AppDesignerAgentInterface.finalize("C:/path/MyApp.mlapp", 120);       % raise deadline

It launches App Designer, waits until the app is fully open and ready, saves (AD bakes the full runnable classdef to disk), and leaves the app open in App Designer for the user to view — baking it runnable and showing it are the same action. It does not close the app.

  • Cost: ~3-5s warm, up to ~16s on a cold AD launch.

  • Requires a live App Designer / connector session (the save routes through AD's JS code engine). Works headless (no -desktop needed).

  • Only needed when you want the app to run directly or be viewed. If you are going to keep editing via AppDesignerAgentInterface, you do not need to finalize between edits — save() alone keeps the file loadable in App Designer.

  • Reopening after finalize is safe — keep editing freely. Because finalize saves through the live product, App Designer bakes the live component state into the file, including read-only runtime properties (e.g. UIAxes.NextSeriesIndex). open() filters those out (it only reads publicly-settable props), so a finalize() -> open() -> edit -> save() cycle round-trips cleanly. Finalize is never a dead end, and you never need to rebuild from scratch to edit a finalized app.

finalize deadline / wedge behavior (know this)

App Designer can wedge (e.g. a modal dialog if a file changed under it), and the open/save waits have no built-in timeout. finalize runs under a hard-deadline watchdog:

  • If the open wait exceeds the deadline, it aborts and throws AppDesignerAgentInterface:finalizeTimeout without closing anything — you recover manually (close App Designer / the stuck app, then retry, or raise deadlineSeconds).

  • A save-side wedge is rare (save on an already-open, ready app is fast); it is intentionally NOT force-closed either, to honor the "never close an app the caller did not ask us to touch" rule.

Posture-A guard: editing an app the user may have open

create() and open() release the file from App Designer before touching disk (AD holding a stale copy while the file is rewritten triggers a wedging reload dialog). The guard:

  • If AD holds the file with unsaved edits -> it rejects (never discards your work): close or save it in App Designer first, then retry.

  • If AD holds a clean copy -> it closes that copy and proceeds.

So it is safe to open() and edit an app that is currently open in App Designer, as long as it has no unsaved changes.

Where unsaved changes come from — do NOT blame finalize(). finalize() saves the app through the product and leaves it open clean (no pending edits). So a reject on AppDesignerAgentInterface:appOpenAndModified after a finalize means the user edited the app in App Designer since then — not that finalize failed to save. Tell the user that plainly ("the app has unsaved edits in App Designer; save or close it and I'll continue"), and never say the changes came from the finalize step. The recovery is the same either way (user saves/closes, you retry), but the cause you report must be correct.

The edit path (open an existing mlapp)

appBuilder = AppDesignerAgentInterface.open("C:/path/MyApp.mlapp");
appBuilder.setProperty("UIFigure", "Color", [0.13 0.12 0.23]);
appBuilder.setProperty("GoButton", "BackgroundColor", [0.20 0.72 0.68]);
appBuilder.save();

open() reads the binary, converts the live object graph to a plain model, and hands you a normal editable handle. There is no cross-file consistency check for mlapp (one binary file, no drift); the loadability guarantee is the save() gate.

Do not re-create() to edit an existing .mlapp, and do not rebuild the app from scratch to make a change. Edit = open() + the minimal verbs + save(). Call inspect() first to see current geometry and existing code names before you mutate — see "Editing an existing app" in the shared guide, which covers inspect-first, read-modify-write for code, and the overwrite warning. All component verbs (addComponent, setProperty, removeComponent, moveComponent, addCallback) are available on the opened model.

Sub-object properties (UIAxes Title, XLabel, YLabel, etc.)

Some component properties hold handle objects that cannot be replaced wholesale. On UIAxes: Title, XLabel, YLabel, ZLabel, Subtitle are all matlab.graphics.primitive.Text objects. Use dot-path syntax to set their sub-properties individually:

appBuilder.setProperty("UIAxes", "Title.String", "Revenue");
appBuilder.setProperty("UIAxes", "Title.FontSize", 14);
appBuilder.setProperty("UIAxes", "XLabel.String", "Quarter");
appBuilder.setProperty("UIAxes", "YLabel.String", "Amount ($)");

Do NOT pass a struct for these properties. This will error with guidance:

% WRONG: throws subObjectRequiresDotPath
appBuilder.setProperty("UIAxes", "Title", struct('String', 'Revenue'));

Known-good patterns (verified)

  • Shared callback across many buttons via event.Source (e.g. a 3x3 board all wired to one CellPushed) — dedupes to one generated function.

  • RGB triplets, FontWeight, color props all pass Layer-1 and the loader gate.

  • Containers are NOT transparent — color them explicitly. A GridLayout has its own BackgroundColor and a Panel its own BackgroundColor; they do not show the figure Color through. If you set UIFigure.Color for a themed look, the grid/panel sitting on top still paints its default gray unless you set its BackgroundColor too. To carry one color across the app, set it on the figure AND every GridLayout/Panel in the tree (a bare figure Color alone leaves visible gray blocks).

  • addProperty defaults are VALUES, not code. A char/string default is emitted as a quoted literal, so addProperty("InputType", "Step") yields InputType = 'Step' (the string 'Step'), and addProperty("Count", 0) yields the number 0. A string is NEVER treated as a code expression: addProperty("Buf", "zeros(1,10)") gives the char 'zeros(1,10)', NOT a numeric array. To initialize richer state (a computed value, an array, a handle, a timer), declare the property bare with addProperty(name, "", "private") and assign it in startupFcn (e.g. app.Buf = zeros(1,10);). That is the App Designer idiom: property defaults are for literal values, startup code is for everything computed.

  • User Authored Components (UAC) are not supported. You cannot addComponent a UAC. The workaround: instantiate it in StartupFcn (e.g. app.MyGauge = MyGaugeComponent(app.UIFigure);) and set layout/properties there. It will work at runtime but will not appear in Design View. If the user needs it visible in Design View, suggest they add it manually in App Designer; on subsequent open() calls AppDesignerAgentInterface can access it normally via setProperty/getProperty.

Backup and recovery

open() copies the existing .mlapp file to <filepath>.backup before any mutation. This is a single rolling recovery point — overwritten on every open() call. It is NOT created on first create().

If the user reports their app looks broken

Do NOT call open() again. Calling open() on the corrupted file will overwrite .backup with the corrupted state, destroying the only recovery point.

Instead, diagnose without opening:

  1. Check the error output from the failed session — what did open() or save() report?

  2. If the error mentions unparseable code, the app's editable section likely has invalid MATLAB syntax (missing ... continuations, unclosed brackets, etc.). The user must fix this manually in App Designer before the API can open the file.

  3. If the edit session completed without error but the app looks wrong, inspect the file non-destructively (e.g., read the generated code via FileReader) to understand what changed.

Only as a last resort — when the app is irrecoverably broken and no targeted fix is possible — restore from backup:

copyfile('MyApp.mlapp.backup', 'MyApp.mlapp');

After restoring, the user should reopen in App Designer to confirm correctness before any further programmatic edits.


Copyright 2026 The MathWorks, Inc.


Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Declares allowed tools

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
MathWorks
Publisher
MathWorks (Official)
Source
matlab/matlab-agentic-toolkit · skills-catalog/matlab-app-building/matlab-build-app · commit 2a7f215
Licence
BSD 2-Clause License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE.md)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by MathWorks.

Get it from the source

5 of this skill’s files are not mirrored here, so there is no ZIP. Get the complete skill from its source: matlab/matlab-agentic-toolkit