MCPInstall
matlab avatar

matlab-export-session-script

Export conversation MATLAB code to a clean, runnable .m script. Use when asked to save or export session work. TRIGGER: user asks to save, export, or generate a script from the current session's MATLAB code. Also when asked for a reproducible script or clean version of what was run.

Installs
80
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-export-session-script
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads matlab-export-session-script automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Exporting a Session to a MATLAB Script

Extracts all MATLAB code executed during the current conversation, assembles it into a well-documented, runnable .m script, and saves it to the working directory.

Quick Reference

StepAction
1. ScanWalk assistant messages chronologically; extract each executed MATLAB code block
2. DeduplicateKeep only the final successful version of repeated blocks
3. OrderArrange into logical workflow order (setup, model, config, analysis, visualization)
4. FormatAdd %% section headers, consolidate parameters at top
5. SaveWrite to Results/<descriptive_name>.m under the working directory

When to Use

  • User says "export this session as a script"
  • User says "create a script from what we did"
  • User says "save the MATLAB code from this conversation"
  • At the end of any MATLAB workflow session when deliverables are requested

When NOT to Use

  • Writing new MATLAB code from scratch — just write the code directly
  • Exporting non-MATLAB content (Python, shell scripts, etc.)
  • Creating Live Scripts (.mlx) — this skill produces plain .m files only

Extraction Rules

Include

  • All MATLAB code that produced meaningful results (analysis, design, visualization)
  • Variable assignments, function calls, plotting commands
  • addpath calls needed for utility functions used during the session

Exclude

  • Shell commands: PowerShell, Bash, OS commands, sbm wrappers
  • MCP tool call metadata and framework boilerplate
  • Exploratory one-liners that were debugging dead ends
  • Agent-only fprintf statements used to relay info back (keep user-facing ones)
  • 'Visible','off' on figures -- the exported script is for interactive use

Deduplicate

When the same block was run multiple times (e.g., to fix an error), keep only the final successful version. Do not include intermediate failed attempts or parameter corrections -- use the values that worked.

Script Assembly

1. Scan the Conversation

Walk through all assistant messages chronologically. For each MATLAB code block that was executed (via MCP, -batch, or similar), extract the MATLAB portion and note:

  • What it accomplished (this becomes the section comment)
  • Whether it succeeded or was superseded by a later version
  • Its logical position in the workflow

2. Order Logically

Arrange extracted code into a natural workflow order, which may differ from execution order:

  1. Setup (paths, parameters, imports)
  2. Data loading / model creation
  3. Configuration
  4. Analysis / computation
  5. Visualization / results

3. Format as Sections

%% <Title> -- <One-line summary>
% <Multi-line description of what this script does.>
% <Key context: what design, what board, what analysis, etc.>
%
% Required toolboxes: <list only what was actually used>

%% Step 1: <Description>
% <Why this step matters>
<code>

%% Step 2: <Description>
<code>

Formatting Conventions

  • %% section breaks for each logical step (creates foldable sections in MATLAB Editor)
  • One comment line before each section explaining intent
  • Consolidate parameters into the setup section rather than scattering through the script
  • Preserve variable names exactly as used in the session
  • Escape underscores in title() / xlabel() TeX strings: \_ not _

Output

File Naming

Derive from the session's primary task. Use lowercase with underscores:

  • openrex_core_rail_dc_analysis.m
  • hairpin_filter_design_2p4ghz.m
  • via_crosstalk_sweep.m

File Location

Save to Results/ under the working directory. Create the folder if it doesn't exist.

After Saving

Tell the user:

  • The file name and path
  • How many sections / lines the script contains
  • That it is ready to run in MATLAB with the required toolboxes

