Setup Pre Commit logo

Setup Pre Commit

Community
WenWuZhiDao
setup-pre-commit

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

Overview

PublisherWenWuZhiDao
Repositorymattpocock-skills-zh
Skill namesetup-pre-commit
Stars
30
Forks
5
Bundled files
1
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by WenWuZhiDao on GitHub. Read the source before you install it.

Installation

Install the Setup Pre Commit AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/WenWuZhiDao/mattpocock-skills-zh/tree/main/skills/misc/setup-pre-commit
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/WenWuZhiDao/mattpocock-skills-zh.git /tmp/mattpocock-skills-zh
mkdir -p .claude/skills
cp -r /tmp/mattpocock-skills-zh/skills/misc/setup-pre-commit .claude/skills/setup-pre-commit
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Setup Pre Commit in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Setup Pre Commit on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Setup Pre Commit is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

设置预提交钩子(Pre-Commit Hooks)

这会设置什么

  • Husky 预提交钩子
  • lint-staged 对所有暂存文件运行 Prettier
  • Prettier 配置(如果缺失)
  • 预提交钩子中的 typecheck 和 test 脚本

步骤

1. 检测包管理器

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

2. 安装依赖

作为 devDependencies 安装:

husky lint-staged prettier

3. 初始化 Husky

bash
npx husky init

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

4. 创建 .husky/pre-commit

写入此文件(Husky v9+ 无需 shebang):

npx lint-staged
npm run typecheck
npm run test

适配:将 npm 替换为检测到的包管理器。如果仓库的 package.json 中没有 typecheck 或 test 脚本,则省略相应行并告知用户。

5. 创建 .lintstagedrc

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

6. 创建 .prettierrc(如果缺失)

仅在不存在 Prettier 配置时创建。使用以下默认值:

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

7. 验证

  • .husky/pre-commit 存在且可执行
  • .lintstagedrc 存在
  • package.json 中的 prepare 脚本为 "husky"
  • prettier 配置存在
  • 运行 npx lint-staged 验证其正常工作

8. 提交

暂存所有更改/创建的文件,并以这条信息提交:Add pre-commit hooks (husky + lint-staged + prettier)

这会跑一遍新的预提交钩子 —— 是验证一切正常的良好冒烟测试。

注意事项

  • Husky v9+ 的钩子文件不需要 shebang
  • prettier --ignore-unknown 会跳过 Prettier 无法解析的文件(图片等)
  • 预提交会先运行 lint-staged(快速,仅针对暂存文件),然后运行完整的类型检查和测试

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Setup Pre Commit AI skill do?

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

Why use Setup Pre Commit on TypingMind?

Because you install it once and use it with any model. Setup Pre Commit is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Setup Pre Commit in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/WenWuZhiDao/mattpocock-skills-zh/tree/main/skills/misc/setup-pre-commit. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Setup Pre Commit?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Setup Pre Commit?

As many as you like. As long as a model supports skills, you can use Setup Pre Commit with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Setup Pre Commit AI skill free?

Yes. It is published on GitHub by WenWuZhiDao under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