SuperAPI AI 工具集

git-hooks-manager

通用与其它

查看项目

更新于 10-16 05:54

技能介绍

用途:为项目搭建自动化 Git 钩子,在提交与推送阶段执行代码质量检查、测试和格式化,防止不合格代码进入仓库。

主要能力:创建 pre-commit 钩子(lint、format、test)、pre-push 钩子(完整测试套件)、commit-msg 钩子(约定式提交校验);支持配置 husky 或手动钩子;可在提交前自动格式化代码;能检测硬编码密钥、console.log、TODO 及超大文件。

使用方式:技能先读取 package.json、pyproject.toml 或 .git/hooks 判断项目类型。Node.js 项目安装 husky 与 lint-staged(npm install --save-dev husky lint-staged、npx husky init),并在 package.json 配置 lint-staged,随后生成 .husky/pre-commit、pre-push、commit-msg 脚本。Python 项目使用 pre-commit 框架,编辑 .pre-commit-config.yaml 配置 black、flake8、isort、mypy、pytest 等,再执行 pip install pre-commit、pre-commit install、pre-commit install --hook-type commit-msg。无包管理器项目可写 .git/hooks/pre-commit 手动脚本。支持 git commit -n 与 git push --no-verify 临时跳过。

适用场景:Node.js 或 Python 项目的提交与推送前自动化质量门禁,团队统一提交规范。

限制:需项目已初始化 Git;钩子工具与依赖版本需按资料配置;具体平台、收费与价格暂未提供。