mcpField
S
setup-pre-commit

setup-pre-commit

github.com/akillnessTesting & quality53187 installsUpdated 1d ago
Repository

About setup-pre-commit

A skill for adding commit-time quality checks to JavaScript projects with Husky and lint-staged. It guides setup and verification of formatting, type checking, and tests.

Key features

  1. 01Husky hook setup
  2. 02lint-staged formatting
  3. 03Optional type checking
  4. 04Optional test execution
  5. 05Commit hook verification

Use cases

  1. 01Add quality gates to a new project
  2. 02Add formatting checks to an existing project
  3. 03Standardize commit checks across a team

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/akillness/jeo-skills --skill setup-pre-commit

After installing, type/setup-pre-commitin Claude Code to confirm it loaded.

Details

From the project README

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

Comments

Markdown supported