record counts: processed/created/updated/skipped/failed
Also include a final summary log line.
Verification requirements
For non-trivial work, add:
unit tests for mapping/transform logic
at least one test for pagination or retry behavior (mocked)
a “dry-run” CLI flag (prints intended writes)
Output format when writing code
Provide a small directory layout
Explain how to configure env vars
Include exact commands to run (and test)
1---2name: superpowers-python-automation3description: Python Automation Skill4---56# Python Automation Skill78This skill provides concrete Python patterns to implement robust REST API automations.910## When to use this skill11- Python scripts that call one or more REST APIs12- ETL jobs, sync tools, webhook handlers13- CLI tools or small services that integrate external systems1415## Preferred stack (defaults)16- HTTP client: **httpx** (preferred) or requests17- Config: env vars + `.env` (optional) with pydantic-settings if appropriate18- Logging: stdlib `logging` with structured-ish fields19- Testing: pytest (+ respx for httpx mocking when useful)2021If the project already uses different tools, follow project conventions.2223---2425## Reference architecture (small but scalable)26- `client.py`: API client wrapper (auth headers, retries, pagination helpers)27- `models.py`: typed payload models (dataclasses or pydantic)28- `sync.py`: orchestration logic (fetch -> transform -> upsert)29- `main.py`: CLI entrypoint30- `tests/`: unit tests for transform + client behavior3132## HTTP rules (mandatory)33- Always set timeouts (connect + read)34- Centralize request sending in one function so retries/logging are consistent35- Never log secrets (Authorization headers, tokens)3637### Retry policy guidance38Retry on:39- network errors/timeouts40- 429 (respect Retry-After when present)41- 500–59942Optional: 408, and 409 only if operation is safe and semantics known4344Do NOT retry on:45- most 400–499 (unless explicitly safe)4647### Timeouts48- Set explicit timeouts; do not rely on defaults.49- Use smaller connect timeout; moderate read timeout.5051---5253## Pagination patterns54Support at least one helper that can handle:55- `next` URL in response56- cursor token in response57- page/limit parameters5859Add a hard stop:60- max pages OR max items OR max elapsed time6162---6364## Idempotency patterns (Python)65Choose and document:66- Use an `Idempotency-Key` header when supported67- Upsert using a stable `external_id`68- Persist a lightweight state store:69 - simplest: SQLite file (recommended for OSS)70 - alternative: JSONL log + compaction7172Minimum: ensure repeated runs don’t create duplicates.7374---7576## Observability (Python)77Minimum logs should include:78- `run_id`79- request: method, url/path, status_code, elapsed_ms, attempt80- record counts: processed/created/updated/skipped/failed8182Also include a final summary log line.8384---8586## Verification requirements87For non-trivial work, add:88- unit tests for mapping/transform logic89- at least one test for pagination or retry behavior (mocked)90- a “dry-run” CLI flag (prints intended writes)9192---9394## Output format when writing code95- Provide a small directory layout96- Explain how to configure env vars97- Include exact commands to run (and test)
Run npx skillmds@latest add phoroth/superpowers-python-automation in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Python Automation Skill It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
phoroth (@phoroth) published this skill. Their other Agent Skills are listed on their SkillMD profile.