Skip to content

Instantly share code, notes, and snippets.

@camwest
Last active July 1, 2025 15:12
Show Gist options
  • Save camwest/f55852e300fdf39880a3a27fc26d55d4 to your computer and use it in GitHub Desktop.
Save camwest/f55852e300fdf39880a3a27fc26d55d4 to your computer and use it in GitHub Desktop.
Claude Code Hook: Code Quality Check - Runs TypeScript and linting after file edits
#!/bin/bash
# Claude Code Hook: Code Quality Check
# Runs TypeScript check and lint fix after file modifications
echo "πŸ” Running code quality checks..."
# Run TypeScript check
echo " β†’ Type checking..."
npx tsc --noEmit
if [ $? -ne 0 ]; then
echo "❌ TypeScript errors found"
echo '{"decision": "block", "reason": "TypeScript errors detected. Please fix type errors before proceeding."}'
exit 0
fi
# Run lint fix
echo " β†’ Linting and fixing..."
yarn lint:fix
if [ $? -ne 0 ]; then
echo "❌ Linting failed"
echo '{"decision": "block", "reason": "Linting failed. Please fix linting errors manually."}'
exit 0
fi
echo "βœ… Code quality checks passed"
echo '{"decision": "approve"}'
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment