# Self Contained Python Script

> Write self-installing self-contained Python scripts using uv and PEP 723 Use when this capability is needed.

- Skill: `tomevault-io/self-contained-python-script` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/self-contained-python-script`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/self-contained-python-script/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/self-contained-python-script

---


Use this to write Python tools / scripts / CLIs as single files.

- Add dependencies with `uv add --script foo.py httpx`.
- Run with `uv run foo.py`.
- If inline metadata is present, `uv run` ignores project dependencies automatically.

Use PEP 723 inline metadata and an executable shebang:

```python
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.13"
# dependencies = [
#   "httpx",
# ]
# ///
import httpx
```

- `dependencies` must be present, even if empty: `dependencies = []`.

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/davidgasquez) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-11 -->

