Workflows & SkillFlows
Basic Workflow (reference)
workflows/cleanup.md:
---
name: cleanup
description: Clean up temporary files
---
# Cleanup Workflow
Remove temp files and rebuild.
SkillFlow (executable multi-step)
workflows/data-pipeline.yaml:
name: data-pipeline
description: Process data through validation, transformation, and storage
steps:
- skill: validate-input
prompt: "Validate the CSV data format"
- skill: __approval_gate__
prompt: "Data validation complete. Approve to continue?"
channel: telegram
- skill: transform-data
prompt: "Transform to required schema"
- skill: save-to-database
prompt: "Store results"
Approval Gates
Steps with skill: __approval_gate__ pause execution and send an approval request via the specified channel (Telegram, WhatsApp). The user has 5 minutes to approve before timeout.
Hooks
Hooks intercept agent lifecycle events for validation, logging, and control.
Configuration
hooks/hooks.yaml:
hooks:
on_session_start:
- script: hooks/check-auth.sh
description: "Verify user authorization"
pre_tool_use:
- script: hooks/validate-command.sh
description: "Block dangerous CLI commands"
post_tool_failure:
- script: hooks/notify-error.sh
post_response:
- script: hooks/log-response.sh
pre_query:
- script: hooks/rate-limit.sh
file_changed:
- script: hooks/track-changes.sh
on_error:
- script: hooks/incident-report.sh
Hook Events
| Event | When | Can Block | Can Modify Args |
|---|---|---|---|
on_session_start | Before agent runs | Yes | No |
pre_tool_use | Before each tool call | Yes | Yes |
post_tool_failure | After a tool errors | No | No |
pre_query | Before LLM call | Yes | No |
post_response | After LLM responds | No | No |
file_changed | After file write | No | No |
on_error | On agent error | No | No |
Hook Script Format
Scripts receive JSON on stdin and output JSON on stdout:
Input:
{"event": "pre_tool_use", "session_id": "uuid", "tool": "cli", "args": {"command": "rm -rf /"}}
Output:
{"action": "block", "reason": "Destructive command blocked"}
Actions: allow, block, modify (with args field for modified arguments)
Programmatic Hooks (SDK)
const result = query({
hooks: {
preToolUse: async (ctx) => {
if (ctx.toolName === "cli" && ctx.args.command.includes("rm")) {
return { action: "block", reason: "Blocked rm command" };
}
return { action: "allow" };
},
},
});
Schedules & Cron
Schedule recurring or one-time tasks.
Schedule Definition
schedules/daily-standup.yaml:
id: daily-standup
prompt: "Summarize git commits from the last 24 hours and list open tasks"
cron: "0 9 * * 1-5"
mode: repeat
enabled: true
One-Time Schedule
id: quarterly-review
prompt: "Generate Q1 performance report"
mode: once
runAt: "2026-04-01T09:00:00Z"
enabled: true
Cron Patterns
| Pattern | Meaning |
|---|---|
0 9 * * 1-5 | Weekdays at 9 AM |
0 9 * * 1 | Every Monday at 9 AM |
0 9 1 * * | First of month at 9 AM |
0 9 1 */3 * | Quarterly |
*/30 * * * * | Every 30 minutes |
Managing via UI
The Scheduler tab in the web UI lets you create, edit, enable/disable, trigger, and delete schedules.
