一键导入
monty
Execute Python code in a secure sandbox using pydantic-monty. Use when running LLM-generated code that should be isolated from filesystem/network access.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Execute Python code in a secure sandbox using pydantic-monty. Use when running LLM-generated code that should be isolated from filesystem/network access.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | monty |
| description | Execute Python code in a secure sandbox using pydantic-monty. Use when running LLM-generated code that should be isolated from filesystem/network access. |
Execute Python code safely without filesystem/network access.
uv run https://raw.githubusercontent.com/zhouzhuojie/monty-skill/main/monty.py "code here"
Note: Since
uv rundownloadsmonty.pyfrom the remote repo, the localfunctions.pydoes not exist by default. If you need external functions, create afunctions.pyfile and pass it with-f.
| Flag | Description |
|---|---|
-f FILE | Path to external functions file (default: functions.py) |
-t SEC | Timeout in seconds |
Define safe functions in functions.py for use in sandboxed code:
import random
def random_numbers(count: int) -> list:
"""Generate n random numbers between 0 and 1."""
return [random.random() for _ in range(count)]
async def fetch(url: str) -> dict:
return {"data": "example"}
If a feature isn't available in the built-ins, you can add your own safe functions to functions.py. Monty will automatically detect and load functions that are called in your code.
Example: Generating random numbers
# functions.py
import random
def random_numbers(count: int) -> list:
"""Generate n random numbers between 0 and 1."""
return [random.random() for _ in range(count)]
def random_int(min_val: int, max_val: int, count: int) -> list:
"""Generate n random integers between min and max (inclusive)."""
return [random.randint(min_val, max_val) for _ in range(count)]
Then use in monty:
uv run https://raw.githubusercontent.com/zhouzhuojie/monty-skill/main/monty.py "result = random_numbers(1000); print(f'Mean: {sum(result)/len(result):.4f}')" -f functions.py
If your external functions need packages like cryptography or requests, use uv run --with:
uv run --with cryptography --with requests https://raw.githubusercontent.com/zhouzhuojie/monty-skill/main/monty.py "encrypt('secret')" -f functions.py
Note: The
--withpackages are only available to your external functions running on the host. The sandboxed code (LLM-generated) still cannot access these packages directly - it must call through your external functions. This maintains the security guarantee.
npx skills add zhouzhuojie/monty-skill
Or manually:
git clone https://github.com/zhouzhuojie/monty-skill.git
cp -r monty-skill ~/.claude/skills/ # Claude
cp -r monty-skill ~/.pi/agent/skills/ # Pi
print, len, str, int, list, dict, rangeSee test_monty.py for comprehensive examples.