AGENT SKILL

Husky提交前钩子配置

setup-pre-commit

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

License 许可
MIT
所属仓库
pkking/dotfiles
最近更新
2026-11-14
Stars
★ 0
Forks
0

01 前言 Front Matter

name
setup-pre-commit
description
Set up Husky pre-commit hooks with lint-staged (Prettier), type checking, and tests in the current repo. Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/typechecking/testing.

02 资源文件 1

03 SKILL.md 正文

Setup Pre-Commit Hooks

What This Sets Up

  • Husky pre-commit hook
  • lint-staged running Prettier on all staged files
  • Prettier config (if missing)
  • typecheck and test scripts in the pre-commit hook

Steps

1. Detect package manager

Check for package-lock.json (npm), pnpm-lock.yaml (pnpm), yarn.lock (yarn), bun.lockb (bun). Use whichever is present. Default to npm if unclear.

2. Install dependencies

Install as devDependencies:

husky lint-staged prettier

3. Initialize Husky

npx husky init

This creates .husky/ dir and adds prepare: "husky" to package.json.

4. Create .husky/pre-commit

Write this file (no shebang needed for Husky v9+):

npx lint-staged
npm run typecheck
npm run test

Adapt: Replace npm with detected package manager. If repo has no typecheck or test script in package.json, omit those lines and tell the user.

5. Create .lintstagedrc

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

6. Create .prettierrc (if missing)

Only create if no Prettier config exists. Use these defaults:

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

7. Verify

  • [ ] .husky/pre-commit exists and is executable
  • [ ] .lintstagedrc exists
  • [ ] prepare script in package.json is "husky"
  • [ ] prettier config exists
  • [ ] Run npx lint-staged to verify it works

8. Commit

Stage all changed/created files and commit with message: Add pre-commit hooks (husky + lint-staged + prettier)

This will run through the new pre-commit hooks: a good smoke test that everything works.

Notes

  • Husky v9+ doesn't need shebangs in hook files
  • prettier --ignore-unknown skips files Prettier can't parse (images, etc.)
  • The pre-commit runs lint-staged first (fast, staged-only), then full typecheck and tests

04 同仓库更多 Skills

pkking
pkking/dotfiles

前端界面视觉设计

frontend-design

在构建新 UI 或重塑现有 UI 时,提供有特色、有意为之的视觉设计指导。帮助把握美学方向、排版,并做出不显得千篇一律的模板化选择。

界面设计师前端开发与界面实现
★ 0
pkking
pkking/dotfiles

AIHOT AI 资讯查询

aihot

查询 AIHOT 的中文 AI 资讯、精选、当前热点和日报。用户询问今天或最近的 AI 新闻、AI 圈动态、大模型或产品发布、OpenAI/Anthropic/Google 最新消息、AI 论文、AI 日报、AIHOT 精选、当前最热事件,或需要同步当前全部精选时使用。必须通过 aihot.news 的匿名只读 API 获取当前数据,不凭训练记忆回答新闻;不需要 API Key 或 MCP server。

普通用户工具调用与实时数据查询
★ 0
pkking
pkking/dotfiles

文章段落塑形

writing-shape

写作,深入挖掘(exploit):把原始素材塑造成一篇文章,逐段推进。

内容创作者创意写作与内容编排
★ 0
pkking
pkking/dotfiles

Skill 编写规范参考

writing-great-skills

编写和编辑 skills 的参考指南——介绍让技能变得可预测的语言与原则。

AI 工程师插件与技能管理
★ 0
pkking
pkking/dotfiles

写作素材片段挖掘

writing-fragments

写作,探索(explore):挖掘原始片段,暂不组织结构。

内容创作者创意写作与内容编排
★ 0
pkking
pkking/dotfiles

智能体文档编写

writing-for-agents

为智能体(agent)编写文档。在创建或编辑 skills,或修改 AGENTS.md 或 CLAUDE.md 时使用。

AI 工程师智能体开发
★ 0