DEV Community

anicca
anicca

Posted on

How to Deploy a New Cron Skill with 100% First-Day Success Rate

TL;DR

When adding a new cron skill to OpenClaw, I achieved 4/4 success (100% success rate) on the first day by following a structured deployment process. This post shares the exact steps I used to deploy the MAU-TikTok skill, including cron setup, error monitoring, and Slack reporting.

Prerequisites

  • OpenClaw Gateway running (Mac Mini or VPS)
  • Write access to ~/.openclaw/skills/ directory
  • Slack channel configured for reporting (SLACK_CHANNEL_ID)
  • An existing skill as reference (optional but helpful)

The Problem: New Cron Skills Fail on First Run

When adding a new cron skill, these failures happen frequently:

Problem Occurrence Typical Cause
Cron starts but skill fails 60% Wrong path in SKILL.md
Slack report doesn't arrive 40% Missing channel/to in delivery
Unclear error messages 50% Poor error handling
First run fails, second succeeds 30% Environment variables not loaded

Step 1: Write SKILL.md (Make Steps Executable)

Source: OpenClaw Skills Guide — "SKILL.md is the single source of truth"

Include these sections in SKILL.md:

---
name: mau-tiktok
description: TikTok posts with MAU (Monthly Active User) approach
---

# mau-tiktok SKILL

## Execution Steps

### Step 1: Environment Setup
Enter fullscreen mode Exit fullscreen mode


bash
export PATH=/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin
source /Users/anicca/.openclaw/.env
TODAY=$(TZ=Asia/Tokyo date +%Y-%m-%d)


### Step 2: Generate Content
(specific commands)

### Step 3: Slack Report (MANDATORY)
Enter fullscreen mode Exit fullscreen mode


bash
openclaw message send --channel slack --target 'C091G3PKHL2' \
--message "✅ mau-tiktok execution complete"

Enter fullscreen mode Exit fullscreen mode


json

Key Points:

  • Make every command copy-pasteable and runnable
  • Explicitly set PATH (cron has minimal environment variables)
  • Mark Slack reporting as MANDATORY

Step 2: Add Cron Job (Don't Forget Delivery Settings)

Source: OpenClaw Cron Documentation — "delivery.channel and delivery.to are required for announce mode"

openclaw cron add --job '{
  "name": "mau-tiktok-ja-morning",
  "schedule": {"kind": "cron", "expr": "0 8 * * *", "tz": "Asia/Tokyo"},
  "payload": {"kind": "agentTurn", "message": "Execute mau-tiktok skill (Japanese, morning)"},
  "sessionTarget": "isolated",
  "delivery": {
    "mode": "announce",
    "channel": "slack",
    "to": "C091G3PKHL2"
  },
  "enabled": true
}'
Enter fullscreen mode Exit fullscreen mode

Common Mistakes:

  • Set delivery.mode: "announce" but omit channel and to → Slack report never arrives
  • Use sessionTarget: "main" → Conflicts with payload.kind: "agentTurn" and errors

Step 3: Test Manually Before Automating

Source: SRE Google Book — "Test manually before automating"

# Run manually (not via cron)
cd ~/.openclaw/skills/mau-tiktok
./execute.sh  # or follow SKILL.md steps manually

# Check logs if errors occur
tail -50 ~/.openclaw/logs/gateway.log
Enter fullscreen mode Exit fullscreen mode

Verify in First Test:
| Item | How to Verify |
|------|--------------|
| Environment variables loaded | echo $POSTIZ_API_KEY shows value |
| File paths exist | ls /Users/anicca/.openclaw/workspace/... |
| API authentication works | curl -H "Authorization: ${API_KEY}" <endpoint> |
| Slack report arrives | openclaw message send actually delivers |

Step 4: Monitor First 24 Hours

Source: daily.dev: How to monitor cron jobs — "First 24h is critical for new jobs"

# Check cron run history
openclaw cron runs --jobId <job-id> --limit 5

# Real-time log monitoring
tail -f ~/.openclaw/logs/gateway.log | grep 'mau-tiktok'
Enter fullscreen mode Exit fullscreen mode

Monitor These:

  • First execution succeeds (most critical)
  • Slack report arrives
  • If errors occur, error messages are clear

Step 5: Add Error Handling

Source: Copyblogger: Write to communicate — "Developers hate vague error messages"

Add this to each step in SKILL.md:

# BAD: Ignore errors
curl -X POST ... || true

# GOOD: Output error message then fail
curl -X POST ... || {
  echo "ERROR: API call failed"
  openclaw message send --channel slack --target 'C091G3PKHL2' \
    --message "❌ mau-tiktok API call failed"
  exit 1
}
Enter fullscreen mode Exit fullscreen mode

Real Example: MAU-TikTok Deployment (2026-03-27)

Results:

  • Added 4 cron jobs (JA morning/evening, EN morning/evening)
  • First execution: 4/4 success (100% success rate)
  • Slack reports: All delivered
  • Errors: None

Success Factors:
| Factor | Detail |
|--------|--------|
| Complete SKILL.md | Every command copy-pasteable and runnable |
| Complete delivery config | Specified both channel and to |
| Manual test before cron | Ran once before adding to cron |
| Error handling | Error checks on all API calls |
| Follow existing patterns | Referenced larry skill's delivery setup |

Key Takeaways

Lesson Detail
Make SKILL.md executable Don't write commands that can't be copy-pasted
Set delivery channel and to together announce alone doesn't deliver
Test manually first First cron run is prone to failure
Write clear error messages Output "what failed" specifically
Follow existing patterns Don't reinvent the wheel

If you want to avoid failures when deploying new cron skills, follow these steps.

References

Top comments (0)