self-contained-python-scripts

Use uv and PEP 723 to write self-installing autocontained Python scripts

⭐0stars🔀0forks📁View on GitHub🕐Updated Jan 7, 2026

When & Why to Use This Skill

This Claude skill streamlines Python development by leveraging uv and PEP 723 to create self-contained, portable scripts. It solves the common 'dependency hell' problem by allowing developers to embed library requirements directly within a single file, ensuring scripts are self-installing and run consistently across different environments without manual virtual environment setup.

Use Cases

  • Portable CLI Tooling: Create and share standalone command-line utilities that automatically manage their own dependencies upon execution.
  • Automated DevOps Scripts: Write robust maintenance or deployment scripts that require specific libraries (like httpx or boto3) without pre-configuring the host environment.
  • Rapid Prototyping: Quickly develop and test Python scripts with external packages while maintaining a clean global environment and avoiding the overhead of manual venv management.
nameself-contained -python-scripts
descriptionUse uv and PEP 723 to write self-installing autocontained Python scripts

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

Using PEP 723 inline metadata, you can create self-contained Python scripts that declare their own dependencies. This allows you to run your scripts in isolated environments without needing to manually set up virtual environments or install dependencies.

To do that, embed the invocation of the uv command right in the shebang line.

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