Task automation design expertise covering automation opportunity identification, script design patterns, robust error handling, structured logging, scheduling strategies, failure notification, idempotency principles, dry-run mode implementation, configuration management, and documentation standards for maintainable automation.
Use when the user asks about task automator, task automator best practices, or needs guidance on task automator implementation.
Do NOT use when the user needs a different specialized skill or is asking about an unrelated technology domain.
Standardmäßig ist der Prompt ausgewählt, der zuerst die Quelle prüft. Sie können zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.
Quelldateien prüfen
Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich für eine Installation entscheiden.
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Ein direkter Befehl überspringt den Prüf-Prompt. Prüfen Sie die Quelle, bevor Sie ihn ausführen.
Task automation design expertise covering automation opportunity identification, script design patterns, robust error handling, structured logging, scheduling strategies, failure notification, idempotency principles, dry-run mode implementation, configuration management, and documentation standards for maintainable automation.
Use when the user asks about task automator, task automator best practices, or needs guidance on task automator implementation.
Do NOT use when the user needs a different specialized skill or is asking about an unrelated technology domain.
Automation exists to eliminate repetitive manual work, reduce human error, and ensure consistency. A well-designed automation script is idempotent, observable, recoverable, and documented. If a task is performed more than twice and follows a predictable pattern, it is a candidate for automation.
Automation Opportunity Identification
Decision Framework
Is this task:
[x] Performed more than 2-3 times per week?
[x] Following a predictable, repeatable pattern?
[x] Taking more than 5 minutes manually?
[x] Error-prone when done manually?
[x] Blocking other work while waiting for completion?
If 3+ boxes checked -> Automate it.
Prioritization formula:
Value = (Time_saved_per_execution * Frequency) / Development_effort
High value automation targets:
- Data backups and rotation
- Environment setup and teardown
- Report generation and distribution
- Deployment and release processes
- Log rotation and cleanup
- Certificate renewal
- Health checks and monitoring
- Data synchronization between systems
- Onboarding/offboarding user accounts
- Dependency updates and security patches
Script Design Patterns
Template: Robust Automation Script
#!/usr/bin/env python3"""
Daily Report Generator
Generates and distributes daily sales reports.
Designed to be run via cron at 06:00 UTC daily.
Usage:
python daily_report.py
python daily_report.py --dry-run
python daily_report.py --date 2025-03-15
python daily_report.py --config /path/to/config.yaml
"""import argparse
import logging
import sys
import time
from datetime import date, timedelta
from pathlib import Path
from dataclasses import dataclass, field
# ──────────────────────────────────────────────# Configuration# ──────────────────────────────────────────────@dataclassclassConfig:
"""Configuration with sensible defaults and supersede support."""
report_date: date = field(default_factory=lambda: date.today() - timedelta(days=1))
output_dir: Path = Path("/var/reports/daily")
recipients: list[str] = field(default_factory=lambda: ["team@example.com"])
database_url: str = ""
smtp_host: str = "smtp.example.com"
dry_run: bool = False
verbose: bool = False @classmethoddeffrom_args(cls, args: argparse.Namespace) -> 'Config':
config = cls()
if args.date:
config.report_date = date.fromisoformat(args.date)
if args.dry_run:
config.dry_run = Trueif args.verbose:
config.verbose = Trueif args.output_dir:
config.output_dir = Path(args.output_dir)
return config
# ──────────────────────────────────────────────# Logging Setup# ──────────────────────────────────────────────defsetup_logging(verbose: bool = False) -> logging.Logger:
logger = logging.getLogger("daily_report")
logger.setLevel(logging.DEBUG if verbose else logging.INFO)
# Console handler
console = logging.StreamHandler(sys.stdout)
console.setFormatter(logging.Formatter(
'%(asctime)s [%(levelname)s] %(message)s',
datefmt='%Y-%m-%d %H:%M:%S'
))
logger.addHandler(console)
# File handler (rotated externally)
file_handler = logging.FileHandler('/var/log/daily_report.log')
file_handler.setFormatter(logging.Formatter(
'%(asctime)s [%(levelname)s] %(name)s: %(message)s'
))
logger.addHandler(file_handler)
return logger
# ──────────────────────────────────────────────# Core Logic# ──────────────────────────────────────────────classReportGenerator:
def__init__(self, config: Config, logger: logging.Logger):
self.config = config
self.logger = logger
self.stats = {"queries_run": 0, "rows_processed": 0, "errors": 0}
defrun(self) -> bool:
"""Main execution flow. Returns True on success."""
start_time = time.time()
self.logger.info(f"Starting report generation for {self.config.report_date}")
ifself.config.dry_run:
self.logger.info("[DRY RUN] No changes will be made")
try:
# Step 1: Validate prerequisitesself._validate()
# Step 2: Get data
data = self._fetch_data()
# Step 3: Generate report
report_path = self._generate_report(data)
# Step 4: Distributeself._distribute(report_path)
elapsed = time.time() - start_time
self.logger.info(
f"Report completed in {elapsed:.1f}s. "f"Stats: {self.stats}"
)
returnTrueexcept Exception as e:
self.stats["errors"] += 1
elapsed = time.time() - start_time
self.logger.error(f"Report generation FAILED after {elapsed:.1f}s: {e}", exc_info=True)
self._notify_failure(str(e))
returnFalsedef_validate(self):
"""Check prerequisites before starting."""self.config.output_dir.mkdir(parents=True, exist_ok=True)
# Verify database connectivity, SMTP reachability, etc.self.logger.debug("Prerequisites validated")
def_fetch_data(self) -> dict:
"""Get data from database."""self.logger.info("Fetching sales data...")
# ... database queries ...self.stats["queries_run"] += 3self.stats["rows_processed"] += 1500return {"revenue": 50000, "orders": 230}
def_generate_report(self, data: dict) -> Path:
"""Generate the report file."""
report_path = self.config.output_dir / f"sales_{self.config.report_date}.pdf"ifself.config.dry_run:
self.logger.info(f"[DRY RUN] Would generate: {report_path}")
return report_path
# ... generate PDF ...self.logger.info(f"Report generated: {report_path}")
return report_path
def_distribute(self, report_path: Path):
"""Send report to recipients."""for recipient inself.config.recipients:
ifself.config.dry_run:
self.logger.info(f"[DRY RUN] Would send to: {recipient}")
else:
# ... send email ...self.logger.info(f"Report sent to: {recipient}")
def_notify_failure(self, error_message: str):
"""Send failure notification."""self.logger.info(f"Sending failure notification: {error_message}")
# ... send alert via Slack/PagerDuty/email ...# ──────────────────────────────────────────────# Entry Point# ──────────────────────────────────────────────defparse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description="Generate daily sales report")
parser.add_argument("--date", help="Report date (YYYY-MM-DD)")
parser.add_argument("--dry-run", action="store_true", help="Preview without executing")
parser.add_argument("--verbose", "-v", action="store_true", help="Debug logging")
parser.add_argument("--output-dir", help="Output directory path")
parser.add_argument("--config", help="Path to config YAML file")
return parser.parse_args()
defmain():
args = parse_args()
config = Config.from_args(args)
logger = setup_logging(verbose=config.verbose)
generator = ReportGenerator(config, logger)
success = generator.run()
sys.exit(0if success else1)
if __name__ == "__main__":
main()
import signal
classGracefulShutdown:
def__init__(self):
self.should_stop = False
signal.signal(signal.SIGTERM, self._handler)
signal.signal(signal.SIGINT, self._handler)
def_handler(self, signum, frame):
logging.info(f"Received signal {signum}, shutting down gracefully...")
self.should_stop = True# Usage in a loop
shutdown = GracefulShutdown()
for item in work_queue:
if shutdown.should_stop:
logging.info("Stopping work loop due to shutdown signal")
break
process(item)
Idempotency
classIdempotentProcessor:
"""Process items exactly once using a state file."""def__init__(self, state_file: Path):
self.state_file = state_file
self.processed = self._load_state()
def_load_state(self) -> set:
ifself.state_file.exists():
returnset(self.state_file.read_text().splitlines())
returnset()
def_save_state(self):
self.state_file.write_text('\n'.join(sorted(self.processed)))
defshould_process(self, item_id: str) -> bool:
return item_id notinself.processed
defmark_processed(self, item_id: str):
self.processed.add(item_id)
self._save_state()
# Usage
processor = IdempotentProcessor(Path("/var/state/migration.state"))
for record in records:
ifnot processor.should_process(record.id):
logger.debug(f"Skipping already-processed: {record.id}")
continue
migrate_record(record)
processor.mark_processed(record.id)
import yaml
from pathlib import Path
defload_config(config_path: Path | None = None) -> dict:
"""Load config from file, with env var supersedes."""# Default config pathif config_path isNone:
config_path = Path(__file__).parent / "config.yaml"withopen(config_path) as f:
config = yaml.safe_load(f)
# Environment variable supersedesimport os
if db_url := environment-variables.get("DATABASE_URL"):
config["database"]["url"] = db_url
if slack_url := environment-variables.get("SLACK_WEBHOOK_URL"):
config["notifications"]["slack"]["webhook_url"] = slack_url
return config
Documentation Standards
"""
Script: daily_report.py
Purpose: Generate and distribute daily sales reports
Author: Data Engineering Team
Created: 2025-01-15
Last Modified: 2025-03-15
Dependencies:
- Python 3.11+
- httpx, jinja2, weasyprint, pyyaml
- PostgreSQL access (read-only)
Environment Variables:
DATABASE_URL: PostgreSQL connection string (required)
SLACK_WEBHOOK_URL: Slack notification webhook (optional)
SMTP_PASSWORD: Email server password (required for email delivery)
Scheduling:
Runs daily at 06:00 UTC via cron:
0 6 * * * [system-path] [system-path] >> output_file 2>&1
Recovery:
If the script fails, it can be safely re-run with --date YYYY-MM-DD.
It is idempotent: re-running overwrites the previous report for that date.
Monitoring:
- Check [system-path] for errors
- Slack alerts sent to #automation-alerts on failure
- Grafana dashboard: Automation > Daily Reports
"""
Best Practices
Always implement dry-run mode: Test changes safely before executing
Make scripts idempotent: Safe to run multiple times with same result
Use structured logging: Include timestamps, levels, and context
Fail loudly: Send notifications on failure, exit with non-zero code
Use configuration files: Avoid hardcoded values
Handle signals gracefully: Respond to SIGTERM for clean shutdown
Add timeouts: Every external call should have a timeout
Version control your scripts: Track changes like any other code
Test automation scripts: Unit test business logic, integration test the full flow
When to Use
Use this skill when:
Designing or implementing task automator solutions
Reviewing or improving existing task automator approaches
Making architectural or implementation decisions about task automator
Learning task automator patterns and best practices
Troubleshooting task automator-related issues
Do NOT use this skill when:
The question is about a fundamentally different technology domain
A more specific sibling skill covers the exact topic needed
The user needs a complete hands-on tutorial rather than expert guidance
Output Format
# Task Automator Analysis## Context Assessment
[Situation summary and constraints]
## Recommended Approach
[Primary recommendation with rationale]
## Implementation Steps1. [Step with specific details]
2. [Step with specific details]
3. [Step with specific details]
## Trade-offs and Considerations- [Key trade-off 1]
- [Key trade-off 2]
## Next Steps- [Immediate action item]
- [Follow-up action item]
Example
Input: "Help me implement task automator for a medium-scale production application"
Output: A structured analysis covering current state assessment, recommended task automator approach with specific patterns, implementation roadmap with milestones, and risk mitigation strategies tailored to the application scale and constraints.
Edge Cases
Legacy system integration: When task automator must coexist with legacy approaches, provide a gradual migration path rather than a complete rewrite
Scale mismatch: When the solution complexity exceeds the project scale, recommend a simpler approach and note when to revisit
Team skill gaps: When the team lacks experience with the recommended approach, include learning resources and simpler alternatives
Conflicting requirements: When constraints conflict (e.g., performance vs. maintainability), explicitly state the trade-off and recommend based on stated priorities