Common Patterns

  • One script per session -- consolidate all related work into a single script, even if it spans multiple design iterations. Multiple scripts are only warranted for unrelated workflows in the same session.
  • Parameters at the top -- gather all user-configurable values (freq, substrate, dimensions) into the setup section so the user can modify them without hunting through the script.
  • Suppress figures in batch -- if the script may be run non-interactively, wrap plotting in if ~exist('BATCH_MODE', 'var') guards. But default to showing figures for interactive use.
  • Path management -- if the script uses files (Touchstone, board files), place file paths in variables at the top of the setup section. Use fullfile() for cross-platform paths. Never hard-code absolute paths.
  • Batch mode header -- for scripts that may be run via matlab -batch, add at the top:
    %% Configuration
    BATCH_MODE = exist('BATCH_MODE', 'var') || ~usejava('desktop');
    if ~BATCH_MODE, close all; clc; end
    
  • Results directory -- save outputs to a Results/ subfolder:
    resultsDir = fullfile(pwd, 'Results');
    if ~exist(resultsDir, 'dir'), mkdir(resultsDir); end
    

Pitfalls

  1. Do not include shell commands. Only MATLAB code belongs in the exported script. PowerShell, Bash, and sbm wrapper invocations must be stripped. If a shell step is essential (e.g., downloading a file), replace it with a comment noting the prerequisite.

  2. Do not keep failed iterations. When a code block was re-run after fixing an error, only the final successful version should appear. Including intermediate failures makes the script unrunnable.

  3. Do not scatter parameters. Hard-coded values buried inside analysis or plotting sections are difficult to find and modify. Always hoist user-configurable parameters (freq, substrate, dimensions, file paths) into the setup section at the top.

  4. Do not hard-code absolute paths. Paths like C:\Users\viyer\... break on other machines. Use fullfile() and relative paths, or place path variables in the setup section.

  5. Do not leave 'Visible','off' on figures. Agent sessions suppress figure windows for non-interactive execution, but exported scripts are meant for interactive use. Remove 'Visible','off' arguments from figure() calls.

  6. Escape underscores in TeX strings. MATLAB interprets _ as a subscript in title(), xlabel(), ylabel(), and legend() calls by default. Use \_ or set 'Interpreter','none'.


Copyright 2026 The MathWorks, Inc.

FAQ

What does the matlab-export-session-script skill do?

Export conversation MATLAB code to a clean, runnable .m script. Use when asked to save or export session work. TRIGGER: user asks to save, export, or generate a script from the current session's MATLAB code. Also when asked for a reproducible script or clean version of what was run.

How do I install matlab-export-session-script?

Run npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-export-session-script in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/matlab-export-session-script/ (personal) or .claude/skills/matlab-export-session-script/ (project).

Which AI agents can use matlab-export-session-script?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is matlab-export-session-script safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains matlab-export-session-script?

It is published by matlab in matlab/matlab-agentic-toolkit. It has 80 recorded installs.

More from matlab/matlab-agentic-toolkit

View all →
matlab avatar

matlab-review-code

matlab/matlab-agentic-toolkit

Review MATLAB code for quality, performance, maintainability, and adherence to MathWorks coding standards. Uses checkmatlabcode and matlabcodingguidelines. Use when reviewing code, checking style, finding code smells, assessing quality, or preparing code for handoff or publication.

matlab avatar

matlab-analyze-data

matlab/matlab-agentic-toolkit

Analyze data using MATLAB. Use when the task involves tables, timetables, time-series data, numeric arrays, sensor matrices, or gridded data — including but not limited to exploring, row filtering, sorting, cleaning, transforming, aggregating, smoothing, padding, trimming, and answering questions about data. MATLAB provides extensive, easy-to-use built-in functions for these workflows with no additional products required.

AI & Agents155 installs
matlab avatar

matlab-design-digital-filter

matlab/matlab-agentic-toolkit

Design and validate digital filters in MATLAB. Use when cleaning up noisy signals, removing interference, filtering signals, designing FIR/IIR filters (lowpass/highpass/bandpass/bandstop/notch), or comparing filters in Filter Analyzer.

AI & Agents136 installs
matlab avatar

matlab-modernize-code

matlab/matlab-agentic-toolkit

Modernize removed or discouraged MATLAB functions and patterns. Use when the checkmatlabcode MCP tool reports that a function "is not recommended", "will be removed in a future release", or "has been removed" — at any severity (info, warning, or error) — when migrating legacy code, or when replacing removed or discouraged APIs with current equivalents. Also applies to discouraged patterns Code Analyzer does not flag (containers.Map, bsxfun, str2num, eval, clear all) and to removed or discouraged functions such as trainNetwork, csvread, xlsread, datenum, guide, svmtrain, ltln2val, webmap.

