/selamy-skills:resilient-pool-refreshfrom selamy-skills
Use when a job refreshes or validates a pool of credentials, tokens, sessions, or connections. Isolate per-item failures, classify terminal (needs human re-auth) versus transient (auto-retry), and alert clearly instead of failing the whole batch silently.
Ships in selamy-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A job that periodically refreshes a pool of items — OAuth tokens, API sessions, certificates, DB connections — must not treat the pool as all-or-nothing. The naive version loops over the pool, lets the first error propagate, and exits non-zero. The scheduler retries the whole batch, exhausts its backoff/retry limit, and ends as one silent failed run — even though most items were fine and only one needed attention. You lose the good refreshes and the signal about the one bad item.
Three properties make a refresh job resilient.
Wrap each item in its own try/except and continue on failure. One item's terminal error must never abort the rest of the pool. Keep the prior good value for an item that fails to refresh — a still-valid token is better than no token — and record which items succeeded.
results = {"ok": [], "needs_human": [], "transient": []}
for item in pool:
try:
new = refresh(item)
store(item, new)
results["ok"].append(item.id)
except TerminalAuthError as e: # do not retry; a human must act
keep_prior_value(item)
results["needs_human"].append((item.id, str(e)))
except TransientError as e: # safe to retry next run / now
keep_prior_value(item)
results["transient"].append((item.id, str(e)))
Not all failures are equal. Decide per error class:
401 Unauthorized, invalid_grant,
refresh_token revoked/reused/expired, account disabled. Do not retry;
surface a clear, actionable alert naming the item and the human action.5xx, timeouts, connection resets, rate limits (honor Retry-After).
Retry with bounded backoff; only escalate if it stays transient too long.Misclassifying terminal as transient burns retries and delays the human; misclassifying transient as terminal pages a human for a blip. Map known error codes explicitly; default unknowns to transient-with-cap so they still surface.
A backoffLimit-exhausted red job with no message is the worst outcome — it
hides which item failed and why. Instead, finish the run and emit a
structured summary: counts of ok / needs-human / transient, and for each
needs-human item the identity and the exact remediation ("re-auth account X").
Make the alert the product of the job, not a stack trace someone has to decode.
Real incident: a credential-refresh CronJob failed silently for ~2.5 days. One
provider's OAuth had hit a terminal invalid_grant (needed human re-auth), but
because the job aborted on first error and surfaced only a red run, nobody knew
which credential or what to do — and the other credentials' refreshes were lost
with it.
A refresh job is done only if: a single item's terminal failure leaves the rest refreshed; terminal vs transient is classified and acted on differently; and a failure produces a human-readable alert naming the item and the fix — not just a non-zero exit.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub selamy-labs/agent-skills --plugin selamy-skills111 skills in this plugin
/adaptive-estimationUse when tracking a slowly-varying latent quantity from noisy measurements with quantifiable uncertainty — a drifting metric, capacity, latency trend, or confidence. Prefer a Kalman-style adaptive estimator over fixed moving averages or static thresholds./adaptive-loop-budgetingUse when an autonomous loop needs explicit limits on attempts, time, cost, tool calls, verification depth, or risk, and a clear stop, continue, yield, or escalate decision./adopt-and-deleteUse when adopting a shared module, library, chart, or service, or doing any consolidation, migration, or refactor that supersedes existing code. The change that adds the replacement must REMOVE what it replaced, in the same atomic change.