Husky git hooks configuration with smart auto-detection for sensitive files, fail-fast execution, auto-fix workflows, and CI detection. Includes 5 required standards (smart .npmrc detection for multi-mono repos, set -e for fail-fast, pre-commit auto-fix with prettier:fix and lint:fix, pre-push validation with time tracking, clear emoji-enhanced output). Use when creating or auditing .husky/pre-commit and .husky/pre-push hooks.
Generates and validates Husky git hooks with smart sensitive file detection, auto-fix workflows, and fail-fast execution. Claude uses this when creating or auditing `.husky/pre-commit` and `.husky/pre-push` files to enforce 5 standards including CI detection and time tracking.
/plugin marketplace add metasaver/metasaver-marketplace/plugin install core-claude-plugin@metasaver-marketplaceThis skill inherits all available tools. When active, it can use any tool Claude has access to.
templates/pre-commit.template.shtemplates/pre-push.template.shThis skill provides Husky pre-commit and pre-push hook templates and validation logic for automated code quality enforcement.
Manage Husky git hooks configuration to:
.env*, .npmrc with smart detection)This skill is invoked by the husky-agent when:
Standard templates are located at:
templates/pre-commit.template.sh # Pre-commit hook with auto-fix
templates/pre-push.template.sh # Pre-push hook with validation
Pre-commit must intelligently block sensitive files:
Multi-mono repo detection:
# Detect if this is multi-mono library repo
if [ -f "scripts/sync-ms-command.sh" ]; then
IS_MULTI_MONO=true
fi
Blocking logic:
.npmrc (registry only), block subdirectory .npmrc.npmrc files including root.env* filesValidation:
# Check for smart detection logic
grep -q "IS_MULTI_MONO" .husky/pre-commit
grep -q "scripts/sync-ms-command.sh" .husky/pre-commit
# Check for sensitive file patterns
grep -q "\.env" .husky/pre-commit
grep -q "\.npmrc" .husky/pre-commit
Both hooks must use set -e to exit immediately on errors:
#!/bin/sh
set -e # Exit immediately if a command exits with non-zero status
Validation:
#!/bin/shset -e is present near top of fileRequired steps in order:
pnpm run prettier:fix (auto-format)pnpm run lint:fix (auto-fix linting)git add -uValidation:
# Check required steps exist in order
grep -n "prettier:fix" .husky/pre-commit
grep -n "lint:fix" .husky/pre-commit
grep -n "git add -u" .husky/pre-commit
# Verify package.json has required scripts
jq '.scripts | has("prettier:fix")' package.json
jq '.scripts | has("lint:fix")' package.json
Required steps in order:
START_TIME)pnpm run prettier (check only, no fix)pnpm run lint (check only, no fix)pnpm run lint:tsc (TypeScript type checking)pnpm run test:unit (unit tests)CI Detection:
# Skip in CI environments
if [ -n "$CI" ] || [ -n "$GITHUB_ACTIONS" ] || [ -n "$GITLAB_CI" ]; then
echo "⏭️ Skipping pre-push checks in CI environment"
exit 0
fi
Time Tracking:
START_TIME=$(date +%s)
# ... run checks ...
END_TIME=$(date +%s)
DURATION=$((END_TIME - START_TIME))
echo "✅ All checks passed in ${DURATION}s"
Validation:
# Check CI detection
grep -q "CI" .husky/pre-push
grep -q "GITHUB_ACTIONS" .husky/pre-push
# Check time tracking
grep -q "START_TIME" .husky/pre-push
grep -q "DURATION" .husky/pre-push
# Check required steps
grep -q "prettier" .husky/pre-push
grep -q "lint" .husky/pre-push
grep -q "lint:tsc" .husky/pre-push
grep -q "test:unit" .husky/pre-push
# Verify package.json has required scripts
jq '.scripts | has("prettier")' package.json
jq '.scripts | has("lint")' package.json
jq '.scripts | has("lint:tsc")' package.json
jq '.scripts | has("test:unit")' package.json
Both hooks must provide clear, emoji-enhanced output:
Pre-commit:
echo "🔒 Checking for sensitive files..."
echo "✨ Running Prettier..."
echo "🔍 Running ESLint..."
echo "✅ Pre-commit checks passed"
Pre-push:
echo "🚀 Running pre-push checks..."
echo "1️⃣ Prettier check..."
echo "2️⃣ ESLint check..."
echo "3️⃣ TypeScript type check..."
echo "4️⃣ Unit tests..."
echo "✅ All checks passed in ${DURATION}s"
Validation:
To validate Husky hook configuration:
.husky/pre-commit exists and is executable.husky/pre-push exists and is executable# Check hooks exist and are executable
[ -f ".husky/pre-commit" ] && [ -x ".husky/pre-commit" ] || echo "VIOLATION: pre-commit missing or not executable"
[ -f ".husky/pre-push" ] && [ -x ".husky/pre-push" ] || echo "VIOLATION: pre-push missing or not executable"
# Rule 1: Check smart detection
grep -q "IS_MULTI_MONO" .husky/pre-commit || echo "VIOLATION: Missing smart auto-detection"
# Rule 2: Check fail-fast
grep -q "^set -e" .husky/pre-commit || echo "VIOLATION: pre-commit missing set -e"
grep -q "^set -e" .husky/pre-push || echo "VIOLATION: pre-push missing set -e"
# Rule 3: Check pre-commit steps
grep -q "prettier:fix" .husky/pre-commit || echo "VIOLATION: Missing prettier:fix"
grep -q "lint:fix" .husky/pre-commit || echo "VIOLATION: Missing lint:fix"
grep -q "git add -u" .husky/pre-commit || echo "VIOLATION: Missing git add -u"
# Rule 4: Check pre-push steps
grep -q "CI" .husky/pre-push || echo "VIOLATION: Missing CI detection"
grep -q "START_TIME" .husky/pre-push || echo "VIOLATION: Missing time tracking"
grep -q "test:unit" .husky/pre-push || echo "VIOLATION: Missing test:unit"
# Rule 5: Check output clarity
grep -q "🔒\|🚀\|✅" .husky/pre-commit || echo "VIOLATION: Missing emoji output"
.npmrc handling (allow root, block subdirectories)chmod +x)set -e)This skill integrates with:
scope parameter. If not provided, use /skill scope-check/skill audit-workflow - Bi-directional comparison workflow/skill remediation-options - Conform/Update/Ignore choicesprettier-agent - For prettier:fix and prettier scriptseslint-agent - For lint:fix and lint scriptstypescript-agent - For lint:tsc scriptvitest-agent - For test:unit script