setup-pre-commit
An agent skill by mattpocock, from mattpocock/skills. Tags: ci-cd, github, setup, validation, workflow.
What it does
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.
Install
With the skills CLI, which installs into Claude Code, Codex, Cursor and other agents:
npx skills add mattpocock/skills --skill setup-pre-commit
Or copy the skill folder into Claude Code's skills directory by hand (~/.claude/skills for every project, or .claude/skills inside one):
git clone --depth 1 https://github.com/mattpocock/skills
cp -r skills/skills/misc/setup-pre-commit ~/.claude/skills/setup-pre-commit
Safety box score
Grade B, low risk: 25 of 100 risk points, rated 2026-10-16. The grade rates what the skill and its scripts can reach on the machine of whoever installs it, across eight categories from shell execution to secrets access. How the score works.
This skill sets up Husky pre-commit hooks that install npm packages, create hook/config files, and run formatting, typechecking, and tests on every commit. The main risks are registry-fetched code execution during setup, automatic commits of generated changes, and repo scripts being run implicitly by the new hook.
| Category | Level | Why |
|---|---|---|
| Code & shell execution | 2 (moderate) | It bootstraps and runs commands like `npx husky init`, `npx lint-staged`, `npm run typecheck`, and `npm run test`, so it executes code during setup and on every commit. |
| Network access | 2 (moderate) | It installs `husky lint-staged prettier` and uses `npx`, which downloads packages from the npm registry. |
| Filesystem reach | 1 (low) | It only writes within the current repo (`.husky/pre-commit`, `.lintstagedrc`, optional `.prettierrc`, and `package.json`). |
| Secrets & credentials | 0 (none) | No secret stores, token files, env files, or logins are referenced. |
| Privilege & persistence | 0 (none) | It does not request sudo, global installs, services, or OS/shell configuration changes. |
| Instruction hijack surface | 0 (none) | There is no prompt-injection content or instruction to ignore safeguards or follow remote text. |
| Irreversible actions | 1 (low) | It tells the agent to stage all changes and commit them locally, but it does not push, deploy, or act outside the repo. |
| Transparency | 1 (low) | The exact code run at setup time comes from unpinned registry packages invoked via `npx`, not from files included in the skill. |
Before installing
- Check whether `package.json` already has `prepare`, `typecheck`, or `test` scripts; this skill will add `prepare: "husky"` and run the others on every commit.
- Read the generated `.husky/pre-commit` before committing to confirm it only runs the commands you expect.
- Prefer pinning `husky`, `lint-staged`, and `prettier` versions if you do not want `npx`/install-time registry code changing over time.
- Try it first on a scratch branch with network access enabled and no sensitive tokens loaded.
Rated 2026-10-16 by an automated review of 2 files from the skill's repository.
Source
- Repository
- mattpocock/skills (all skills from this repository)
- Path
- skills/misc/setup-pre-commit/SKILL.md
- Branch
- main
- Updated
- 2026-10-05
Related skills
- code-review — Review the changes since a fixed point (commit, branch, tag, or merge-base) along two axes.
- aws-deployment — Configures CI/CD pipelines using AWS CodePipeline, CodeBuild, CodeDeploy, CodeConnections, and CodeArtifact.
- cli-for-agents — Designs or reviews CLIs so coding agents can run them reliably: non-interactive flags, layered --help with examples, stdin/pipelines, fast actionable errors.
- create-verification-skill — Generate a project-local verification skill that drives your app the way a user does — any language, framework, or platform.
- eas-workflows — EAS service (paid). Helps understand and write EAS workflow YAML files for Expo projects.
- expo-project-structure — Framework (OSS). Folder structure for a new Expo app.