Skills DirectoryCurated open-source Skills from GitHub

setup-pre-commitcommit 3216582SKILL.md · Code Standards

Setup Pre-Commit Hooks

Sets up a Husky pre-commit hook in the current repo that runs Prettier via lint-staged, plus typecheck and tests.

Installs dev dependencies, adds a git pre-commit hook and commits the changes.

npx skills add mattpocock/skills --skill setup-pre-commit
Permissions
  • read-repo
  • write-files
  • shell
  • network
Compatible with
Claude Code, Codex, Copilot, Gemini CLI
GitHub
308.7k
Source
Community · Matt Pocock
Status
Scan passed
License
MIT

Core rule

Adapt the hook to the detected package manager, and omit the typecheck or test line, telling the user, when the repo has no such script.

Execution Phases

  1. Phase 01Detect and install

    Detect npm, pnpm, yarn or bun from the lockfile and install husky, lint-staged and prettier as devDependencies.

  2. Phase 02Initialise Husky

    Run npx husky init, then write .husky/pre-commit to run lint-staged, typecheck and test.

  3. Phase 03Add configs

    Create .lintstagedrc running prettier --ignore-unknown --write on staged files, and .prettierrc only if no Prettier config exists.

  4. Phase 04Verify and commit

    Check the files and prepare script, run npx lint-staged, then commit so the new hook runs as a smoke test.

Permissions (summarised from SKILL.md)

CapabilityNeededDetails
File writesLimitedCreates or edits only .husky/pre-commit, .lintstagedrc, .prettierrc and package.json.
Command executionLimitedRuns the package manager install, npx husky init, npx lint-staged and a git commit.
Network outboundLimitedOnly the package registry, to install dependencies.

SKILL.md frontmatter (YAML)

SKILL.md frontmatter (YAML)commit 3216582
---
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.
---

Related skills

A rule scan cannot catch every risk. Read this skill's SKILL.md and check its permissions before installing.