Skip to content
Back to skills

Mesa

ASecurity

"Use Mesa for agent-based simulation models, spatial ABM

  • 247 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 8, 2026
datapythongobashapifrontendperformance

Works with

  • api

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 20 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill mesa --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Mesa?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Mesa
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-mesa/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-mesa)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: mesa
description: "Use Mesa for agent-based simulation models, spatial ABM
  environments, experiment data collection, scenarios, and Solara visualization
  workflows."
disable-model-invocation: true
metadata:
  disco-role: operating
license: Apache 2.0
---

# Mesa

Use this repo skill when a task involves **Mesa**, the Python agent-based modeling framework: building ABM models, managing agents, adding spaces, collecting outputs, running scenarios, or creating browser/notebook visualizations.

## Install and import

Mesa requires Python 3.12 or newer in this snapshot.

```bash
python -m pip install -U mesa
# For Mesa 4 pre-releases when a task depends on APIs from this skill:
python -m pip install -U --pre mesa
# Recommended optional stacks:
python -m pip install -U "mesa[network]"  # Network spaces
python -m pip install -U "mesa[viz]"      # Solara/matplotlib/altair visualization
python -m pip install -U "mesa[rec]"      # network + viz recommended extras
```

Minimal import check:

```python
import mesa
from mesa import Agent, DataCollector, Model
from mesa.discrete_space import OrthogonalMooreGrid
```

Run [scripts/check_mesa_install.py](scripts/check_mesa_install.py) for a safe JSON probe of the installed package and optional extras.

## Route by task

| Task intent | Read |
| --- | --- |
| Define `Model` and `Agent` classes, create agents, activate `AgentSet`s, seed RNGs, schedule events, run time, remove agents | [model-core](sub-skills/model-core/SKILL.md) |
| Choose grids/cells/network/Voronoi/continuous spaces, move cell agents, use property layers, debug capacity or coordinates | [spaces](sub-skills/spaces/SKILL.md) |
| Collect model/agent/table outputs, create DataFrames, run scenarios, use experimental recorders/actions/states/signals | [analysis-experiments](sub-skills/analysis-experiments/SKILL.md) |
| Build or debug `SolaraViz`, `SpaceRenderer`, component builders, portrayal styles, plots, user parameters, visualization extras | [visualization](sub-skills/visualization/SKILL.md) |

## High-signal Mesa rules

- In Mesa 4, `Agent.__init__(model)` automatically registers the agent and assigns `unique_id`. Do not reassign or manually mutate `model.agents`.
- `Model(rng=...)` creates both `model.rng` and `model.random`; pass `rng` for reproducibility unless a `Scenario` instance already owns the RNG.
- `Model.step()` is scheduled by default every 1.0 time units; use `run_for()` or `run_until()` to process the event queue.
- Prefer `model.agents.do(...)`, `shuffle_do(...)`, `map(...)`, `select(...)`, `groupby(...)`, and `agg(...)` over custom scheduler objects.
- For new spatial models, use `mesa.discrete_space` or `mesa.experimental.continuous_space`, not legacy `mesa.space` APIs.
- `DataCollector` supports model, agent, agent-type, and table outputs; avoid lambdas when the model must be pickle-safe.
- `SolaraViz` re-creates models from `model_params`; model constructors must accept keyword arguments matching those parameter keys.

## Optional dependency choices

- Core modeling, data collection, grids, Voronoi, and continuous spaces: base `mesa` install.
- Network examples or `Network` default layouts: install `mesa[network]` or pass your own graph/layout stack.
- Browser/notebook visualization: install `mesa[viz]` or `mesa[rec]`.
- Example-library and verification-style runs: `mesa[examples]` includes recommended extras and pytest.
- Browser end-to-end checks need additional frontend/browser tooling and are not required for ordinary modeling tasks.

## References and checks

- [references/repo-provenance.md](references/repo-provenance.md) records the source snapshot used to create this skill; read it before deciding whether to refresh the skill for a different checkout or Mesa version.
- [references/examples-index.md](references/examples-index.md) maps classic Mesa example patterns to the owning sub-skills.
- [references/troubleshooting.md](references/troubleshooting.md) covers cross-cutting install, version, optional-extra, and workflow-selection issues.
- Each sub-skill links its own API reference, workflows, troubleshooting guide, and smoke scripts.

## Avoid this skill when

- The task is only generic Python, pandas, NumPy, NetworkX, Matplotlib, Altair, or Solara usage without Mesa model objects or Mesa visualization components.
- The task asks for a non-Mesa ABM framework such as NetLogo, Repast, MASON, Agents.jl, or a custom simulator.
- The task is benchmark-scale performance tuning or browser automation infrastructure; this skill records those as long-tail or optional areas, not primary guidance.

Files in this skill

  • SKILL.md4.5 KB
  • references/examples-index.md4.4 KB
  • references/repo-provenance.md2.1 KB
  • references/repo-routing-metadata.json396 B
  • references/troubleshooting.md3.8 KB
  • scripts/check_mesa_install.py6 KB
  • sub-skills/analysis-experiments/SKILL.md2.2 KB
  • sub-skills/analysis-experiments/references/api-reference.md16.2 KB
  • sub-skills/analysis-experiments/references/troubleshooting.md11.3 KB
  • sub-skills/analysis-experiments/references/workflows.md12.4 KB
  • sub-skills/analysis-experiments/scripts/datacollector_smoke.py4.5 KB
  • sub-skills/analysis-experiments/scripts/scenario_smoke.py5.9 KB
  • sub-skills/model-core/SKILL.md1.8 KB
  • sub-skills/model-core/references/api-reference.md7.4 KB
  • sub-skills/model-core/references/troubleshooting.md2.4 KB
  • sub-skills/model-core/references/workflows.md5.3 KB
  • sub-skills/model-core/scripts/mesa_model_smoke.py6.2 KB
  • sub-skills/spaces/SKILL.md2.3 KB
  • sub-skills/spaces/references/api-reference.md10.8 KB
  • sub-skills/spaces/references/troubleshooting.md4.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.