用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/glincker/claude-code-marketplace --skill git-hooks-manager命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Analyze and optimize code performance, identify bottlenecks, and suggest improvements
Automated deployment orchestration with rollback, blue-green, and canary deployment strategies
Manage development environments, configurations, and secrets across local, staging, and production
基于 SOC 职业分类
正在显示 SKILL.md
| name | git-hooks-manager |
| description | Setup and manage git hooks for pre-commit, pre-push automation (lint, test, format) |
| allowed-tools | ["Write","Read","Bash"] |
| version | 1.0.0 |
| author | GLINCKER Team |
| license | Apache-2.0 |
| keywords | ["git","hooks","pre-commit","automation","quality"] |
Setup automated git hooks for pre-commit and pre-push workflows. Enforce code quality, run tests, format code, and prevent bad commits from reaching your repository.
Use Read to check:
- package.json → Node.js (use husky)
- pyproject.toml → Python (use pre-commit)
- .git/hooks → Manual hooks
Install husky:
npm install --save-dev husky lint-staged
npx husky init
Configure package.json:
{
"scripts": {
"prepare": "husky"
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
"eslint --fix",
"prettier --write"
],
"*.{json,md,yml}": [
"prettier --write"
]
}
}
Pre-commit hook (.husky/pre-commit):
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
echo "🔍 Running pre-commit checks..."
# Run linter
npm run lint || exit 1
# Format code
npx lint-staged || exit 1
# Run tests on staged files
npm test -- --findRelatedTests $(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(js|jsx|ts|tsx)$' | tr '\n' ' ') || exit 1
echo "✅ Pre-commit checks passed!"
Pre-push hook (.husky/pre-push):
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
echo "🔍 Running pre-push checks..."
# Run full test suite
npm test || exit 1
# Check types (if TypeScript)
npm run type-check || exit 1
# Build check
npm run build || exit 1
echo "✅ Pre-push checks passed!"
Commit-msg hook (.husky/commit-msg):
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
# Enforce conventional commits
npx --no -- commitlint --edit $1 || exit 1
.pre-commit-config.yaml:
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-json
- id: check-merge-conflict
- id: detect-private-key
- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
language_version: python3.11
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
args: ['--max-line-length=88', '--extend-ignore=E203']
- repo: https://github.com/pycqa/isort
[, ]
[]
Install:
pip install pre-commit
pre-commit install
pre-commit install --hook-type commit-msg
For projects without package managers:
.git/hooks/pre-commit:
#!/bin/sh
echo "🔍 Running pre-commit checks..."
# Check for TODOs
if git diff --cached | grep -i "TODO"; then
echo "❌ Found TODO comments. Please remove or track them properly."
exit 1
fi
# Check for console.log
if git diff --cached --name-only | grep -E '\.(js|jsx|ts|tsx)$' | xargs grep -n "console\.log"; then
echo "❌ Found console.log statements. Please remove them."
exit 1
fi
# Check for hardcoded secrets
if git diff --cached | grep -E '(password|secret|api_key|apikey)\s*=\s*["\'][^"\']+["\']'; then
echo "❌ Possible hardcoded secret detected!"
exit 1
fi
# Check file size
for file in $(git diff --cached --name-only); do
if [ -f "$file" ]; then
size=$(wc -c < "$file")
if [ $size -gt 1048576 ]; then # 1MB
echo "❌ File $file is too large (>1MB)"
exit 1
fi
fi
done
echo "✅ Pre-commit checks passed!"
# Skip pre-commit
git commit -n -m "Emergency fix"
# Skip pre-push
git push --no-verify
# Only run on specific branches
if [ "$(git branch --show-current)" = "main" ]; then
echo "Running extra checks on main branch..."
fi
# Cache linter results
if [ ! -f .lint-cache ] || [ "$(git diff --cached | md5sum)" != "$(cat .lint-cache)" ]; then
npm run lint
git diff --cached | md5sum > .lint-cache
fi
User: "Setup git hooks for my Node.js project"
Output:
User: "Setup pre-commit hooks for Python"
Output:
GLINCKER Team