Agents & Orchestration Advanced
Agent with Hooks
Attach lifecycle hooks to a custom agent for quality gates and validation
Command
"color:#9CA3AF;font-style:italic"># ."color:#7C5CFC">claude/agents/safe-coder.md $ "color:#d97757">--- name: safe-coder description: Coder with safety hooks tools: Read, Grep, Glob, Bash, Write, Edit hooks: PreToolUse: - matcher: Bash hooks: - type: command command: ./."color:#7C5CFC">claude/hooks/validate-bash.sh "color:#d97757">--- You are a careful developer. Always run tests after changes.
Response
// Agent-scoped hooks only fire for that specific agent // TeammateIdle and TaskCompleted hooks are for agent team orchestration
Parsing Code
059669">">// Hook events 059669">">for agent teams: 059669">">// TeammateIdle — teammate finished, no tasks left 059669">">// Exit 2: send feedback, keep working 059669">">// TaskCompleted — teammate marked task done // Exit 2: reject, send back to work
Gotchas
! Hooks in agent frontmatter are scoped to that agent only — won't fire for other agents
! TeammateIdle and TaskCompleted hooks enable quality gates for agent team orchestration