Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
akillness avatar

Setup Pre Commit

  • 132 installs
  • 40 repo stars
  • Updated August 4, 2026
  • akillness/oh-my-skills

Configure pre-commit hooks that run linters, formatters, and secret scanners on staged files before commits land, standardizing local quality gates across a team repo.

About

Sets up pre-commit for a repository: install the framework, declare hook repos, map file types to linters/formatters, add secret scanning, and verify hooks block bad commits before push—cutting CI failures and review noise.

  • .pre-commit-config.yaml scaffolding
  • multi-language linter and formatter hooks
  • secret and credential scanning
  • commit message policy enforcement
  • local parity with CI quality gates

Setup Pre Commit by the numbers

  • 132 all-time installs (skills.sh)
  • Ranked #200 of 733 Git & Pull Requests skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/akillness/oh-my-skills --skill setup-pre-commit

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs132
repo stars40
Last updatedAugust 4, 2026
Repositoryakillness/oh-my-skills

What it does

Configure pre-commit hooks that run linters, formatters, and secret scanners on staged files before commits land, standardizing local quality gates across a team repo.

Files

SKILL.mdMarkdownGitHub ↗

Setup Pre-Commit

Configure automated code quality checks at commit time using Husky and lint-staged.

When to use this skill

  • Setting up a new project's commit-time quality gates
  • Adding formatting and type checking to an existing project
  • Standardizing pre-commit behavior across a team

When not to use this skill

  • CI pipeline setup → use deployment-automation
  • Git workflow strategy → use git-workflow
  • Full testing strategy → use testing-strategies

Installation process

Step 1 — Detect package manager

# Check for lockfiles in order of precedence
ls package-lock.json  # npm
ls yarn.lock          # yarn
ls pnpm-lock.yaml     # pnpm
ls bun.lockb          # bun

Step 2 — Install dependencies

# npm
npm install --save-dev husky lint-staged prettier

# pnpm
pnpm add -D husky lint-staged prettier

# yarn
yarn add -D husky lint-staged prettier

Step 3 — Initialize Husky

npx husky init

This creates .husky/ directory and adds a prepare script to package.json.

Step 4 — Create the pre-commit hook

Create .husky/pre-commit:

npx lint-staged
npm run typecheck  # omit if script doesn't exist
npm test           # omit if script doesn't exist

Note: Husky v9+ doesn't need shebangs in hook files.

Step 5 — Configure lint-staged

Create .lintstagedrc:

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

Step 6 — Configure Prettier (if absent)

Create .prettierrc only if it doesn't exist:

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

Step 7 — Verify

git add -A
git commit -m "test: verify pre-commit hooks"

Watch for: lint-staged formatting, typecheck passing, tests passing.

Execution order

lint-staged runs first (fast, only staged files) → typecheck (full project) → tests (full suite)

If typecheck or test scripts don't exist in package.json, omit those lines from the pre-commit hook.

Instructions

1. Identify the task trigger and expected output. 2. Follow the workflow steps in this skill from top to bottom. 3. Validate outputs before moving to the next step. 4. Capture blockers and fallback path if any step fails.

Examples

  • Example: Apply this skill to a small scope first, then scale to full scope after validation passes.

Best practices

  • Keep outputs deterministic and auditable.
  • Prefer small reversible changes over broad risky edits.
  • Record assumptions explicitly.

References

  • Project standards: .agent-skills/skill-standardization/SKILL.md
  • Validator script: .agent-skills/skill-standardization/scripts/validate_skill.sh

Related skills

Git & Pull Requestsgitdevopstesting

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.