App Events
App events are triggered by user actions and system changes within Craft Agents.LabelAdd
Triggered when a label is added to a session. Match value: The label name Environment variables:$CRAFT_LABEL- The label that was added$CRAFT_SESSION_ID- The session ID$CRAFT_SESSION_NAME- The session name
Use regex patterns to match specific labels. Use
"matcher": ".*" to match all labels.LabelRemove
Triggered when a label is removed from a session. Match value: The label name Environment variables:$CRAFT_LABEL- The label that was removed$CRAFT_SESSION_ID- The session ID$CRAFT_SESSION_NAME- The session name
LabelConfigChange
Triggered when the label configuration changes (labels added, removed, or modified). Match value: Empty (always matches) Environment variables:$CRAFT_WORKSPACE_ID- The workspace ID
This event has no matcher field since it always fires when labels change.
PermissionModeChange
Triggered when a session’s permission mode changes. Match value: The new permission mode Environment variables:$CRAFT_OLD_MODE- Previous permission mode$CRAFT_NEW_MODE- New permission mode$CRAFT_SESSION_ID- The session ID$CRAFT_SESSION_NAME- The session name
safe- Read-only modeask- Prompt for approvalallow-all- Auto-approve all commands
FlagChange
Triggered when a session is flagged or unflagged. Match value:true or false
Environment variables:
$CRAFT_IS_FLAGGED-trueorfalse$CRAFT_SESSION_ID- The session ID$CRAFT_SESSION_NAME- The session name
SessionStatusChange
Triggered when a session’s status changes in the workflow. Match value: The new status Environment variables:$CRAFT_OLD_STATE- Previous status$CRAFT_NEW_STATE- New status$CRAFT_SESSION_ID- The session ID$CRAFT_SESSION_NAME- The session name
TodoIn ProgressNeeds ReviewDoneCancelled
Statuses are customizable per workspace. Match against your configured status labels.
SchedulerTick
Triggered on a cron schedule. Match value: Not used (uses cron matching instead) Environment variables:$CRAFT_LOCAL_TIME- Local time in HH:MM format$CRAFT_LOCAL_DATE- Local date in YYYY-MM-DD format$CRAFT_WORKSPACE_ID- The workspace ID
Cron Syntax Guide
Cron Syntax Guide
Field order:
Special characters:
minute hour day month weekday| Field | Allowed values |
|---|---|
| Minute | 0-59 |
| Hour | 0-23 |
| Day | 1-31 |
| Month | 1-12 |
| Weekday | 0-6 (0 = Sunday) |
*- Any value,- List (e.g.,1,3,5)-- Range (e.g.,1-5)/- Step (e.g.,*/15)
0 9 * * 1-5- Weekdays at 9:00 AM0 */2 * * *- Every 2 hours30 14 * * 1- Mondays at 2:30 PM0 0 1 * *- First day of month at midnight
Always specify a timezone using IANA timezone names (e.g.,
America/New_York, Europe/Budapest, Asia/Tokyo).Agent Events
Agent events are triggered by the Claude SDK during agent execution. These events are currently supported for monitoring and logging but have limited automation support.PreToolUse
Triggered before a tool is executed. Match value: The tool name Available data:tool_name- Name of the tooltool_input- Input parameterstool_use_id- Unique tool use ID
PostToolUse
Triggered after a tool is executed successfully. Match value: The tool name Available data:tool_name- Name of the tooltool_response- Response from the tooltool_use_id- Unique tool use ID
PostToolUseFailure
Triggered when a tool execution fails. Match value: The tool name Available data:tool_name- Name of the toolerror- Error messagetool_use_id- Unique tool use ID
Notification
Triggered when the agent sends a notification. Match value: The notification message Available data:message- Notification messagetitle- Notification title (optional)
UserPromptSubmit
Triggered when a user submits a prompt. Match value: Empty Available data:prompt- The user’s prompt text
SessionStart
Triggered when a session starts. Match value: The session source Available data:source- Session source (startup, resume, clear, compact)model- Model being used
SessionEnd
Triggered when a session ends. Match value: Empty Available data:- Session metadata
Stop
Triggered when execution is stopped. Match value: EmptySubagentStart
Triggered when a subagent starts. Match value: The agent type Available data:agent_id- Subagent IDagent_type- Type of subagent
SubagentStop
Triggered when a subagent stops. Match value: The agent type Available data:agent_id- Subagent IDagent_type- Type of subagent
PreCompact
Triggered before conversation compaction. Match value: EmptyPermissionRequest
Triggered when the agent requests permission. Match value: The tool name Available data:tool_name- Tool requiring permissiontool_input- Tool input parameters
Setup
Triggered during agent setup. Match value: EmptyRegex Matchers
All events (except SchedulerTick) support regex patterns for matching:Match Specific Values
Match Multiple Values
Match Prefix
Match All
matcher field entirely:
Invalid regex patterns are silently skipped. Test your patterns before deploying.
Next Steps
Overview
Learn the basics of automation configuration
Examples
Explore real-world automation recipes