본문으로 건너뛰기
cccskills
무료GitHub에 공개

setup-pre-commit

Set up checks that run before each commit using Husky, lint-staged, and Prettier. Format staged files, run existing type-check and test scripts, then verify and commit the configuration.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

在当前仓库设置 Husky pre-commit hooks,集成 lint-staged (Prettier)、类型检查和测试。适用于用户想添加 pre-commit hooks、设置 Husky、配置 lint-staged,或在提交时运行格式化、类型检查和测试时。

설치 방법 보기

이럴 때 유용합니다

  • Adding automated checks before commits
  • Formatting staged files with Prettier
  • Running type checks and tests before committing
  • Setting up and verifying Husky hooks

포함된 파일(2)

  • SKILL.md2.3 KB
  • agents/openai.yaml97 B

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

设置 Pre-Commit Hooks

这会配置什么

  • Husky pre-commit hook
  • lint-staged 对所有 staged files 运行 Prettier
  • Prettier config(如果缺失)
  • pre-commit hook 中的 typecheck 和 test scripts

步骤

1. 检测 package manager

检查 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/ dir,并向 package.json 添加 prepare: "husky"。

4. 创建 .husky/pre-commit

写入这个文件(Husky v9+ 不需要 shebang):

npx lint-staged
npm run typecheck
npm run test

Adapt:把 npm 替换为检测到的 package manager。如果 repo 的 package.json 没有 typecheck 或 test script,就省略对应行并告知用户。

5. 创建 .lintstagedrc

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

6. 创建 .prettierrc(如果缺失)

只有没有 Prettier config 时才创建。使用这些 defaults:

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

7. 验证

  • .husky/pre-commit 存在且可执行
  • .lintstagedrc 存在
  • package.json 中的 prepare script 是 "husky"
  • prettier config 存在
  • 运行 npx lint-staged 验证可用

8. 提交

Stage 所有 changed/created files,并用 message 提交:Add pre-commit hooks (husky + lint-staged + prettier)

这会经过新的 pre-commit hooks,是一个不错的 smoke test。

备注

  • Husky v9+ 不需要 hook files 中的 shebangs
  • prettier --ignore-unknown 会跳过 Prettier 无法 parse 的 files(images 等)
  • pre-commit 先运行 lint-staged(快,只针对 staged files),再运行完整 typecheck 和 tests

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

ask-matt

무료

Find the right skill and sequence for your current development task, from shaping an idea to implementation, debugging, and review. The guide also explains when to prototype, prepare specifications, or move work into a fresh session.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Choose a workflow for turning an idea into working software
  • Find the starting point for a difficult bug investigation
  • Plan specifications and tickets for work across multiple sessions
vinvcn/mattpocock-skills-zh-CN5.1천2026년 10월 20일 업데이트

Summarize the current conversation and launch a fresh background agent to continue the work. The handoff includes references to existing artifacts and suggested skills, removes sensitive information, and can emphasize the next session’s intended focus.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Continue ongoing work with a fresh agent
  • Focus the next session on a specific task
  • Hand off work using references to existing documents
vinvcn/mattpocock-skills-zh-CN5.1천2026년 10월 20일 업데이트

Review changes from a chosen Git reference against both project coding standards and issue or specification requirements. Separate parallel reviews report rule violations, possible design problems, missing requirements, and changes beyond the intended scope.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Review a branch or pull request
  • Check changes since a specific commit
  • Find missing requirements or unintended scope
vinvcn/mattpocock-skills-zh-CN5.1천2026년 10월 20일 업데이트

Design modules that expose simple interfaces while hiding substantial behavior. Use shared terms and principles to assess interface complexity, decide where behavior can be swapped, and organize code so callers and tests use the same interface.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Simplify a module interface
  • Review module structure during refactoring
  • Decide where behavior should be swappable
vinvcn/mattpocock-skills-zh-CN5.1천2026년 10월 20일 업데이트

Diagnose difficult bugs and performance regressions by first building a repeatable check for the exact symptom. Minimize the reproduction, test ranked hypotheses, apply a fix, and verify the original scenario with regression tests where suitable.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Investigating persistent errors or incorrect output
  • Increasing reproduction rates for intermittent bugs
  • Measuring and diagnosing performance regressions
vinvcn/mattpocock-skills-zh-CN5.1천2026년 10월 20일 업데이트

Clarify project terminology and the relationships between business concepts. Check definitions against concrete scenarios and code, update GLOSSARY.md as terms are agreed, and record significant design decisions with their trade-offs when the stated criteria are met.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Clarifying ambiguous project terminology
  • Creating or updating GLOSSARY.md
  • Checking concept boundaries against code and edge cases
vinvcn/mattpocock-skills-zh-CN5.1천2026년 10월 20일 업데이트

vinvcn의 스킬 모두 보기

이 스킬의 문제 신고