AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified MIT Self-run

Setup Pre Commit

skill-wenwuzhidao-mattpocock-skills-zh-setup-pre-commit · by WenWuZhiDao

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

No reviews yet
0 installs
28 views
0.0% view→install

Install

$ agentstack add skill-wenwuzhidao-mattpocock-skills-zh-setup-pre-commit

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-wenwuzhidao-mattpocock-skills-zh-setup-pre-commit)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
2mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Setup Pre Commit? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

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

这会设置什么

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

步骤

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 中没有 typechecktest 脚本,则省略相应行并告知用户。

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)

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

注意事项

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

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.