python-scripting
npx machina-cli add skill aiskillstore/marketplace/python-scripting --openclawFiles (1)
SKILL.md
1.3 KB
Python Scripting Skill
Creates self-contained Python scripts using uv and PEP 723 inline script metadata.
What This Skill Does
- Creates standalone Python scripts
- Uses PEP 723 inline dependencies
- Sets up argument parsing
- Handles input/output
- Configures reproducible builds
When to Use
- Standalone utility scripts
- One-off automation tasks
- Quick data processing
- CLI tools
- Scripts that need dependencies
Reference Files
references/UV_SCRIPT.template.py- Python script template with PEP 723 metadata
PEP 723 Format
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "requests",
# "rich",
# ]
# ///
Running Scripts
uv run script.py [args]
Dependencies install automatically on first run.
Best Practices
- Use
exclude-newerfor reproducibility - Include docstring with usage examples
- Use argparse for CLI arguments
- Return exit codes (0 success, non-zero error)
- Keep scripts focused on one task
Source
git clone https://github.com/aiskillstore/marketplace/blob/main/skills/89jobrien/python-scripting/SKILL.mdView on GitHub Overview
Creates standalone Python scripts with uv and PEP 723 inline metadata to manage dependencies automatically. It emphasizes reproducible builds, argument parsing, and input/output handling, using a template reference to standardize structure.
How This Skill Works
The script uses a PEP 723 header to declare requires-python and dependencies, wrapped in a shebang that invokes uv run. On first run, uv installs the inline dependencies and executes the script, enabling a self-contained workflow. A reference template at references/UV_SCRIPT.template.py guides users on structure and metadata placement.
When to Use It
- Standalone utility scripts
- One-off automation tasks
- Quick data processing
- CLI tools
- Scripts that need dependencies
Quick Start
- Step 1: Start from references/UV_SCRIPT.template.py and create your script
- Step 2: Add a PEP 723 inline metadata header with requires-python and dependencies
- Step 3: Run the script with uv run script.py [args] and iterate
Best Practices
- Use exclude-newer for reproducibility
- Include docstring with usage examples
- Use argparse for CLI arguments
- Return exit codes (0 success, non-zero error)
- Keep scripts focused on one task
Example Use Cases
- CSV to JSON converter CLI with inline dependencies
- Log file analyzer that outputs a summary
- API data fetcher that formats and displays results
- Data cleaning script for a small dataset
- Folder organizer utility run as a standalone tool
Frequently Asked Questions
Add this skill to your agents