pre-delete-check Hook
The pre-delete-check hook fires before file deletion operations (rm, git rm, or Write with empty content). It checks whether the files being deleted are linked to features in the Sentinel registry and warns if critical features would be orphaned.
Trigger Event
Fires as a PreToolUse hook when it detects deletion patterns:
Bashtool withrmorgit rmcommands targetingsrc/filesWritetool with empty content targetingsrc/files
What It Does
- Extracts deleted file paths from the tool input
- Opens the data database (read-only) containing the Sentinel feature registry
- Runs feature impact analysis via
getFeatureImpact() - Generates a warning if features would be orphaned or degraded
- Outputs the warning as JSON to stdout
The hook does not block the deletion -- it provides a warning that the AI assistant should act on.
Example Input
json
{
"session_id": "abc123-def456",
"tool_name": "Bash",
"tool_input": {
"command": "rm src/components/orders/CreateOrderForm.tsx"
}
}Example Output (when features affected)
json
{
"message": "SENTINEL IMPACT WARNING: Deleting 1 file(s) would affect features:\n\nORPHANED (1 features - no primary components left):\n - orders.create [P1]: Order Creation Flow\n\nCreate a migration plan before deleting these files."
}Performance
This hook must complete within 500ms. It achieves this with:
- Read-only database access (no writes)
- Early exit if no
src/files are being deleted - Early exit if the Sentinel table does not exist yet
- 400ms stdin timeout to prevent hanging
Tips
- The hook only checks files under
src/-- non-source file deletions are ignored - If the Sentinel registry has not been populated yet (no
massu_syncrun), the hook exits silently - Use
massu_sentinel_impactfor a more detailed analysis before large refactoring operations