22 lines
788 B
Bash
22 lines
788 B
Bash
#!/bin/bash
|
|
# PostToolUse Hook for Write - Logs file writes and can trigger actions
|
|
|
|
# Extract file path from parameters
|
|
FILE_PATH="${CLAUDE_TOOL_PARAMETERS:-Unknown file}"
|
|
|
|
# Log the write operation
|
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] File written: $FILE_PATH" >> .claude/logs/writes.log
|
|
|
|
# Optional: Auto-format specific file types
|
|
if [[ "$FILE_PATH" =~ \.(js|ts|jsx|tsx)$ ]]; then
|
|
# Uncomment to enable auto-formatting with prettier
|
|
# npx prettier --write "$FILE_PATH" 2>/dev/null || true
|
|
echo " -> JavaScript/TypeScript file detected" >> .claude/logs/writes.log
|
|
fi
|
|
|
|
if [[ "$FILE_PATH" =~ \.(py)$ ]]; then
|
|
# Uncomment to enable auto-formatting with black
|
|
# black "$FILE_PATH" 2>/dev/null || true
|
|
echo " -> Python file detected" >> .claude/logs/writes.log
|
|
fi
|