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

setup-pre-commit

Set up repository-local Husky pre-commit hooks with lint-staged, Prettier, and optional typecheck/test gates. Use when a user asks to add pre-commit hooks, configure lint-staged, enforce staged formatting, or add commit-time checks.

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

설치 방법 보기

포함된 파일(1)

  • SKILL.md6.1 KB

SKILL.md(원문)

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

setup-pre-commit

Guides a safe, repo-aware pre-commit setup. This skill is guidance-first: inspect the target repository, explain the planned changes, and only mutate dependency, hook, package, lint-staged, or Prettier files after the user approves that setup.

What this configures

  • Husky v9+ with a .husky/pre-commit hook
  • lint-staged running Prettier on staged files
  • Prettier defaults only when no Prettier config exists
  • Optional typecheck and test commands only when the target package.json already defines those scripts
  • Verification commands and a real commit smoke test when the user is ready to commit setup changes

1. Preflight the target repo

Work from the target repo root, then inspect existing package and config state before proposing commands:

git status --short
node -e "const fs=require('fs'); const p=JSON.parse(fs.readFileSync('package.json','utf8')); process.stdout.write(JSON.stringify({packageManager:p.packageManager||null,scripts:p.scripts||{}}, null, 2)+'\n');"
node -e "const fs=require('fs'); const files=['bun.lock','bun.lockb','pnpm-lock.yaml','yarn.lock','package-lock.json','.lintstagedrc','.lintstagedrc.json','.lintstagedrc.js','lint-staged.config.js','.prettierrc','.prettierrc.json','.prettierrc.js','prettier.config.js','prettier.config.cjs','prettier.config.mjs']; process.stdout.write(files.filter((f)=>fs.existsSync(f)).join('\n')+'\n');"

Stop and ask before editing if the repo has unrelated dirty changes, multiple package managers, or an existing hook/config whose intent is unclear.

2. Detect the package manager

Prefer the packageManager field in package.json, then lockfiles:

SignalPackage manager
packageManager starts with bun or bun.lock / bun.lockb existsBun
packageManager starts with pnpm or pnpm-lock.yaml existspnpm
packageManager starts with yarn or yarn.lock existsYarn
packageManager starts with npm or package-lock.json existsnpm

If there is no clear signal, default to npm only after telling the user that no lockfile or package-manager pin was found.

3. Install dev dependencies

Use exactly one command for the detected package manager:

Package managerCommand
Bunbun add --dev husky lint-staged prettier
pnpmpnpm add --save-dev husky lint-staged prettier
Yarnyarn add --dev husky lint-staged prettier --non-interactive
npmnpm install --save-dev husky lint-staged prettier --yes

Do not run these commands while porting this skill. Run them only when applying the skill to a target repo with user approval.

4. Initialize Husky

After dependencies are installed, initialize Husky with the detected package manager:

Package managerCommand
Bunbunx --bun husky init
pnpmpnpm exec husky init
Yarnyarn exec husky init
npmnpx --yes husky init

Husky v9+ creates .husky/pre-commit and usually adds prepare: "husky" to package.json. Preserve an existing prepare script by combining commands only if the user approves the exact package script change.

5. Compose .husky/pre-commit

The hook must run lint-staged first, then only the package scripts that already exist. Do not add failing placeholder lines for missing scripts.

Package managerlint-staged lineExisting typecheck scriptExisting test script
Bunbunx --bun lint-stagedbun run typecheckbun run test
pnpmpnpm exec lint-stagedpnpm run typecheckpnpm run test
Yarnyarn exec lint-stagedyarn run typecheckyarn run test
npmnpx --no-install lint-stagednpm run typechecknpm run test

Example for a Bun repo that has both scripts:

bunx --bun lint-staged
bun run typecheck
bun run test

If the repo lacks typecheck or test, omit that line and tell the user which check was skipped.

6. Configure lint-staged and Prettier

Respect existing config:

  1. If a lint-staged config already exists, update it only after confirming it should run Prettier on staged files.
  2. If no lint-staged config exists, add one config location that matches repo style. Prefer an existing package.json config style if the repo already keeps tool config there; otherwise use .lintstagedrc.json.
  3. Use this minimal lint-staged config:
{
  "*": "prettier --ignore-unknown --write"
}
  1. If any Prettier config exists, do not overwrite it.
  2. If no Prettier config exists, propose these defaults:
{
  "useTabs": false,
  "tabWidth": 2,
  "printWidth": 80,
  "singleQuote": false,
  "trailingComma": "es5",
  "semi": true,
  "arrowParens": "always"
}

prettier --ignore-unknown lets staged binary or unsupported files pass without parse failures.

7. Verify

Run only commands that match the detected package manager and existing scripts:

git status --short
  • Confirm .husky/pre-commit exists and contains the selected lint-staged line.
  • Confirm package.json has a valid Husky prepare script without clobbering previous behavior.
  • Confirm lint-staged config exists and Prettier config is preserved or created intentionally.
  • Run the selected lint-staged command with staged setup files.
  • Run the selected typecheck/test commands only if those scripts exist.

8. Smoke test with a real commit

When the user is ready to commit the setup, use the normal commit as the smoke test:

git add package.json .husky/pre-commit .lintstagedrc.json .prettierrc
git commit -m "chore: add pre-commit checks"

Adjust the git add paths to the files actually changed. Do not create an empty or throwaway commit just to test the hook, and do not run a commit smoke test unless the user explicitly wants the setup committed.

리뷰

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

댓글

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

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

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

0 / 1,000자

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

같은 저장소의 스킬

add-bead

무료

Capture free-text work as a tracked Beads issue. Use when the user runs /add-bead or wants to quickly file a Beads issue.

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

jupes/agent-forge-harness22026년 10월 19일 업데이트

add-repo

무료

Register a new sub-repo in the knowledge base.

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

jupes/agent-forge-harness22026년 10월 19일 업데이트

Add focused Bun unit tests for mission-critical behavior and edge cases — not blanket coverage.

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

jupes/agent-forge-harness22026년 10월 19일 업데이트

ask

무료

Answer questions about the codebase from knowledge files. Use when the user runs /ask or asks a domain/knowledge question about the repos.

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

jupes/agent-forge-harness22026년 10월 19일 업데이트

Meta-skill for creating Agent Forge skills under .claude/skills/ with SKILL.md, optional references/ and scripts/, and Bun scaffolds. Use when the user wants to add or author a skill, scaffold a new skill folder, or align skill docs with harness conventions (JSON script output, Beads for tasks).

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

jupes/agent-forge-harness22026년 10월 19일 업데이트

Choose Beads issue priority (P0–P4, numeric, or named) from urgency, impact, and risk when creating or triaging work.

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

jupes/agent-forge-harness22026년 10월 19일 업데이트

jupes의 스킬 모두 보기

이 스킬의 문제 신고