v2/docs/technical/fixes/HOOKS-V2-MODIFICATION.md
Three new modification hooks have been added to Claude Flow that leverage Claude Code v2.0.10+ PreToolUse input modification capability.
modify-bash - Bash Command ModificationsFeatures:
-i flag to rm commands for interactive confirmationll → ls -lah, la → ls -la/tmp/Example:
echo '{"tool_input":{"command":"rm test.txt"}}' | npx claude-flow@alpha hooks modify-bash
# Output: {"tool_input":{"command":"rm -i test.txt"}, "modification_notes":"[Safety: Added -i flag]"}
modify-file - File Path ModificationsFeatures:
/tests//src//docs/working//tmp/Example:
echo '{"tool_input":{"file_path":"test.js"}}' | npx claude-flow@alpha hooks modify-file
# Output: {"tool_input":{"file_path":"src/test.js"}, "modification_notes":"[Organization: Moved to /src/]"}
modify-git-commit - Git Commit Message FormattingFeatures:
[feat], [fix], [docs], etc.)feature/PROJ-123 → (PROJ-123))Example:
echo '{"tool_input":{"command":"git commit -m \"fix auth bug\""}}' | npx claude-flow@alpha hooks modify-git-commit
# Output: Formats as "[fix] fix auth bug" with co-author
Both hook configuration files have been updated:
.claude-plugin/hooks/hooks.json{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [{
"type": "command",
"command": "cat | npx claude-flow@alpha hooks modify-bash"
}]
},
{
"matcher": "Write|Edit|MultiEdit",
"hooks": [{
"type": "command",
"command": "cat | npx claude-flow@alpha hooks modify-file"
}]
}
]
}
}
.claude/settings.jsonSame configuration applied for local development.
All hooks tested and working in containerized/remote environments:
# Test bash modifications
echo '{"tool_input":{"command":"rm test.txt"}}' | ./bin/claude-flow hooks modify-bash
# ✅ Outputs: {"tool_input":{"command":"rm -i test.txt"},"modification_notes":"[Safety: Added -i flag]"}
# Test alias expansion
echo '{"tool_input":{"command":"ll"}}' | ./bin/claude-flow hooks modify-bash
# ✅ Outputs: {"tool_input":{"command":"ls -lah"},"modification_notes":"[Alias: ll → ls -lah]"}
# Test file path modifications
echo '{"tool_input":{"file_path":"test.js"}}' | ./bin/claude-flow hooks modify-file
# ✅ Outputs: {"tool_input":{"file_path":"src/test.js"},"modification_notes":"[Organization: Moved to /src/]"}
# Test git commit formatting
echo '{"tool_input":{"command":"git commit -m \"fix bug\""}}' | ./bin/claude-flow hooks modify-git-commit
# ✅ Outputs: [fix] fix bug with Co-Authored-By: claude-flow <[email protected]>
# Test help display (no input)
./bin/claude-flow hooks modify-bash
# ✅ Shows usage help after 100ms timeout
Note: The hooks use a 100ms timeout to detect piped vs interactive input, ensuring they work correctly in containerized and remote development environments where process.stdin.isTTY may be undefined.
The hooks are automatically invoked by Claude Code v2.0.10+ when using the PreToolUse feature.
To use manually:
npx claude-flow@alpha hooks modify-bash # For bash commands
npx claude-flow@alpha hooks modify-file # For file operations
npx claude-flow@alpha hooks modify-git-commit # For git commits
View all hooks:
npx claude-flow@alpha hooks --help
Author: claude-flow Co-Author: claude-flow [email protected]