setup-pre-commit
Use this skill when > Configure automated code quality checks at commit time using Husky and lint-staged. Sets up pre-commit hooks for formatting (Prettier), type checking, and tests. Adapts to existing project configurations and omits missing scripts gracefully.
How do I install this agent skill?
npx skills add https://github.com/akillness/jeo-skills --skill setup-pre-commitIs this agent skill safe to install?
- Gen Agent Trust Hubpass
The skill provides a standard configuration for Git pre-commit hooks using well-known development tools. It automates the installation and setup of Husky, lint-staged, and Prettier to ensure code quality. No security risks were identified.
- Socketpass
No alerts
- Snykpass
Risk: LOW · No issues
What does this agent skill do?
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
- Identify the task trigger and expected output.
- Follow the workflow steps in this skill from top to bottom.
- Validate outputs before moving to the next step.
- 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
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/akillness/jeo-skills/setup-pre-commit">View setup-pre-commit on skillZs</a>