polling-best-practices
Polling Best Practices
A guidance-style skill for automating long-running, asynchronous tasks using a cron-compatible polling pattern. When a task cannot complete synchronously (e.g., a CLI command that triggers a background job and returns a job ID), this skill guides the agent through: (1) deciding whether polling is appropriate, (2) pre-flight confirmation with the user, (3) setting up a task directory, (4) writing the polling script, (5) launching the background job, and (6) monitoring it to completion or timeout.
Language: All confirmation messages to the user should be written in the user's current session language (check the session language — if the user is writing in Chinese, reply in Chinese; if in English, reply in English).
1. Suitability Checklist
Before proceeding, the agent must answer:
✅ Suitable for Polling — if ALL of the following are true:
- The target command/API returns immediately with a process ID, job ID, artifact ID, or similar handle
- There is a clear, machine-parseable completion condition (e.g., a JSON/TOML field, a status string, an exit code, a file appearing)
- The condition can be checked by re-running the same command or a lightweight query command
- The wait time is predictable (typically 1–15 minutes)
- No real-time user interaction is needed during execution