Agent skill

Setup Pre Commit

by vinvcn in vinvcn/mattpocock-skills-zh-CN

在当前仓库设置 Husky pre-commit hooks,集成 lint-staged (Prettier)、类型检查和测试。适用于用户想添加 pre-commit hooks、设置 Husky、配置 lint-staged,或在提交时运行格式化、类型检查和测试时。

MITAuto-check passedDevelopment

Install Setup Pre Commit

skills CLI
$ npx skills add vinvcn/mattpocock-skills-zh-CN --skill setup-pre-commit -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install vinvcn/mattpocock-skills-zh-CN setup-pre-commit --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/vinvcn/mattpocock-skills-zh-CN.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/misc/setup-pre-commit .claude/skills/setup-pre-commit && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
setup-pre-commit
GitHub stars
4.7k
Token cost
~463 tokens
SKILL.md length
148 words
Files
2
Skills in repo
33
Repo updated
First seen
Licence
MIT

At a glance

在当前仓库设置 Husky pre-commit hooks,集成 lint-staged (Prettier)、类型检查和测试。适用于用户想添加 pre-commit hooks、设置 Husky、配置 lint-staged,或在提交时运行格式化、类型检查和测试时。

  • Works in 8 steps: Detect package manager → Install dependencies → Initialize Husky → …
  • Tasks that involve Linting and formatting
  • SKILL.md covers What This Sets Up, Steps and Notes
  • Calls npx, npm and prettier

What it does

Setup Pre Commit is an agent skill from vinvcn/mattpocock-skills-zh-CN. 在当前仓库设置 Husky pre-commit hooks,集成 lint-staged (Prettier)、类型检查和测试。适用于用户想添加 pre-commit hooks、设置 Husky、配置 lint-staged,或在提交时运行格式化、类型检查和测试时。

Its SKILL.md is about 460 tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files (for example `agents/openai.yaml`).

It sits in Development, covering Linting and formatting. It works with Prettier and npm. The repository describes itself as: 这是 mattpocock/skills 的简体中文本地化版本。 The licence is MIT.

When your agent uses it

  • Tasks that involve Linting and formatting

Example prompts

  • “/setup-pre-commit”

Requirements

  • Node.js

Workflow steps

8 steps, taken from the step headings in SKILL.md.

  1. Detect package manager
  2. Install dependencies
  3. Initialize Husky
  4. Create .husky/pre-commit
  5. Create .lintstagedrc
  6. Create .prettierrc (if missing)
  7. Verify
  8. Commit

What it can do on your machine

Read from SKILL.md and the folder at commit 3f92a83. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • npx
    • npm
    • prettier

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use npx and npm, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Setup Pre Commit loads about 463 tokens when it runs. Until then it costs about 38 tokens; SKILL.md has 148 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~38
When it runs · the whole SKILL.md, loaded when a task matches
~463

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from vinvcn/mattpocock-skills-zh-CN at commit 3f92a83, republished under its MIT licence (© vinvcn). 148 words, ~463 tokens.

Download SKILL.mdSave it as .claude/skills/setup-pre-commit/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
setup-pre-commit
description
在当前仓库设置 Husky pre-commit hooks,集成 lint-staged (Prettier)、类型检查和测试。适用于用户想添加 pre-commit hooks、设置 Husky、配置 lint-staged,或在提交时运行格式化、类型检查和测试时。

Setup Pre-Commit Hooks

What This Sets Up

  • Husky pre-commit hook
  • lint-staged 对所有 staged files 运行 Prettier
  • Prettier config(如果缺失)
  • pre-commit hook 中的 typecheck 和 test 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
bash
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 没有 typecheck 或 test script,就省略对应行并告知用户。

5. Create .lintstagedrc
json
{
  "*": "prettier --ignore-unknown --write"
}
6. Create .prettierrc (if missing)

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

