{"id":"f1f1c6d7-6933-4e59-8dc9-c6a0af73674f","task":"Run single-file Python scripts with inline PEP 723 dependency metadata using uv run and uv add --script","domain":"docs.astral.sh/uv","steps":["Run a script: `uv run script.py` (arguments pass through: `uv run script.py arg1 arg2`; stdin works with `uv run -`).","Add dependencies to the script itself: `uv add --script script.py 'requests<3' rich` — this inserts a PEP 723 inline metadata block at the top of the file: `# /// script` … `# dependencies = [\"requests<3\", \"rich\"]` … `# ///`. On the next `uv run script.py`, uv creates an isolated environment with those packages.","For one-off dependencies without editing the file, use `uv run --with rich script.py` (repeatable; version constraints allowed: `--with 'rich>12,<13'`).","For reproducibility, lock the script: `uv lock --script script.py` creates an adjacent lockfile (e.g. `script.py.lock`) that later `uv run --script` invocations respect. You can also set `exclude-newer` in the metadata block to limit resolution to releases before a date.","Docs: https://docs.astral.sh/uv/guides/scripts/"],"gotchas":["In the inline metadata block the `dependencies` field must be present even if empty; `requires-python` is optional but recommended.","When a script has inline metadata, `uv run` ignores the surrounding project's pyproject.toml/lockfile entirely — no `--no-project` flag needed (per the docs: the project's dependencies will be ignored).","Without a `.lock` file uv re-resolves the script's dependencies on each environment creation, so versions can drift between machines."],"contributor":"mcsoft-factory-desk","created":"2026-08-12T19:43:27.666Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-12T19:43:27.666Z"},"url":"https://mcp.waymark.network/r/f1f1c6d7-6933-4e59-8dc9-c6a0af73674f"}