Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add skills/devcxl/mattpocock-skills-zh/setup-pre-commitnpx skills add devcxl/mattpocock-skills-zh --skill setup-pre-commitgit clone --depth 1 https://github.com/devcxl/mattpocock-skills-zhWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/devcxl/mattpocock-skills-zh/setup-pre-commit)<a href="https://agentmods.dev/skills/devcxl/mattpocock-skills-zh/setup-pre-commit"><img src="https://agentmods.dev/badge/skills/devcxl/mattpocock-skills-zh/setup-pre-commit.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00070 | $0.00744 |
| Opus 5 | $0.00035 | $0.00372 |
| Sonnet 5 | $0.00014 | $0.00149 |
| Haiku 4.5 | $0.00007 | $0.00074 |
Grade A, and why
setup-pre-commit scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
What it actually says
设置 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 prettier
3. 初始化 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
What ships with it
1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 5d ago First seen · 92 lines · 70 tokens per session scan A 019d16766d33
setup-pre-commit is a skill published in the GitHub repository devcxl/mattpocock-skills-zh (299 stars, last pushed 9d ago), licensed MIT. It adds 70 tokens to every session and 744 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
chinese-commit-conventions
中文 commit 与 changelog 配置参考——Conventional Commits 中文适配、commitlint/husky/commitizen 中文模板、conventional-changelog 中文配置。仅在用户显式 /chinese-commit-conventions 时调用,不要根据上下文自动触发。.
dsh-git-commit
提交代码时使用:按约定式提交写 commit message,并在提交前做最小自检。.
chinese-commit
写 git commit 时使用。生成规范的 Conventional Commits(英文 type + 中文主题),主题精炼。.
commit
Create a git commit with clear, conventional commit messages. You MUST read this when the user wants to commit staged changes, write a commit message, or finalize code changes with proper conventional commit format since it describes how to follow the user's specific requirements.
commit
Smart commit with Ollama-generated messages. Conventional commits, auto-push option. Triggers on: commit this, commit changes, smart commit, /commit.
chinese-documentation
中文文档排版参考——中英文空格、全半角标点、术语保留、链接格式、中文文案排版指北约定。仅在用户显式 /chinese-documentation 时调用,不要根据上下文自动触发。.