AI & Agents129 installs
matlab avatar

matlab-create-live-script

matlab/matlab-agentic-toolkit

Create, edit, and run plain-text MATLAB live scripts (.m files) with rich text formatting, LaTeX equations, section breaks, and inline figures. Use when generating tutorials, analysis notebooks, reports, documentation, or educational content, when modifying existing live scripts, or when converting existing binary .mlx files to .m for version control. Requires R2025a+.

AI & Agents122 installs
matlab avatar

matlab-agentic-toolkit-setup

matlab/matlab-agentic-toolkit

Install and configure the MATLAB Agentic Toolkit — detect MATLAB, install the MCP server, register with your AI coding agent, and verify the environment. Supports Claude Code, Codex, GitHub Copilot, Amp, and Gemini CLI.

AI & Agents121 installs

Popular ai & agents skills

View category →
google avatar

google-agents-cli-publish

google/agents-cli

This skill should be used when the user wants to "publish an agent", "publish my ADK agent", "register an agent with Gemini", "publish to Gemini" (formerly Gemini Enterprise), or needs guidance on the agents-cli publish gemini command. Also use when the user wants to "manage agents in Agent Registry", "list/update/delete registered agents", or "register an MCP server". Covers ADK vs A2A registration modes, programmatic and interactive usage, flag reference, auto-detection from deployment metadata, Agent Registry fleet management, and troubleshooting. Part of the agents-cli skills suite. Do NOT use for deployment (use google-agents-cli-deploy).

AI & Agents587.3K installs
google avatar

google-agents-cli-eval

google/agents-cli

This skill should be used when the user wants to "run an evaluation", "evaluate my agent", "evaluate my ADK agent", "write an eval dataset", "analyze eval failures", "compare eval results", "optimize agent", or needs guidance on the Gemini platform eval methodology and the Quality Flywheel. Covers eval metrics, dataset schema, LLM-as-judge scoring, and common failure causes. Applies to any agents-cli project, whatever framework the agent is written in. Do NOT use for agent API code patterns (ADK: use google-agents-cli-adk-code), deployment (use google-agents-cli-deploy), or project scaffolding (use google-agents-cli-scaffold).

AI & Agents586.1K installs
anthropics avatar

skill-creator

anthropics/skills

Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.

OfficialAI & Agents438.3K installs
prime-skills avatar

codex-pet

prime-skills/runcomfy-agent-skills

Codex Pet generator on RunComfy. Build a Codex-compatible Codex Pet spritesheet.webp + pet.json from a single reference image, drop it into ${CODEXHOME:-$HOME/.codex}/pets/ / and Codex picks it up as a custom Codex Pet next to the 8 built-ins. This skill produces the exact Codex Pet atlas Codex expects (1536x1872 PNG/WebP, 8 cols x 9 rows, 192x208 cells, 9 animation states — idle, running-right, running-left, waving, jumping, failed, waiting, running, review). Calls OpenAI GPT Image 2 edit ONCE via the local RunComfy CLI as runcomfy run openai/gpt-image-2/edit to produce a canonical Codex Pet pose, then assembles all 9 animation rows programmatically with ImageMagick micro-transforms — no Codex Pro, no $imagegen, no OPENAIAPIKEY required, only RUNCOMFYTOKEN. Triggers on "codex pet", "create codex pet", "make codex pet", "hatch codex pet", "/hatch image", "desktop pet codex", "codex pets", "spritesheet.webp", or any explicit ask to build a custom pet for OpenAI Codex.

AI & Agents412.7K installs
leonxlnx avatar

full-output-enforcement

leonxlnx/taste-skill

Overrides default LLM truncation behavior. Enforces complete code generation, bans placeholder patterns, and handles token-limit splits cleanly. Apply to any task requiring exhaustive, unabridged output.

AI & Agents401.1K installs
obra avatar

executing-plans

obra/superpowers

Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available

AI & Agents268.9K installs