TaskCreated
Runs when a task is being created via the TaskCreate tool. Use this to enforce naming conventions, require task descriptions, or prevent certain tasks from being created. In a session without the Task tools, this event doesn't fire.
TaskCreated hooks don't support matchers and fire on every occurrence.
TaskCreated input
In addition to the common input fields, TaskCreated hooks receive task_id, task_subject, and optionally task_description, teammate_name, and team_name.
{
"session_id": "abc123",
"transcript_path": "/Users/.../.claude/projects/.../00893aaf-19fa-41d2-8238-13269b9b3ca0.jsonl",
"cwd": "/Users/...",
"hook_event_name": "TaskCreated",
"task_id": "task-001",
"task_subject": "Implement user authentication",
"task_description": "Add login and signup endpoints",
"teammate_name": "implementer",
"team_name": "session-a1b2c3d4"
}| Field | Description |
|---|---|
task_id | Identifier of the task being created |
task_subject | Title of the task |
task_description | Detailed description of the task. May be absent |
teammate_name | Name of the teammate creating the task. May be absent |
team_name | Deprecated. Session-derived team name; will be removed in a future release |
TaskCreated decision control
A TaskCreated hook can block the creation in two ways. Either way, Claude Code deletes the task and returns your message to Claude as the tool's error. Claude Code ignores continue: false from this event and Claude keeps working.
- Exit code 2: Claude Code returns the stderr text as the message.
- JSON
\{"decision": "block", "reason": "..."\}: Claude Code returnsreasonas the message.
This example blocks tasks whose subjects don't follow the required format:
#!/bin/bash
INPUT=$(cat)
TASK_SUBJECT=$(echo "$INPUT" | jq -r '.task_subject')
if [[ ! "$TASK_SUBJECT" =~ ^\[TICKET-[0-9]+\] ]]; then
echo "Task subject must start with a ticket number, e.g. '[TICKET-123] Add feature'" >&2
exit 2
fi
exit 0