v2/src/cli/simple-commands/init/templates/commands/hooks/pre-edit.md
Execute pre-edit validations and agent assignment before file modifications.
npx claude-flow hook pre-edit [options]
--file, -f <path> - File path to be edited--auto-assign-agent - Automatically assign best agent (default: true)--validate-syntax - Pre-validate syntax before edit--check-conflicts - Check for merge conflicts--backup-file - Create backup before editingnpx claude-flow hook pre-edit --file "src/auth/login.js"
npx claude-flow hook pre-edit -f "config/database.js" --validate-syntax
npx claude-flow hook pre-edit -f "api/users.ts" --auto-assign-agent false
npx claude-flow hook pre-edit -f "production.env" --backup-file --check-conflicts
This hook is automatically called by Claude Code when:
Manual usage in agents:
# Before editing files
npx claude-flow hook pre-edit --file "path/to/file.js" --validate-syntax
Returns JSON with:
{
"continue": true,
"file": "src/auth/login.js",
"assignedAgent": "auth-specialist",
"syntaxValid": true,
"conflicts": false,
"backupPath": ".backups/login.js.bak",
"warnings": []
}
hook post-edit - Post-edit processingEdit - File editing toolMultiEdit - Multiple edits toolagent spawn - Manual agent creation