running-resumable-sync-jobslisted
Install: claude install-skill AleksandarBisevac/claude-plugins
# Running Resumable Sync Jobs
A sync job is a loop over N items against a service that will fail partway
through. Everything hard about these jobs is what happens on item K of N: what
the process reports, what it wrote down, and what the *next* run does with that.
Get the happy path right and you still ship a job that silently under-collects,
double-applies, or bills for work it never did.
## The exit code is the only thing automation reads
The most common failure: per-item errors are printed as warnings, the loop
`continue`s, and the run finishes by saving state, committing, printing
"Sync complete!" and returning success. A cron wrapper, a CI step, or a
supervisor sees exit 0 and reports a healthy job forever.
```python
# Bad — the warning goes to a log nobody reads; the process says "fine".
for user in users:
try:
mirror(user)
except MirrorError as e:
print(f"Warning: failed to mirror {user}: {e}")
continue
save_state(); commit(); print("Sync complete!")
return 0
# Good — failures are counted and surfaced in the status the caller can act on.
failed = []
for user in users:
try:
mirror(user)
except MirrorError as e:
log.error("failed to mirror %s: %s", user, e)
failed.append(user)
save_state() # keep the work that succeeded
if failed:
log.error("%d of %d targets failed: %s", len(failed), len(users), failed)
return 1 # or 2, if you want "partial" distinguishable from "total"
retur