python-script

Solid

Write standalone single-file Python scripts using PEP 723 inline metadata and uv. Use when creating a quick CLI script that needs dependencies without a full project.

Data & Documents 4 stars 1 forks Updated yesterday MIT

Install

View on GitHub

Quality Score: 80/100

Stars 20%
23
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# PEP 723 Standalone Python Scripts Write single-file Python CLI scripts with inline dependency metadata (PEP 723) executed via `uv run` — no virtualenv, no `pyproject.toml`, no project scaffolding required. ## When to Use - Agent scratch scripts (store in `.agents/tmp/`). - Any situation where a full Python project is overkill. - Quick automation, data processing, or one-off CLI tools. ## Template Base every script on [script.py](references/script.py). Key elements: 1. **Shebang + PEP 723 block** (must be at the top of the file): ```python #!/usr/bin/env -S uv run --quiet --script # /// script # requires-python = ">=3.14" # dependencies = [ # "rich>=15.0.0", # "typer>=0.27.0", # ] # /// ``` 1. **CLI framework**: Use `Typer` with `Rich` for argument parsing and formatted output. 1. **Dual consoles**: `Console()` for stdout results, `Console(stderr=True)` for logs/errors. 1. **Typed arguments**: Use `Annotated[..., typer.Argument/Option(...)]` with help text. 1. **Error handling**: Catch exceptions at the CLI boundary with `err.print_exception(show_locals=False)` and exit via `raise typer.Exit(code=1) from None`; never render locals because they can contain secrets. ## Execution ```bash # Direct execution (after chmod +x) ./script.py input.txt # Or via uv explicitly uv run script.py input.txt --verbose ``` `uv` resolves and caches the declared dependencies automatically — no manual install step. For a durable script, commit its ...

Details

Author
fmind
Repository
fmind/dotfiles
Created
4 months ago
Last Updated
yesterday
Language
Go
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category