Add three new sections to all 14 examples: - "Carry Forward": what output feeds into later examples (01-10) - "The Cumulative Path": alternative prompt building on previous output (02-10) - "Now Try It Yourself": personalized template with transferable pattern (all) - "Building On" callout connecting back to previous examples (02-10) Add Example 14: Build Your Personal Agent - capstone that guides reader through writing their own CLAUDE.md, creating a personal skill, connecting a messaging channel, setting up automation, and testing end-to-end. Update README with cumulative path diagram, two usage modes, and example 14. Update GETTING-STARTED.md with cross-references to relevant examples. 17 files changed, 703+ lines added. The examples now form a coherent learning path from "see what it can do" to "build your own agent." Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4.4 KiB
Example 08: Cron and Scheduled Automation
Capability: Claude Code supports scheduled and automated execution through three complementary mechanisms, covering in-session polling through to system-level cron jobs.
OpenClaw equivalent: HEARTBEAT.md, cron scheduler, webhooks, auto-reply.
Building on Examples 01-07. You have a complete pipeline: research (01-03), memory (05), agent review (06), and delivery (07). This example makes it run without you pressing enter. Automation is what separates a demo from a daily driver.
Three Approaches
Approach 1: /loop (In-session polling, v2.1.71)
For tasks that should repeat while Claude Code is running:
/loop interval=60
Every 60 seconds, check if a file called 'trigger.txt' exists in this
directory. If it does, read its contents, execute the task described inside,
delete the file, and write the result to 'loop-output.md'. Then wait for
the next trigger.
Use this for development and testing. The loop runs as long as the session is active.
Approach 2: CronCreate (System-level scheduling, v2.1.71)
For tasks that should run on a schedule even when Claude Code is not open:
Create a cron job that runs the 'daily-briefing' skill every morning at 07:00.
Use the automation/daily-briefing.sh wrapper script. Show me the cron entry
before creating it so I can verify it.
Claude Code calls CronCreate to register the job with the system cron daemon.
Use CronList to see all registered jobs and CronDelete to remove them.
The automation/daily-briefing.sh script in this repo is a ready-made wrapper.
Approach 3: /schedule (Remote trigger, web only)
For triggering runs from anywhere, including from a phone:
/schedule "Run the web-research skill on 'latest Anthropic news' and
email me a summary" at 2025-04-01T08:00:00
/schedule is available in the Claude web interface. It queues a headless
Claude Code run for the specified time. Combines with the Telegram permission
relay (v2.1.81) for approval-gated automation.
Why This Matters
OpenClaw uses HEARTBEAT.md as a persistent loop marker. Claude Code achieves
the same outcome with more granularity: /loop for in-process polling, CronCreate
for system scheduling, /schedule for remote triggering. The automation/ directory
in this repo provides macOS launchd examples as an alternative to cron.
Carry Forward
With scheduling configured, your pipeline runs itself:
- Example 09 adds safety guardrails to protect automated runs
- Example 10 is the pipeline that your cron job triggers
- Example 12 lets you monitor and control scheduled runs from your phone
Automation is the multiplier. Everything you built in examples 01-07 runs once when you trigger it. With scheduling, it runs every day, every week, or every time a condition is met.
The Cumulative Path
If you ran Examples 01-07, you have a complete pipeline with delivery. This prompt schedules it to run automatically.
Create a cron job that runs every Monday at 07:00 to execute:
1. Web research on a topic from memory/research-state.md
2. Multi-agent review via the researcher/writer/reviewer agents
3. Save output to pipeline-output/
4. Send a Telegram notification with the summary
Use automation/daily-briefing.sh as a template for the wrapper script.
Show me the cron entry before creating it so I can verify.
After running this, your Monday mornings start with a fresh research report waiting on your phone.
Now Try It Yourself
Think about what you would automate if it cost zero effort:
Option 1: /loop (for testing)
/loop interval=300
Every 5 minutes, check if [your trigger condition]. If true,
[execute your pipeline]. Write results to [your output location].
Option 2: CronCreate (for production)
Create a cron job that runs [your task] every [schedule].
Use [wrapper script] and show me the cron entry first.
Option 3: /schedule (for remote)
/schedule "[your task description]" at [ISO datetime]
The pattern you just learned: trigger condition + pipeline steps + output destination. The three approaches cover different needs: /loop for development, CronCreate for system-level, /schedule for remote.
Ideas worth trying:
- Weekly competitor monitoring report every Monday
- Daily inbox summary from your email MCP at 08:00
- Hourly check for new entries in a data source you monitor