setup-pre-commit
Skill0 starsChanged 6 months agoMITView on GitHub
在当前 repo 中设置带 lint-staged(Prettier)、type checking 和 tests 的 Husky pre-commit hooks。当用户想添加 pre-commit hooks、设置 Husky、配置 lint-staged,或添加 commit-time formatting/typechecking/testing 时使用。
124 other projects use a version of this, 113 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 setup-ts-deep-modules, loop-me 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.
liufeng1976Skillsetup-ts-deep-modules
Wire dependency-cruiser into a TypeScript repo so each package is a deep module — implementation hidden in subfolders, reachable only through its entry-point files. User-invoked.
Also in 41 projects that use this
RoentekSkillloop-me
Grill me about specs for the workflows I want to build, within this workspace.
Also in 52 projects that use this
ryotaroh180105Skillclaude-handoff
Hand the current conversation off to a fresh background agent that picks up the work immediately.
Also in 39 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
Other versions124 projects use a version of this.
Word for word · 0
None found.
Edited · 113
- mattpocock/skills★ 309k21% same
- vinvcn/mattpocock-skills-zh-CN★ 5.5k50% same
- devcxl/mattpocock-skills-zh★ 52225% same
- amazingloft999-droid/mattpocock-skills★ 42221% same
- InditexTech/weavejs★ 26621% same
- loulanyue/skills★ 23121% same
- tt-a1i/matt-skills-with-to-goal★ 19221% same
- aurorasoft2/Matt_Pocock_Skills★ 13321% same
- Tresnanda/kybern★ 8321% same
- VisualxIntelligence/mattpocok-skills★ 5521% same
103 more not listed
Wrote their own version · 11
- jrjsmrtn/project-orchestration-skills★ 17same name
- josortmel/EcoRelay★ 15same name
- imMamdouhaboammar/matts-skills-into-chatgpt★ 8same name
- amit-t/skills★ 4same name
- chrislacey89/skills★ 4same name
- christofferbergj/agent-skills★ 1same name
- manastalukdar/ai-devstudio★ 1same name
- mauriciovieira/skills★ 1same name
- snowfluke/engineering-skills★ 1same name
- Thalisu/SKILLS★ 1same name
1 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 repository29 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- design-an-interfaceSkill
- qaSkill
- request-refactor-planSkill
- ubiquitous-languageSkill
- diagnoseSkill
- grill-with-docsSkill
- improve-codebase-architectureSkill
- prototypeSkill
- setup-matt-pocock-skillsSkill
- tddSkill
- to-issuesSkill
- to-prdSkill
- triageSkill
- zoom-outSkill
- reviewSkill
- writing-beatsSkill
- writing-fragmentsSkill
- writing-shapeSkill
- git-guardrails-claude-codeSkill
- migrate-to-shoehornSkill
- scaffold-exercisesSkill
- edit-articleSkill
- obsidian-vaultSkill
- cavemanSkill
- grill-meSkill
- handoffSkill
- write-a-skillSkill
The file
Files
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 prettier3. 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 testAdapt:把 npm 替换为检测到的 package manager。如果 repo 的 package.json 中没有 typecheck 或 test script,省略对应行并告诉用户。
5. Create .lintstagedrc
{
"*": "prettier --ignore-unknown --write"
}6. Create .prettierrc(如果缺失)
只有在不存在 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 中的
preparescript 是"husky" prettierconfig 存在- 运行
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 无法解析的 files(images 等)- pre-commit 会先运行 lint-staged(快,只处理 staged-only),然后运行完整 typecheck 和 tests
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.

