Python Production Script / CLI Generator

作者:promptpacks发布日期:2026-09-21观看:26

Generates a robust Python CLI with argparse, logging, retries, dry-run, and typed config — ideal for automation, data pipelines, and internal ops scripts.

01/ 01

Write a production-grade Python 3.12 CLI that {{TASK, e.g. syncs users from the X API into our Postgres DB}}. Required features: - argparse subcommands (sync, backfill, verify); flags: --config, --dry-run, --limit, --verbose, --since. - pydantic-settings config loaded from env + YAML; fail fast with a clear message on missing config. - structlog JSON logging to stdout; debug logs gated by --verbose; never log tokens or PII (redact emails partially). - httpx with timeout, exponential backoff (tenacity), circuit breaker, and pagination handling; rate-limit aware (respect 429 + Retry-After). - Database writes in batches inside transactions; UPSERT with updated_at; idempotent re-runs keyed on {{natural_key}}. - Graceful SIGINT/SIGTERM: finish current batch, flush metrics, exit 0. - pytest tests with respx and a test database; coverage for retry, pagination, dry-run, and partial-failure scenarios. - pyproject.toml (ruff + mypy strict), Dockerfile, and a README with run examples. Return: file tree, every file's full content, and a short runbook for operators (how to monitor, what alerts to set, how to backfill safely). ================================================================================

自动翻译

自动翻译中…

🔥热搜词

评论0

登录后参与评论

还没有评论,来抢沙发吧