Skip to content

깃훅 가이드

dictionary-app은 husky로 git 훅을 관리한다. package.json의 prepare: "husky" 스크립트가 pnpm install 시점에 훅을 .husky/에 설치한다.

.husky/pre-commit
pnpm exec lint-staged
pnpm run build
  1. lint-staged로 스테이징된 파일에 코딩 컨벤션 (Prettier/oxlint)을 자동 적용한다.
    package.json
    {
    "lint-staged": {
    "**/*.{js,cjs,ts,tsx}": ["oxlint --fix", "prettier --write"],
    "**/*.{json,css,md,yaml,yml}": "prettier --write"
    }
    }
  2. pnpm run build(tsc -b && vite build)까지 실행해 타입 오류·빌드 실패를 커밋 전에 미리 잡는다 — lint-staged만으로는 타입체크가 되지 않기 때문이다.
  3. 두 단계 중 하나라도 실패하면 커밋이 차단된다.

dictionary-app은 커밋 메시지를 검사하는 도구(commitlint 등)나 commit-msg 훅을 두지 않는다. 한때 commitlint.config.cjs와 @commitlint/cli가 설치돼 있었지만 어떤 훅에서도 실행되지 않는 설정이었고, 도구 없이 규칙을 직접 따르는 방식을 유지하기로 해 모두 제거했다.

  1. 형식은 Conventional Commits(type(scope): 한국어 명령형 요약)를 따른다.
  2. 허용 타입은 build/chore/ci/docs/feat/fix/perf/refactor/revert/style/test 11개다.
  3. 요약 부분(type(scope): 접두사 제외)은 50자 이내로 쓴다.
  4. AI가 커밋할 때는 /git-commit(커밋만) 또는 /git-publish(커밋 → master 병합·push) 스킬이 이 규칙대로 메시지를 작성한다.
  • git commit --no-verify로 pre-commit 훅을 건너뛰지 않는다.
  • 훅이 실패하면 원인(포맷/린트/타입/빌드 오류)을 고쳐서 다시 커밋한다.