setup-pre-commit
仓库创建 2026年7月6日最近提交 22 天前SkillHot 收录 22 天前
▸ 精选理由
一键在项目中建立提交质量门槛,适合希望统一代码规范的团队。
▸ 风险提示
会修改仓库配置并安装依赖(npm/pnpm/yarn),可能触发外部包安装。
这个 Skill 做什么
在仓库中自动配置 Husky、lint-staged、Prettier 及提交时的类型检查/测试流程。
在代码仓库里一键配置 Husky 的 pre-commit 钩子,配合 lint-staged 自动跑 Prettier,并在提交时做类型检查和跑测试。需要给项目加提交时的格式化/类型校验/测试保障时用,能自动识别常见包管理器。特点是把格式化、typecheck 和 test 都塞进提交流程,能显著降低不合格代码被提交的几率。
▸ 展开 SKILL.md 英文原文
Set up Husky pre-commit hooks with lint-staged (Prettier), type checking, and tests in the current repo. Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/typechecking/testing.
0
Stars
0
Forks
38
仓库内 Skill
+0
7 日增星
安装 / 使用
给你的 Agent 一句话(通用)
帮我安装这个 skill:https://raw.githubusercontent.com/K3639284/skills/main/skills/misc/setup-pre-commit/SKILL.md或 curl 直取 SKILL.md
curl -fsSL "https://raw.githubusercontent.com/K3639284/skills/main/skills/misc/setup-pre-commit/SKILL.md"SKILL.MD 节选查看完整文件 ↗
# Setup Pre-Commit Hooks ## What This Sets Up - **Husky** pre-commit hook - **lint-staged** running Prettier on all staged files - **Prettier** config (if missing) - **typecheck** and **test** scripts in the pre-commit hook ## Steps ### 1. Detect package manager Check for `package-lock.json` (npm), `pnpm-lock.yaml` (pnpm), `yarn.lock` (yarn), `bun.lockb` (bun). Use whichever is present. Default to npm if unclear. ### 2. Install dependencies Install as devDependencies: ``` husky lint-staged prettier ``` ### 3. Initialize Husky ```bash npx husky init ``` This creates `.husky/` dir and adds `prepare: "husky"` to package.json. ### 4. Create `.husky/pre-commit` Write this file (no sh
via SKILL·HOT · 数据来自 GitHub 公开信息 · 原文版权归作者所有