v2/src/cli/simple-commands/init/templates/commands/hooks/pre-task.md
Execute pre-task preparations and context loading.
npx claude-flow hook pre-task [options]
--description, -d <text> - Task description for context--auto-spawn-agents - Automatically spawn required agents (default: true)--load-memory - Load relevant memory from previous sessions--optimize-topology - Select optimal swarm topology--estimate-complexity - Analyze task complexitynpx claude-flow hook pre-task --description "Implement user authentication"
npx claude-flow hook pre-task -d "Continue API development" --load-memory
npx claude-flow hook pre-task -d "Debug issue #123" --auto-spawn-agents false
npx claude-flow hook pre-task -d "Refactor codebase" --optimize-topology --estimate-complexity
This hook is automatically called by Claude Code when:
Manual usage in agents:
# In agent coordination
npx claude-flow hook pre-task --description "Your task here"
Returns JSON with:
{
"continue": true,
"topology": "hierarchical",
"agentsSpawned": 5,
"complexity": "medium",
"estimatedMinutes": 30,
"memoryLoaded": true
}
hook post-task - Post-task cleanupagent spawn - Manual agent creationmemory usage - Memory managementswarm init - Swarm initialization