Create Custom Routine
Guide the user through creating a new automated routine that runs on schedule via the EvoNexus scheduler.
What You're Building
A routine is a Python script in ADWs/routines/custom/ that runs on a schedule (daily, weekly, monthly, or interval). There are two types:
- AI routines — invoke Claude Code CLI with an agent to perform reasoning tasks (reports, analysis, decisions). Cost tokens and ~30-120s per run.
- Systematic routines — pure Python scripts that perform deterministic operations (API calls, file ops, data transforms). No AI, no tokens, no cost, ~1-5s per run.
Step 1: Understand the Task
Ask the user:
- What should this routine do? (e.g., "check my GitHub repos every morning", "ping API endpoints every 5 minutes")
- AI or systematic? Help the user decide:
- Use AI when: the task needs reasoning, analysis, writing, or decisions (generate a report, analyze sentiment, summarize data, make recommendations)
- Use systematic when: the task is deterministic and repeatable (HTTP health checks, file cleanup, data snapshots, metric logging, backups, CSV exports)
- When should it run? (daily at X, every N minutes, weekly on day, monthly on day 1)
- What output? (HTML report, markdown file, CSV, JSON, Telegram notification, log entry, or just action)
If AI routine, also ask:
- Which agent should run it?
clawdia-assistant — ops, daily tasks, email, meetings
flux-finance — financial reports, Stripe, ERP
atlas-project — GitHub, Linear, project tracking
pulse-community — Discord, WhatsApp, community
pixel-social-media — social media, content, analytics
sage-strategy — OKRs, strategy, competitive analysis
nex-sales — pipeline, proposals, leads
mentor-courses — courses, learning paths
kai-personal-assistant — health, habits, personal
Step 2: Generate the Script
AI routine
Create the routine script at ADWs/routines/custom/{name}.py:
#!/usr/bin/env python3
"""ADW: {Routine Name} — {brief description}. Agent: @{agent-name}"""
import sys, os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from runner import run_skill, run_claude, banner, summary
def main():
banner("{Routine Name}", "{description} | @{agent}")
results = []
results.append(run_skill(
"{skill-name}",
log_name="{routine-id}",
timeout=600,
agent="{agent-name}"
))
summary(results, "{Routine Name}")
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("\nCancelled.")
Key rules for AI routines:
- Use
run_skill() when there's an existing skill, or run_claude() for inline prompts
- Specify the agent name for context loading
- Set a reasonable timeout (300-900s depending on complexity)
Systematic routine
Create the routine script at ADWs/routines/custom/{name}.py:
#!/usr/bin/env python3
"""ADW: {Routine Name} — {brief description}. Type: systematic"""
import sys, os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from runner import run_script, banner, summary
def do_task():
"""Pure Python logic — no Claude CLI, no AI, no tokens."""
# YOUR CODE HERE: API calls, file ops, data transforms
# ...
return {
"ok": True, # or False on failure
"summary": "Short description of what happened",
"data": {} # optional structured data for logs
}
def main():
banner("{Routine Name}", "{description} | systematic")
results = []
results.append(run_script(do_task, log_name="{routine-id}", timeout=60))
summary(results, "{Routine Name}")
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("\nCancelled.")
Key rules for systematic routines:
- Write the actual Python logic in the
do_task() function — this is where YOU (Claude) generate the implementation code
- Use stdlib +
requests for HTTP calls (already in pyproject.toml dependencies)
- Return
{"ok": bool, "summary": str} so the runner can log success/failure
- Keep timeout short (30-120s) — these should be fast
- No
agent parameter — systematic routines don't use agents
- Common patterns:
requests.get() for API polling, os.walk() for file ops, csv.writer() for data export, shutil for backups
Step 3: Run It
No Makefile changes needed — routines are discovered dynamically from scripts.
make run R={routine-id} # Run by ID
make list-routines # List all available
Step 4: Add to Scheduler (Optional)
If the user wants it automated, add to scheduler.py in the appropriate section:
# Daily
schedule.every().day.at("{HH:MM}").do(run_adw, "{Routine Name}", "custom/{script_name}.py")
# Weekly
schedule.every().{day}.at("{HH:MM}").do(run_adw, "{Routine Name}", "custom/{script_name}.py")
# Monthly (in the monthly block)
run_adw("{Routine Name}", "custom/{script_name}.py")
# Interval
schedule.every({N}).minutes.do(run_adw, "{Routine Name}", "custom/{script_name}.py")
Step 5: Test
Run the routine manually:
make run R={routine-id}
Check the output and adjust the prompt if needed.
Step 6: Create HTML Template (Optional)
If the routine generates an HTML report, create a template at .claude/templates/html/{name}.html following the pattern of existing templates:
- Dark theme (bg #0C111D, green #00FFA7)
- Evolution Foundation logo in header
- Footer: "Automatically generated by EvoNexus — Evolution Foundation"
- Use
{{PLACEHOLDER}} for dynamic content
Examples
AI routine: Daily competitor check
Name: competitor-check
Type: AI
Agent: sage-strategy
Schedule: daily at 09:00
Why AI: needs reasoning to analyze competitor changes and compare positioning
AI routine: Weekly content performance
Name: content-performance
Type: AI
Agent: pixel-social-media
Schedule: weekly on friday at 17:00
Why AI: needs analysis to identify trends and make recommendations
Systematic routine: API health check
Name: api-health-check
Type: systematic
Schedule: every 5 minutes
Why systematic: just pings endpoints and checks HTTP status codes — no reasoning needed
Systematic routine: Metric snapshot
Name: metric-snapshot
Type: systematic
Schedule: daily at 23:55
Why systematic: reads metrics.json and appends a row to a CSV — pure data transform
Systematic routine: Log cleanup
Name: log-cleanup
Type: systematic
Schedule: weekly on sunday at 03:00
Why systematic: deletes files older than 30 days — deterministic file operation
Important Notes
- Custom routines go in
ADWs/routines/custom/ (gitignored — they're personal to your workspace)
- Core routines in
ADWs/routines/ are shipped with the repo and should not be modified
- The
runner.py handles logging, metrics, and Telegram notifications automatically for both types
- Systematic routines log with
tokens=0 and cost=0 in metrics
- Systematic routines can run at high frequency (every 1-5 minutes) since they cost nothing
- Restart the scheduler after adding new routines: stop and
make scheduler
1---2name: create-routine3description: Create a new automated routine (ADW) for the scheduler. Guides the user through defining what the routine does, the type (AI or systematic), the schedule, and generates the Python script + Makefile target. Use when the user says 'create a routine', 'add a routine', 'automate this', 'schedule this task', 'new ADW', 'I want this to run automatically', or wants to turn any manual task into a scheduled automation.4---56# Create Custom Routine78Guide the user through creating a new automated routine that runs on schedule via the EvoNexus scheduler.910## What You're Building1112A routine is a Python script in `ADWs/routines/custom/` that runs on a schedule (daily, weekly, monthly, or interval). There are two types:1314- **AI routines** — invoke Claude Code CLI with an agent to perform reasoning tasks (reports, analysis, decisions). Cost tokens and ~30-120s per run.15- **Systematic routines** — pure Python scripts that perform deterministic operations (API calls, file ops, data transforms). No AI, no tokens, no cost, ~1-5s per run.1617## Step 1: Understand the Task1819Ask the user:201. **What should this routine do?** (e.g., "check my GitHub repos every morning", "ping API endpoints every 5 minutes")212. **AI or systematic?** Help the user decide:22 - **Use AI when:** the task needs reasoning, analysis, writing, or decisions (generate a report, analyze sentiment, summarize data, make recommendations)23 - **Use systematic when:** the task is deterministic and repeatable (HTTP health checks, file cleanup, data snapshots, metric logging, backups, CSV exports)243. **When should it run?** (daily at X, every N minutes, weekly on day, monthly on day 1)254. **What output?** (HTML report, markdown file, CSV, JSON, Telegram notification, log entry, or just action)2627If AI routine, also ask:28- **Which agent should run it?**29 - `clawdia-assistant` — ops, daily tasks, email, meetings30 - `flux-finance` — financial reports, Stripe, ERP31 - `atlas-project` — GitHub, Linear, project tracking32 - `pulse-community` — Discord, WhatsApp, community33 - `pixel-social-media` — social media, content, analytics34 - `sage-strategy` — OKRs, strategy, competitive analysis35 - `nex-sales` — pipeline, proposals, leads36 - `mentor-courses` — courses, learning paths37 - `kai-personal-assistant` — health, habits, personal3839## Step 2: Generate the Script4041### AI routine4243Create the routine script at `ADWs/routines/custom/{name}.py`:4445```python46#!/usr/bin/env python347"""ADW: {Routine Name} — {brief description}. Agent: @{agent-name}"""4849import sys, os50sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))51from runner import run_skill, run_claude, banner, summary5253def main():54 banner("{Routine Name}", "{description} | @{agent}")55 results = []56 results.append(run_skill(57 "{skill-name}",58 log_name="{routine-id}",59 timeout=600,60 agent="{agent-name}"61 ))62 summary(results, "{Routine Name}")6364if __name__ == "__main__":65 try:66 main()67 except KeyboardInterrupt:68 print("\nCancelled.")69```7071Key rules for AI routines:72- Use `run_skill()` when there's an existing skill, or `run_claude()` for inline prompts73- Specify the agent name for context loading74- Set a reasonable timeout (300-900s depending on complexity)7576### Systematic routine7778Create the routine script at `ADWs/routines/custom/{name}.py`:7980```python81#!/usr/bin/env python382"""ADW: {Routine Name} — {brief description}. Type: systematic"""8384import sys, os85sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))86from runner import run_script, banner, summary8788def do_task():89 """Pure Python logic — no Claude CLI, no AI, no tokens."""90 # YOUR CODE HERE: API calls, file ops, data transforms91 # ...92 return {93 "ok": True, # or False on failure94 "summary": "Short description of what happened",95 "data": {} # optional structured data for logs96 }9798def main():99 banner("{Routine Name}", "{description} | systematic")100 results = []101 results.append(run_script(do_task, log_name="{routine-id}", timeout=60))102 summary(results, "{Routine Name}")103104if __name__ == "__main__":105 try:106 main()107 except KeyboardInterrupt:108 print("\nCancelled.")109```110111Key rules for systematic routines:112- Write the actual Python logic in the `do_task()` function — this is where YOU (Claude) generate the implementation code113- Use stdlib + `requests` for HTTP calls (already in pyproject.toml dependencies)114- Return `{"ok": bool, "summary": str}` so the runner can log success/failure115- Keep timeout short (30-120s) — these should be fast116- No `agent` parameter — systematic routines don't use agents117- Common patterns: `requests.get()` for API polling, `os.walk()` for file ops, `csv.writer()` for data export, `shutil` for backups118119## Step 3: Run It120121No Makefile changes needed — routines are discovered dynamically from scripts.122123```bash124make run R={routine-id} # Run by ID125make list-routines # List all available126```127128## Step 4: Add to Scheduler (Optional)129130If the user wants it automated, add to `scheduler.py` in the appropriate section:131132```python133# Daily134schedule.every().day.at("{HH:MM}").do(run_adw, "{Routine Name}", "custom/{script_name}.py")135136# Weekly137schedule.every().{day}.at("{HH:MM}").do(run_adw, "{Routine Name}", "custom/{script_name}.py")138139# Monthly (in the monthly block)140run_adw("{Routine Name}", "custom/{script_name}.py")141142# Interval143schedule.every({N}).minutes.do(run_adw, "{Routine Name}", "custom/{script_name}.py")144```145146## Step 5: Test147148Run the routine manually:149```bash150make run R={routine-id}151```152153Check the output and adjust the prompt if needed.154155## Step 6: Create HTML Template (Optional)156157If the routine generates an HTML report, create a template at `.claude/templates/html/{name}.html` following the pattern of existing templates:158- Dark theme (bg #0C111D, green #00FFA7)159- Evolution Foundation logo in header160- Footer: "Automatically generated by EvoNexus — Evolution Foundation"161- Use `{{PLACEHOLDER}}` for dynamic content162163## Examples164165### AI routine: Daily competitor check166```167Name: competitor-check168Type: AI169Agent: sage-strategy170Schedule: daily at 09:00171Why AI: needs reasoning to analyze competitor changes and compare positioning172```173174### AI routine: Weekly content performance175```176Name: content-performance177Type: AI178Agent: pixel-social-media179Schedule: weekly on friday at 17:00180Why AI: needs analysis to identify trends and make recommendations181```182183### Systematic routine: API health check184```185Name: api-health-check186Type: systematic187Schedule: every 5 minutes188Why systematic: just pings endpoints and checks HTTP status codes — no reasoning needed189```190191### Systematic routine: Metric snapshot192```193Name: metric-snapshot194Type: systematic195Schedule: daily at 23:55196Why systematic: reads metrics.json and appends a row to a CSV — pure data transform197```198199### Systematic routine: Log cleanup200```201Name: log-cleanup202Type: systematic203Schedule: weekly on sunday at 03:00204Why systematic: deletes files older than 30 days — deterministic file operation205```206207## Important Notes208209- Custom routines go in `ADWs/routines/custom/` (gitignored — they're personal to your workspace)210- Core routines in `ADWs/routines/` are shipped with the repo and should not be modified211- The `runner.py` handles logging, metrics, and Telegram notifications automatically for both types212- Systematic routines log with `tokens=0` and `cost=0` in metrics213- Systematic routines can run at high frequency (every 1-5 minutes) since they cost nothing214- Restart the scheduler after adding new routines: stop and `make scheduler`