Python Playground
Testing & Qualitypython-playgroundPython Playground is an Agent Skill for testing & quality published in the pydantic/monty repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Run and test Python code in a dedicated playground directory. Use when you need to execute Python scripts, test code snippets, investigate CPython behavior, or experiment with Python without affecting the main codebase.
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Inspect the Agent Skill at https://github.com/pydantic/monty/blob/HEAD/.claude/skills/python-playground/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/python-playground, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Python Playground
Run Python code in an isolated playground directory for testing and experimentation.
Instructions
- First, ensure the playground directory exists. If the
playgrounddirectory doesn't already exist, runmkdir playground. - Use the Write tool to create the Python file at
playground/test.py - Run with:
uv run playground/test.pyto test cpython behavior orcargo run -- playground/test.pyto test monty behavior
IMPORTANT: Use separate tool calls for each step - do NOT chain commands with &&. This allows the pre-approved commands to work without prompting.
Example workflow
Step 1 - Create directory if it doesn't already exist (Bash, already allowed):
mkdir playground
Step 2 - Write code (use Write tool, not cat):
Write to playground/test.py:
def foo():
raise ValueError('test')
foo()
Step 3 - Run script (Bash, already allowed):
uv run playground/test.py
Guidelines
- The
playground/directory is gitignored - Use a different file name for each test you want to run, give the files recognizable names like
test_value_error.py - Use
uv run ...to run scripts (uses project Python) - Or,
cargo run -- ...to run scripts using Monty - Use Write tool for creating files (avoids permission prompts)
- Run mkdir and uv as separate commands (not chained)
- do NOT delete files from playground after you've finished testing