Agent skill · Databases

matlab-setup-worker-state

Set up worker environment and per-worker state for parallel pools. Use when code needs paths, environment variables, database connections, loaded libraries, or expensive objects available on workers before parfor/parfeval runs. Teaches parallel.pool.Constant, parfevalOnAll, and parpool name-value pairs. Also use when refactoring existing code that uses spmd for side-effect setup (an anti-pattern). Triggers: worker setup, pool constant, per-worker state, non-serializable, loadlibrary on workers, database connection parfor, addpath workers, spmd before parfor, worker environment, reduce parfor o

matlabgithub.com/matlabGitHub ↗
claude-codecodexcopilotNOASSERTION
Install
npx skills add matlab/matlab-agentic-toolkit --skill matlab-setup-worker-state --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 2
SKILL.md size: 13 KB
Bundled scripts: none
Version: 1.0
Declared author: MathWorks
Path: skills-catalog/parallel-computing/matlab-setup-worker-state/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 868
Language: MATLAB

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# Set Up Worker State for Parallel Pools By default, process workers in a parallel pool inherit MATLAB path state from their controlling client, but they do not inherit loaded libraries, open connections, or expensive pre-computed objects. Code that relies on any of these needs explicit setup. This skill teaches the correct APIs for each scenario. Most patterns target process-based pools; thread pool applicability is noted where relevant. ## When to Use - Code needs a **non-serializable resource** on workers (database connections, COM objects, loaded shared libraries, file handles) - Code needs **expensive one-time setup** per worker (large object construction, data loading) that should not repeat every parfor iteration - Code needs **paths or environment variables** set on workers - User has existing code using **spmd for side-effect setup** before parfor (anti-pattern — help them modernise) - User sees errors about objects not being serializable when passed to parfor ## When NOT to Use - Data already in client memory used in a single parfor loop (MATLAB broadcasts it automatically — Constant adds complexity for no benefit in this case) - Choosing between process and thread pools

What's inside
Steps it walks through
  1. When to Use
  2. When NOT to Use
  3. Decision Framework
  4. The spmd Anti-Pattern
  5. What it looks like
  6. Why it's fragile
  7. How to modernise
  8. Patterns
  9. Pattern 1: Loading data from a file for use in parfor
  10. Pattern 2: Shared library (non-serializable, needs cleanup)
  11. Pattern 3: One-shot setup with parfevalOnAll (no cleanup needed)
  12. Pattern 4: Database connection (use createConnectionForPool)
  13. Recognising When pool.Constant Is Needed
  14. Common Mistakes
Ships with 1 file
  • manifest.yaml
More from matlab-agentic-toolkit
All skills →
About this skill
What does the matlab-setup-worker-state skill do?

Set up worker environment and per-worker state for parallel pools. Use when code needs paths, environment variables, database connections, loaded libraries, or expensive objects available on workers before parfor/parfeval runs. Teaches parallel.pool.Constant, parfevalOnAll, and parpool name-value pairs. Also use when refactoring existing code that uses spmd for side-effect setup (an anti-pattern). Triggers: worker setup, pool constant, per-worker state, non-serializable, loadlibrary on workers, database connection parfor, addpath workers, spmd before parfor, worker environment, reduce parfor o

How do I install it?

Run `npx skills add matlab/matlab-agentic-toolkit --skill matlab-setup-worker-state --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From matlab/matlab-agentic-toolkit, a repository with 868 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going