openclaw-cron-standard
Use this skill when cleaning up or designing OpenClaw cron jobs.
Standard contract
For cron wrappers:
- Clear the old result artifact before a new run.
- Claim through one shared helper.
- If the claim reports
ALREADY_CLAIMED, print that sentinel, exit 0, and do not write a result artifact.
- Only write a result JSON for a real execution or a real failure.
- Keep result artifacts as the source of truth for real runs, not duplicate-run guards.
For cron prompts:
- Run the wrapper first.
- If it prints
ALREADY_CLAIMED, reply only with NO_REPLY.
- Only then read the result JSON.
- Never read a stale artifact after a duplicate-claim guard path.
- Match the prompt's delivery contract to the cron job's
delivery.mode.
Delivery-mode contract
This is the easy place to break a healthy cron job.
Use delivery.mode: announce when:
- the job returns user-visible text as its final assistant reply
- the prompt says things like
return summary_text exactly, return the alert text, or return the formatted message
- the job explicitly says
Do not use the message tool
Use delivery.mode: none when:
- the job is intentionally silent on success
- the job sends alerts explicitly via the
message tool
- the job is maintenance-only and should never rely on reply-text fallback delivery
Common failure mode
If you set delivery.mode: none on a cron that still relies on reply-text delivery, the job can:
- run successfully
- generate valid summary text
- update freshness facts
- still never notify the user
That is not a wrapper failure. It is a delivery-contract mismatch.
Why this matters
The fragile failure mode is usually contract drift across three places:
- wrapper behavior
- prompt behavior
- claim string expectations such as
already claimed vs already-claimed
That drift can turn a healthy duplicate-run guard into a fake failure or a silent not-delivered run. Delivery-mode drift can do the same thing even when the wrapper itself is fine.
Preferred implementation shape
Use a small shared helper module for:
prepare_result_path(...)
claim_or_exit(...)
run(...)
Keep wrapper-specific business logic outside the shared helper.
Audit checklist
- no result artifact written on
ALREADY_CLAIMED
- stale result file is removed before each run
- prompts check the sentinel before reading the artifact
delivery.mode matches the actual delivery contract (announce for reply delivery, none for explicit message-tool or silent jobs)
- validator passes after edits
- dead scratch wrappers and tmp scripts are removed if unreferenced
Good migration order
- Patch the wrapper contract first.
- Patch the live cron prompt second.
- Patch
delivery.mode to match the prompt's real delivery behavior.
- Validate with the cron validator and any runtime snapshot tools.
- Remove dead one-off scripts after reference checks.
Scope guidance
This skill is for cron wrapper standardization, not for changing the business logic of a cron job unless that logic is required to fit the contract.