PufferLib RL Guide
Version-aware guidance for PufferLib: wrapping environments, vectorization, PuffeRL training plans, and safe checkpoint review across the 3.0.0 release and the 4.0 source line.
Dev & CodingAdvanced★ 33,030⑂ 3,248AI score 8/10Last updated: Aug 9, 2026
What it does
PufferLib speeds up reinforcement-learning simulation and training. This skill keeps you on one explicit version profile at a time — the published PyPI release 3.0.0 versus the redesigned upstream 4.0 source — so you never mix incompatible imports, configs, and CLI flags.
- Correct wrapping of Gymnasium / PettingZoo environments via
GymnasiumPufferEnvandPettingZooPufferEnv - Vectorization workflow: start on
Serial, then move toMultiprocessing, with a checklist for shapes, masks, and agent slots - Policy contracts for Torch modules, recurrent composition, and
nativize_dtypeusage - A dry-run workflow that emits a strict-JSON training plan and validates it before anything executes
- Checkpoint inspection by hash and metadata only, never calling
torch.load - Hard rules for W&B / Neptune credentials: named env vars only, never in args, configs, or logs
Every bundled CLI is standard-library only, CPU-only, synthetic, and network-free.
Who it's for
- RL researchers and engineers running large-scale environment simulation with PufferLib
- Teams porting existing Gymnasium or PettingZoo environments into PufferLib
- Security-conscious setups that must vet third-party checkpoints, ROMs, or environment packages
- MLOps folks who care about reproducibility: separate seeds, pinned commits, committed lockfiles
Examples
- Validate an environment contract: run
python3 scripts/env_contract_validator.py --steps 64 --episodes 8 --seed 42to check spaces, dtypes, finite rewards, seeding, and theterminatedvstruncateddistinction. - Plan before you train:
scripts/train_template.py --profile pypi-3.0.0 --device cpu --total-timesteps 10000emits a config plan without launching, andvalidate_plan.pyrejects mixed-version options, unbounded resources, dotted env paths, and coupled train/eval seeds. - Vet a downloaded checkpoint:
scripts/inspect_checkpoint.py checkpoint.pt --expected-sha256 ...hashes and classifies the file without unpickling, so you only load it in a sandbox after the digest matches.
· · · Install guide · · ·
Install in the Claude app (no terminal)
- Download the ZIP with the button below.
- In Claude, open Settings → Capabilities and turn on 'Code execution and file creation'. (one time)
- Go to Customize → Skills → + → 'Upload a skill' and upload the ZIP.
Install in Claude Code
Let Claude do it — paste this into Claude Code
Install the skill I found on Claude Skill Mart. Copy the skills/pufferlib folder from the GitHub repo K-Dense-AI/scientific-agent-skills into my ~/.claude/skills/pufferlib/. When it's done, tell me in one line what this skill can do.
Install with a command instead
git clone https://github.com/K-Dense-AI/scientific-agent-skills.git /tmp/scientific-agent-skills && mkdir -p ~/.claude/skills && cp -r /tmp/scientific-agent-skills/skills/pufferlib ~/.claude/skills/⚠ This is a third-party skill. Check the source repository before installing.
- Open a terminal and clone the skills repository:
git clone https://github.com/K-Dense-AI/scientific-agent-skills.git - Create the Claude Code skills directory if it does not exist:
mkdir -p ~/.claude/skills - Copy just the
pufferlibskill folder:cp -r scientific-agent-skills/skills/pufferlib ~/.claude/skills/ - Confirm Python 3.10 or newer with
python3 --version. The bundled scripts need no extra packages. - Restart Claude Code and ask something like "validate my PufferLib environment" to trigger the skill.
- For real training, install PufferLib in its own pinned virtualenv:
uv venv --python 3.11thenuv add --exact "pufferlib==3.0.0". Because the sdist compiles native code, do the resolve/build inside a sandbox with no credentials mounted.
View source on GitHub ↗License: MIT