ワンクリックで
setup-pre-commit-hooks
Set up pre-commit hooks for formatting, linting, and building using proper tooling with git-tracked config files.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Set up pre-commit hooks for formatting, linting, and building using proper tooling with git-tracked config files.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Merges completed work back to main through a protected-branch pull request workflow.
Set up a new git worktree and install dependencies.
Merges completed work back to main through a protected-branch pull request workflow.
Set up a new git worktree and install dependencies.
Prepares a Python package for PyPI release by updating the version, building, and verifying the distribution.
Prepare a release by updating the version, building, and verifying the distribution.
| name | setup-pre-commit-hooks |
| description | Set up pre-commit hooks for formatting, linting, and building using proper tooling with git-tracked config files. |
Set up pre-commit hooks for formatting, linting, and building using proper tooling with git-tracked config files.
$ARGUMENTS
Examine the repo to determine:
Stack - Identify from existing config files (e.g., Cargo.toml → Rust, package.json → Node)
Git root - Before configuring any hook tooling, identify the actual git root. In nested worktree setups a subdirectory like project/ may have its own .git file and be a completely separate repo — hook tooling installed there configures that repo's hooks, not the parent's. Run git -C <dir> rev-parse --git-dir to confirm.
Hook management tool - Choose based on ecosystem:
Hook commands - Infer from existing tooling (package.json scripts, linter configs like .eslintrc, ruff.toml). Default to at least these:
"**/*.{js,ts,jsx,tsx,json,md,yaml,yml,css,scss,html}": "prettier --write".tsc --noEmit (type-check only). Full builds belong in CI, not pre-commit.tsc cannot receive individual staged file paths — tsc -p tsconfig.json file.ts throws TS5042, and tsc --noEmit file.ts ignores tsconfig compilerOptions. tsc-files is abandoned and broken with TypeScript 6+. The correct solution is a lint-staged.config.js (not package.json) using function syntax so tsc runs project-wide without file args: "**/*.ts": () => "pnpm --filter <pkg> typecheck". See: https://github.com/lint-staged/lint-staged/issues/825#issuecomment-2393146853Do NOT include tests in pre-commit hooks - tests should run in CI to keep commits fast. Pre-commit hooks should only include fast checks that validate code quality, not test suites.
Only ask the user if the stack is genuinely ambiguous (e.g., multiple languages with no clear primary).
Install the hook tool and create git-tracked config files.
Important: If you're using pre-commit, use current, non-deprecated hook IDs and syntax. Check official documentation for the latest hook names:
ruff-check (not the legacy ruff alias)Examples (non-exhaustive):
npm install --save-dev husky lint-staged && npx husky init.pre-commit-config.yaml, then pre-commit install && pre-commit install --hook-type post-commitlefthook.yml, then lefthook install:::note
If the config includes post-commit hooks (like cleanup tasks), install those hook types explicitly. For pre-commit framework: pre-commit install --hook-type post-commit.
:::
Run hooks manually to ensure they successfully pass and fail before proceeding. If hooks don't successfully fail, that means there's a problem with your setup because the hooks aren't actually catching anything.
Examples:
npx lint-staged && npm run buildpre-commit run --all-fileslefthook run pre-commitFix any failures before continuing.
Add a section documenting:
Ask for user confirmation, then commit all hook-related files (config files, package.json changes, README updates).