Skip to content

Instantly share code, notes, and snippets.

@fubits1
Created February 24, 2026 18:13
Show Gist options
  • Select an option

  • Save fubits1/7ec1009d905ac2434e3b60a4700aecab to your computer and use it in GitHub Desktop.

Select an option

Save fubits1/7ec1009d905ac2434e3b60a4700aecab to your computer and use it in GitHub Desktop.
Claude Hook: Formatting
#!/bin/bash
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path')
# Run prettier on all supported files
npx -y prettier --write "$FILE_PATH" >/dev/null 2>&1
# Additionally run markdownlint on .md files
if [[ "$FILE_PATH" == *.md ]]; then
npx -y markdownlint-cli2 --fix "$FILE_PATH" >/dev/null 2>&1
fi
exit 0
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/fix-formatting.sh"
}
]
}
]
},
"enabledPlugins": {
"svelte@svelte": true
},
"effortLevel": "medium"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment