Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
vinvcn avatar

Setup Pre Commit

  • 3.3k installs
  • 2.8k repo stars
  • Updated July 27, 2026
  • vinvcn/mattpocock-skills-zh-cn

setup-pre-commit is an agent skill that 在当前 repo 设置 Husky pre-commit hooks,集成 lint-staged (Prettier)、type checking 和 tests。Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or ad.

About

The setup-pre-commit skill. 在当前 repo 设置 Husky pre-commit hooks,集成 lint-staged (Prettier)、type checking 和 tests。Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/typechecking/testing. Detect package manager 检查 (npm)、 (pnpm)、 (yarn)、 (bun)。使用存在的那个。不清楚时默认 npm。 ### 2. Install dependencies 作为 devDependencies 安装: ### 3. Initialize Husky 这会创建 dir,并向 package.json 添加 。 ### 4. Create 写入这个文件(Husky v9+ 不需要 shebang): **Adapt**:把 替换为检测到的 package manager。如果 repo 的 package.json 没有 或 script,就省略对应行并告知用户。 ### 5. Create (if missing) 只有没有 Prettier config 时才创建。使用这些 defaults: ### 7. Verify - [ ] 存在且可执行 - [ ] 存在 - [ ] package.json 中的 script 是 - [ ] prettier config 存在 - [ ] 运行 验证可用 ### 8. The workflow follows the source SKILL.md contract with progressive reference loading, clear trigger phrases, and practical steps developers can apply directly in agent sessions.

  • Husky pre-commit hook
  • lint-staged 对所有 staged files 运行 Prettier
  • Prettier config(如果缺失)
  • pre-commit hook 中的 typecheck 和 test scripts
  • [ ] `.husky/pre-commit` 存在且可执行

Setup Pre Commit by the numbers

  • 3,252 all-time installs (skills.sh)
  • +402 installs in the week ending Aug 2, 2026 (Skillselion tracking)
  • Ranked #50 of 1,438 DevOps & CI/CD skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Aug 3, 2026 (Skillselion catalog sync)
At a glance

setup-pre-commit capabilities & compatibility

Capabilities
husky pre commit hook · lint staged 对所有 staged files 运行 prettier · prettier config(如果缺失) · pre commit hook 中的 typecheck 和 test scripts · [ ] `.husky/pre commit` 存在且可执行
Use cases
testing · debugging · ci cd
npx skills add https://github.com/vinvcn/mattpocock-skills-zh-cn --skill setup-pre-commit

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs3.3k
repo stars2.8k
Security audit3 / 3 scanners passed
Last updatedJuly 27, 2026
Repositoryvinvcn/mattpocock-skills-zh-cn

How do I apply setup-pre-commit correctly using the SKILL.md workflows and reference files?

在当前 repo 设置 Husky pre-commit hooks,集成 lint-staged (Prettier)、type checking 和 tests。Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/typec

Who is it for?

Developers and software engineers working with setup-pre-commit patterns from the skill documentation.

Skip if: Skip when cached docs are empty, boilerplate-only, or outside the skill documented scope.

When should I use this skill?

在当前 repo 设置 Husky pre-commit hooks,集成 lint-staged (Prettier)、type checking 和 tests。Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/typechecking/testing.

What you get

Grounded setup-pre-commit guidance with highlights, triggers, and evidence quotes from SKILL.md.

  • .husky pre-commit hook
  • lint-staged configuration

Files

SKILL.mdMarkdownGitHub ↗

Setup Pre-Commit Hooks

What This Sets Up

  • Husky pre-commit hook
  • lint-staged 对所有 staged files 运行 Prettier
  • Prettier config(如果缺失)
  • pre-commit hook 中的 typechecktest scripts

Steps

1. Detect package manager

检查 package-lock.json (npm)、pnpm-lock.yaml (pnpm)、yarn.lock (yarn)、bun.lockb (bun)。使用存在的那个。不清楚时默认 npm。

2. Install dependencies

作为 devDependencies 安装:

husky lint-staged prettier

3. Initialize Husky

npx husky init

这会创建 .husky/ dir,并向 package.json 添加 prepare: "husky"

4. Create .husky/pre-commit

写入这个文件(Husky v9+ 不需要 shebang):

npx lint-staged
npm run typecheck
npm run test

Adapt:把 npm 替换为检测到的 package manager。如果 repo 的 package.json 没有 typechecktest script,就省略对应行并告知用户。

5. Create .lintstagedrc

{
  "*": "prettier --ignore-unknown --write"
}

6. Create .prettierrc (if missing)

只有没有 Prettier config 时才创建。使用这些 defaults:

{
  "useTabs": false,
  "tabWidth": 2,
  "printWidth": 80,
  "singleQuote": false,
  "trailingComma": "es5",
  "semi": true,
  "arrowParens": "always"
}

7. Verify

  • [ ] .husky/pre-commit 存在且可执行
  • [ ] .lintstagedrc 存在
  • [ ] package.json 中的 prepare script 是 "husky"
  • [ ] prettier config 存在
  • [ ] 运行 npx lint-staged 验证可用

8. Commit

Stage 所有 changed/created files,并用 message 提交:Add pre-commit hooks (husky + lint-staged + prettier)

这会经过新的 pre-commit hooks,是一个不错的 smoke test。

Notes

  • Husky v9+ 不需要 hook files 中的 shebangs
  • prettier --ignore-unknown 会跳过 Prettier 无法 parse 的 files(images 等)
  • pre-commit 先运行 lint-staged(快,只针对 staged files),再运行完整 typecheck 和 tests

Related skills

How it compares

Use setup-pre-commit for opinionated Husky plus lint-staged JS setup rather than manual hook scripting from scratch.

FAQ

Who is setup-pre-commit for?

Developers and software engineers working with setup-pre-commit patterns from the skill documentation.

When should I use setup-pre-commit?

在当前 repo 设置 Husky pre-commit hooks,集成 lint-staged (Prettier)、type checking 和 tests。Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/typechecking/testing.

Is setup-pre-commit safe to install?

Review the Security Audits panel on this page before installing in production.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.