python-uv-scripts

Create self-contained Python scripts with uv inline metadata.

22|1|Updated Oct 24, 2025
One-click install
npx skills add https://github.com/basher83/lunar-claude --skill python-uv-scripts
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-uv-scripts
Source: https://github.com/basher83/lunar-claude/tree/main/plugins/devops/python-uv-tools/skills/python-uv-scripts
Command: npx skills add https://github.com/basher83/lunar-claude --skill python-uv-scripts

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires httpx, rich, typer, keyring, infisical-python, polars, psutil, PyGithub, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill simplifies Python script development by enabling self-contained, reproducible scripts with inline dependency management using uv and PEP 723. It eliminates the need for separate requirements.txt files, making scripts easier to share, execute, and maintain.

Core Features & Use Cases

  • Inline Dependency Management: Define Python dependencies directly within your script using PEP 723 metadata, ensuring consistent execution environments.
  • Self-Executable Scripts: Create scripts that automatically install their dependencies upon first run, streamlining distribution and setup.
  • Best Practices & Patterns: Learn production-ready patterns for security, error handling, CLI applications, and API clients, ensuring robust and maintainable utilities.
  • Use Case: Develop a small utility to check server health. Instead of managing a virtual environment and requirements.txt, embed httpx and rich directly in the script. Share the single file, and anyone can run it without manual setup.

Quick Start

#!/usr/bin/env -S uv run --script

/// script

requires-python = ">=3.11"

dependencies = [

"httpx>=0.27.0",

"rich>=13.0.0",

]

///

import httpx from rich import print

response = httpx.get("https://api.github.com") print(f"[green]Status: {response.status_code}[/green]")

Frequently Asked Questions about python-uv-scripts

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create self-contained Python scripts without managing separate requirements files?

Self-contained Python scripts embed dependencies directly in source code using PEP 723 inline metadata with `# /// script` markers. The `uv` tool reads this metadata and automatically installs dependencies on first run, eliminating the need for `requirements.txt` or virtual environment setup.

What is PEP 723 and how does it work with uv for Python scripting?

PEP 723 defines a standard syntax for embedding script metadata—including Python version requirements and dependencies—directly in Python files using TOML format between `# /// script` markers. The `uv` runtime executes scripts by parsing these markers, resolving dependencies, and running the script in an isolated environment.

Can I convert existing Python scripts to use uv inline dependencies?

Yes. Convert existing scripts by adding a `# /// script` block at the top with your current dependencies listed in TOML format, then add the shebang `#!/usr/bin/env -S uv run --script`. The script remains a single file and works immediately with any `uv` installation.

What are the different modes for managing dependencies in uv scripts?

Mode 1 (Inline Dependencies) embeds dependencies in script metadata; Mode 2 (Project Mode) uses a full `pyproject.toml` for larger projects; Mode 3 (No Dependencies) runs scripts with only the Python standard library. Each mode supports different complexity levels and team workflows.

How do I ensure production-ready security and version pinning in uv scripts?

Pin exact dependency versions in the `# /// script` metadata block using `>=` or exact version specifiers, validate TOML syntax before execution, and follow patterns for error handling and secure credential management using libraries like `keyring` or `infisical-python` for storing sensitive data.

Does uv support building CLI applications and API clients as single-file scripts?

Yes. `uv` scripts support building production CLI applications using `typer` and API clients with `httpx`, rich terminal output with `rich`, and system monitoring with `psutil`—all embedded in one file with inline dependency metadata, making distribution and execution trivial.