Skip to content
Back to skills

Spaces Data

ASecurity

"Design Gymnasium action and observation spaces, validate samples,

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

Works with

  • api

Security analysis

A100/100

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

Scanned September 8, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Spaces Data?

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

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

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: spaces-data
description: "Design Gymnasium action and observation spaces, validate samples,
  flatten/unflatten data, serialize JSONable batches, and debug dtype/shape
  mismatches."
disable-model-invocation: true
metadata:
  disco-role: operating
license: MIT
---

# Gymnasium Spaces and Data Contracts

Use this sub-skill when a task involves choosing Gymnasium action or observation spaces, validating samples with `contains`, seeding or sampling spaces, flattening nested data for model inputs, unflattening model vectors back to structured observations/actions, or serializing space samples.

## Start Here

- For constructor choices and data contracts, use `references/space-design.md` before modifying an environment's `action_space` or `observation_space`.
- For `flatdim`, `flatten_space`, `flatten`, `unflatten`, `to_jsonable`, and `from_jsonable`, use `references/flattening-and-json.md`.
- For `Box.contains` surprises, integer starts, nested flatten shape mismatches, dynamic spaces, and wrapper space updates, use `references/troubleshooting.md`.
- To smoke-test the local Gymnasium install and demonstrate the core contract, run `python sub-skills/spaces-data/scripts/space_contract_smoke.py --help` and then `python sub-skills/spaces-data/scripts/space_contract_smoke.py` from the root Gymnasium skill directory.

## Scope Boundaries

- Use `../environment-api/SKILL.md` for custom `Env` lifecycle, `reset`/`step`, registration, `check_env`, and seeding an environment through `reset(seed=...)`.
- Use `../wrappers-recording/SKILL.md` when a wrapper changes `observation_space`, `action_space`, observations, actions, rewards, rendering, or recording behavior.
- Use `../vectorization/SKILL.md` for batched/vector spaces, `gym.vector` utilities, `single_observation_space`, `single_action_space`, and vector wrapper space transforms.

## Minimum Correct Patterns

```python
import numpy as np
from gymnasium import spaces

observation_space = spaces.Dict({
    "position": spaces.Box(low=-1.0, high=1.0, shape=(2,), dtype=np.float32),
    "inventory": spaces.Tuple((spaces.Discrete(5), spaces.MultiBinary(3))),
})

observation = observation_space.sample()
assert observation_space.contains(observation)
```

```python
from gymnasium.spaces import utils as space_utils

flat = space_utils.flatten(observation_space, observation)
restored = space_utils.unflatten(observation_space, flat)
assert observation_space.contains(restored)
```

Keep runtime guidance self-contained. Do not depend on Gymnasium source, tests, examples, or documentation paths at runtime.

Files in this skill

  • SKILL.md2.5 KB
  • references/flattening-and-json.md7.8 KB
  • references/space-design.md8.9 KB
  • references/troubleshooting.md7.7 KB
  • scripts/space_contract_smoke.py8.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.