json
{
  "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

© vinvcn, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in skills/misc/setup-pre-commit of vinvcn/mattpocock-skills-zh-CN.

  • SKILL.md
  • agents/openai.yaml

Open the folder on GitHubat commit 3f92a83

Compare with similar skills

Setup Pre Commit next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Setup Pre Commit compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Setup Pre Commit this skillvinvcn/mattpocock-skills-zh-CN4.7k—~463Automated safety check: PassMIT
Setup Pre Commitfossasia/eventyay-interpretation1.6k13 repos~565Automated safety check: PassApache-2.0
Git PR Workflowandymai/brepjs114—~2.9kAutomated safety check: PassApache-2.0
Setup Pre Commitdevcxl/mattpocock-skills-zh437—~412Automated safety check: PassMIT
Static Code Analysis Typescriptjaktestowac/awesome-copilot-for-testers116—~4.2kAutomated safety check: PassMIT
Code Formatterjeremylongshore/tons-of-skills-marketplace2.8k—~1.2kAutomated safety check: PassMIT

Similar skills

  • Setup Pre Commit

    fossasia/eventyay-interpretation

    Set up Husky pre-commit hooks with lint-staged (Prettier), type checking, and tests in the current repo.

    1.6k GitHub starsUsed in 13 repos~565 tokens
    DevelopmentAuto-check passed
  • Git PR Workflow

    andymai/brepjs

    This skill should be used when committing, pushing, branching, or merging in the brepjs repository — when a task involves "pre-commit hook failed" (which tier ran, how to bypass), "commit rejected…

    114 GitHub stars~2.9k tokensUpdated today
    DevelopmentAuto-check passed
  • Setup Pre Commit

    devcxl/mattpocock-skills-zh

    在当前仓库中设置 Husky pre-commit 钩子,集成 lint-staged(Prettier)、类型检查和测试。当用户想要添加 pre-commit 钩子、设置 Husky、配置 lint-staged、或添加提交时的格式化/类型检查/测试时使用。

    437 GitHub stars~412 tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Static Code Analysis Typescript

    jaktestowac/awesome-copilot-for-testers

    Creates, reviews, and modernizes static code analysis setups for Node.js and TypeScript repositories, covering ESLint flat config, typescript-eslint, tsconfig, Prettier, import sorting, Husky…

    116 GitHub stars~4.2k tokensUpdated 1 mo ago
    DevelopmentAuto-check passed
  • Code Formatter

    jeremylongshore/tons-of-skills-marketplace

    Execute automatically formats and validates code files using Prettier and other formatting tools.

    2.8k GitHub stars~1.2k tokensUpdated today
    DevelopmentAuto-check passed
  • Hook Commits

    danielvm-git/bigpowers

    Set up pre-commit hooks with lint-staged (Prettier), type checking, and tests in the current repo.

    257 GitHub stars~623 tokensUpdated 17 days ago
    DevelopmentAuto-check passed

More from vinvcn/mattpocock-skills-zh-CN

All 33 skills in this repo
  • Git Guardrails Claude Code

    vinvcn/mattpocock-skills-zh-CN

    设置 Claude Code hooks,在危险 git commands(push、reset --hard、clean、branch -D 等)执行前阻止它们。适用于用户想防止破坏性 git 操作、添加 git safety hooks,或在 Claude Code 中阻止 git push/reset 时。

    4.7k GitHub stars~474 tokensUpdated 10 days ago
    Auto-check passed
  • Codebase Design

    vinvcn/mattpocock-skills-zh-CN

    用于设计深模块的共享词汇。适用于用户想设计或改进模块接口、寻找深化机会、决定 seam 放在哪里、让代码更容易测试或更适合 AI 导航,或其他技能需要深模块词汇时。

    4.7k GitHub stars~1.1k tokensUpdated 10 days ago
    Auto-check passed
  • Diagnosing Bugs

    vinvcn/mattpocock-skills-zh-CN

    面向棘手缺陷和性能回退的诊断循环。适用于用户说 “diagnose” / “debug this”,或报告某些东西 broken、throwing、failing、slow 时。

    4.7k GitHub stars~1.4k tokensUpdated 10 days ago
    Auto-check passed
  • Domain Modeling

    vinvcn/mattpocock-skills-zh-CN

    构建并打磨项目的领域模型。适用于讨论 codebase 术语、编写或编辑 CONTEXT.md,或记录或编辑 ADR. An agent skill from vinvcn/mattpocock-skills-zh-CN.

    4.7k GitHub stars~505 tokensUpdated 10 days ago
    Auto-check passed
  • Migrate To Shoehorn

    vinvcn/mattpocock-skills-zh-CN

    将测试文件从 as 类型断言迁移到 @total-typescript/shoehorn。适用于用户提到 shoehorn、想替换测试中的 as,或需要局部测试数据时。

    4.7k GitHub stars~619 tokensUpdated 10 days ago
    Auto-check passed
  • PR

    vinvcn/mattpocock-skills-zh-CN

    用于撰写 PR 正文。适用于用户要求起草、改写或改进 PR 正文,或希望 PR 更便于审阅时. An agent skill from vinvcn/mattpocock-skills-zh-CN.

    4.7k GitHub stars~737 tokensUpdated 10 days ago
    Auto-check passed

Works with

Categories

Questions about Setup Pre Commit

What does Setup Pre Commit do?

在当前仓库设置 Husky pre-commit hooks,集成 lint-staged (Prettier)、类型检查和测试。适用于用户想添加 pre-commit hooks、设置 Husky、配置 lint-staged,或在提交时运行格式化、类型检查和测试时。. Setup Pre Commit is an agent skill from vinvcn/mattpocock-skills-zh-CN.

When should I use Setup Pre Commit?

Setup Pre Commit fits situations like: tasks that involve Linting and formatting.

How do I install Setup Pre Commit in Claude Code?

Run `npx skills add vinvcn/mattpocock-skills-zh-CN --skill setup-pre-commit -a claude-code`. Or copy the skill folder (skills/misc/setup-pre-commit in vinvcn/mattpocock-skills-zh-CN) into .claude/skills/setup-pre-commit in your project. Claude Code loads it when a task matches its description.

How do I install Setup Pre Commit in Codex?

Run `npx skills add vinvcn/mattpocock-skills-zh-CN --skill setup-pre-commit -a codex`. Or copy the skill folder (skills/misc/setup-pre-commit in vinvcn/mattpocock-skills-zh-CN) into .agents/skills/setup-pre-commit in your project. Codex loads it when a task matches its description.

Can I use Setup Pre Commit in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add vinvcn/mattpocock-skills-zh-CN --skill setup-pre-commit -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/setup-pre-commit, .gemini/skills/setup-pre-commit, .github/skills/setup-pre-commit and .opencode/skills/setup-pre-commit in your project.

What does Setup Pre Commit need to run?

Going by SKILL.md and its folder, Setup Pre Commit needs the command-line tools its instructions call (npx, npm and prettier). Our summary lists: Node.js.

Does Setup Pre Commit access the network?

SKILL.md contains no URLs. Its commands use npx and npm, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Setup Pre Commit safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Setup Pre Commit use?

Setup Pre Commit is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Setup Pre Commit use?

About 463 tokens (SKILL.md is roughly 1.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Setup Pre Commit?

Skills that share tags, products or a category with Setup Pre Commit: Setup Pre Commit (fossasia/eventyay-interpretation, 1.6k stars), Git PR Workflow (andymai/brepjs, 114 stars), Setup Pre Commit (devcxl/mattpocock-skills-zh, 437 stars) and Static Code Analysis Typescript (jaktestowac/awesome-copilot-for-testers, 116 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Setup Pre Commit?

vinvcn (a GitHub user) maintains it in vinvcn/mattpocock-skills-zh-CN, which has 4,657 GitHub stars. The repository holds 33 skills in this directory. The repository was last updated on September 28, 2026.

Source: vinvcn/mattpocock-skills-zh-CN on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.