setup-pre-commit
Skill522 starsChanged 36 days agoMITView on GitHub
在当前仓库中设置 Husky pre-commit 钩子,集成 lint-staged(Prettier)、类型检查和测试。当用户想要添加 pre-commit 钩子、设置 Husky、配置 lint-staged、或添加提交时的格式化/类型检查/测试时使用。
124 other projects use a version of this, 107 of them edited.
Adopted by
Most recently taken up by
- 5thlayer/skillworksedited, first seen Nov 8, 2026
- dfirmin/compassedited, first seen Nov 8, 2026
- op3616windows/skillsedited, first seen Nov 8, 2026
- kazemcodes/skill-treeedited, first seen Nov 8, 2026
- shkodnik1917/claude-brainlabedited, first seen Nov 8, 2026
- Tresnanda/kybernedited, first seen Nov 8, 2026
Used with
Projects with it also use edit-article, request-refactor-plan and 2 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
simo97Skilledit-article
The user will invoke this skill to help them edit an article.
Also in 38 projects that use this
simo97Skillrequest-refactor-plan
Use this skill when user wants to create a refactor plan.
Also in 38 projects that use this
FabienDehopreSkilldecision-mapping
Turn a loose idea into a sequenced map of investigation tickets, then drive them to resolution one at a time.
Also in 6 projects that use this
- +1 more from simo97
Other versions124 projects use a version of this.
Word for word · 0
None found.
Edited · 107
- mattpocock/skills★ 309k12% same
- vinvcn/mattpocock-skills-zh-CN★ 5.5k29% same
- amazingloft999-droid/mattpocock-skills★ 42212% same
- InditexTech/weavejs★ 26612% same
- loulanyue/skills★ 23112% same
- tt-a1i/matt-skills-with-to-goal★ 19212% same
- aurorasoft2/Matt_Pocock_Skills★ 13312% same
- Tresnanda/kybern★ 8312% same
- VisualxIntelligence/mattpocok-skills★ 5512% same
- romiluz13/mifal★ 4410% same
97 more not listed
Wrote their own version · 17
- jrjsmrtn/project-orchestration-skills★ 17same name
- josortmel/EcoRelay★ 15same name
- imMamdouhaboammar/matts-skills-into-chatgpt★ 8same name
- Boom-Vitt/skills-thai★ 5same name
- amit-t/skills★ 4same name
- chrislacey89/skills★ 4same name
- kayaman/skills★ 3same name
- ForgeyClap/claude-forge★ 2same name
- ForgeyClap/Forge-Core★ 2same name
- pumpkit-io/sdlc★ 2same name
7 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository39 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- ask-mattSkill
- codebase-designSkill
- code-reviewSkill
- diagnosing-bugsSkill
- domain-modelingSkill
- grill-with-docsSkill
- implementSkill
- implement-specSkill
- improve-codebase-architectureSkill
- prototypeSkill
- prSkill
- researchSkill
- retroSkill
- setup-matt-pocock-skillsSkill
- tddSkill
- to-specSkill
- to-ticketsSkill
- triageSkill
- wayfinderSkill
- wizardSkill
- chief-of-staffSkill
- claude-handoffSkill
- loop-meSkill
- setup-ts-deep-modulesSkill
- software-factorySkill
- writing-beatsSkill
- writing-fragmentsSkill
- writing-shapeSkill
- git-guardrails-claude-codeSkill
- migrate-to-shoehornSkill
- scaffold-exercisesSkill
- grillingSkill
- grill-meSkill
- handoffSkill
- teachSkill
- to-questionnaireSkill
- wait-whatSkill
- writing-for-agentsSkill
The file
Files
设置 Pre-Commit 钩子
将要设置的内容
- Husky pre-commit 钩子
- lint-staged 对所有暂存文件运行 Prettier
- Prettier 配置(如果缺失)
- typecheck 和 test 脚本在 pre-commit 钩子中运行
步骤
1. 检测包管理器
检查 package-lock.json(npm)、pnpm-lock.yaml(pnpm)、yarn.lock(yarn)、bun.lockb(bun)。使用已存在的那个。如果不确定,默认使用 npm。
2. 安装依赖
安装为 devDependencies:
husky lint-staged prettier3. 初始化 Husky
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
{
"*": "prettier --ignore-unknown --write"
}6. 创建 .prettierrc(如果缺失)
仅当不存在 Prettier 配置时才创建。使用以下默认值:
{
"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)
这将触发新的 pre-commit 钩子执行:是一个很好的冒烟测试,验证一切正常。
注意事项
- Husky v9+ 不需要在钩子文件中加 shebang
prettier --ignore-unknown会跳过 Prettier 无法解析的文件(如图片等)- pre-commit 钩子先运行 lint-staged(快速,仅处理暂存文件),然后运行完整的 typecheck 和 test
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

