home / skills / vaayne / agent-kit / python-script

python-script skill

/skills/python-script

This skill helps engineers design and run robust Python automation with structured logging, safety checks, and reproducible workflows.

npx playbooks add skill vaayne/agent-kit --skill python-script

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
1.3 KB
---
name: python-script
description: Create robust Python automation with full logging and safety checks. Use when tasks need complex data processing, authenticated API work, conditional file operations, or error handling beyond simple shell commands.
---

# Python Scripter

## Overview

Design and run Python scripts with clear requirements, safety checks, and reproducible logging.

## Workflow

1. Confirm inputs, outputs, constraints, and preferred libraries.
2. Identify risky operations and secure explicit approval.
3. Scaffold a script with PEP 723 metadata and structured logging.
4. Lint with `uvx ruff check --fix .agents/scripts/{script_name}.py`.
5. Run with `uv run --script .agents/scripts/{script_name}.py` and monitor logs.
6. Report results, risks encountered, and any follow-up steps.

## Logging requirements

- Log to `.agents/logs/{script_name}.log` and stream to console
- Capture start/end timestamps, parameters, file operations, and errors
- Add `RotatingFileHandler` if logs may grow large

## Template

Read `references/script-template.md` for the full script template.

## Safety practices

- Provide dry-run or rollback paths
- Validate external inputs and API responses
- Use temporary directories for intermediates
- Never run destructive steps without confirmation

Overview

This skill helps you design and run robust Python automation with structured logging, safety checks, and reproducible execution. It is tailored for tasks that require complex data processing, authenticated API interactions, conditional file work, or advanced error handling. The skill provides a clear workflow, logging conventions, and templates to produce maintainable scripts.

How this skill works

You start by confirming inputs, outputs, constraints, and preferred libraries. The skill identifies risky operations and requires explicit approval before destructive actions. It scaffolds a PEP-compliant script with structured logging to both file and console, adds linting and run commands, and surfaces results, risks, and follow-up steps after execution.

When to use it

  • Complex ETL jobs that need validation, retries, and temporary intermediates
  • Authenticated API automation with response validation and rate-limit handling
  • File system changes that must be conditional, reversible, or logged for audit
  • Long-running tasks requiring rotating logs and progress timestamps
  • Scripts that must pass linting and be reproducibly executed by agents

Best practices

  • Confirm inputs, outputs, constraints, and any external dependencies before coding
  • Mark risky operations and require explicit approval or a dry-run flag
  • Log start/end times, parameters, file operations, and all exceptions to file and console
  • Use temporary directories for intermediates and provide rollback or dry-run modes
  • Lint scripts with the recommended command and use RotatingFileHandler for large logs

Example use cases

  • Pull data from an authenticated API, transform it, and write versioned CSVs with full audit logs
  • Batch rename or move files conditionally, with a dry-run report and rollback option
  • Run a scheduled data cleaning pipeline that logs parameters, timing, and errors to a central log store
  • Perform multi-step deployments where each destructive step requires explicit approval and logging

FAQ

How are logs organized and where are they stored?

Logs are written to .agents/logs/{script_name}.log and streamed to the console; use a RotatingFileHandler when logs may grow large.

What safety measures protect destructive actions?

Scripts include dry-run and rollback paths, explicit approval prompts for risky steps, input validation, and use temporary directories for intermediates.