Skip to content
Skills Library
Programming · Automation

setup-pre-commit

/setup-pre-commit

Install git pre-commit hooks via the project's hook tool — Husky+lint-staged (JS), pre-commit (Python/OCaml), lefthook (Go), cargo-husky (Rust). Use when the user wants commit-time formatting, linting, type-checking, or test gates. Detects ecosystem first.

Licence
Apache-2.0
Last repository change
08.07.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
1
Deprecation

No signals detected. Repository changed on 08.07.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What it does and when to use it

Install git pre-commit hooks via the project's hook tool — Husky+lint-staged (JS), pre-commit (Python/OCaml), lefthook (Go), cargo-husky (Rust). Use when the user wants commit-time formatting, linting, type-checking, or test gates. Detects ecosystem first.

Original author description

Install git pre-commit hooks via the project's hook tool — Husky+lint-staged (JS), pre-commit (Python/OCaml), lefthook (Go), cargo-husky (Rust). Use when the user wants commit-time formatting, linting, type-checking, or test gates. Detects ecosystem first.

How it works

  1. Detection (run first)
  2. Ecosystem → hook tool
  3. Per-ecosystem hook contents
  4. Verify
  5. Commit
Original SKILL.md headings · 110 lines, 431 words
SKILL.md preview
---
name: setup-pre-commit
description: Install git pre-commit hooks via the project's hook tool — Husky+lint-staged (JS), pre-commit (Python/OCaml), lefthook (Go), cargo-husky (Rust). Use when the user wants commit-time formatting, linting, type-checking, or test gates. Detects ecosystem first.
---

Detect the ecosystem, pick the right hook tool, install with formatter + type-check + test gates.

## Detection (run first)

Dispatch Explore agent — or for a single-language repo, probe directly via `fd` for lockfile / manifest signature. Map the first manifest hit to an ecosystem. Multi-language repos: ask the maintainer which surface to gate, or apply both.

## Ecosystem → hook tool

| Ecosystem            | Hook tool                  | Install command                                                  |
| -------------------- | -------------------------- | ---------------------------------------------------------------- |
| npm / yarn / pnpm / bun | husky + lint-staged     | `<pm> add -D husky lint-staged prettier && npx husky init`       |
| Python (poetry/pip)  | pre-commit (framework)     | `pipx install pre-commit && pre-commit install`                  |
| Go                   | lefthook (or pre-commit)   | `go install github.com/evilmartians/lefthook@latest && lefthook install` |
| Rust (cargo)         | cargo-husky (or pre-commit)| add `cargo-husky` as `[dev-dependencies]`; runs on `cargo test`  |
| OCaml (dune)         | pre-commit + dune hooks    | `pipx install pre-commit && pre-commit install`                  |

## Per-ecosystem hook contents

**Node ecosystems** — write `.husky/pre-commit`:

```
npx lint-staged
<pm> run typecheck
<pm> run test
```

Drop missing scripts and tell the user. Write `.lintstagedrc`:

```json
{ "*": "prettier --ignore-unknown --write" }
```

Formatter policy is **out of scope** for this skill. Do NOT auto-create `.prettierrc`. If no Prettier config exists, surface that fact and ask the user.

**Python** — write `.pre-commit-config.yaml`:

```yaml
repos:
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.6.0
    hooks:
      - id: ruff
      - id: ruff-format
  - repo: local
    hooks:
      - id: pyright
        name: pyright
        entry: pyright
        language: system
        pass_filenames: false
      - id: pytest
        name: pytest
        entry: pytest -q
        language: system
        pass_filenames: false
        stages: [pre-commit]
```

**Go** — write `lefthook.yml`:

```yaml
pre-commit:
  parallel: true
  commands:
    fmt:    { run: gofmt -l -w {staged_files} }
    vet:    { run: go vet ./... }
    test:   { run: go test -race ./... }
```

**Rust** — `Cargo.toml`:

```toml
[dev-dependencies]
cargo-husky = { version = "1", default-features = false, features = ["precommit-hook", "run-cargo-test", "run-cargo-clippy", "run-cargo-fmt"] }
```

**OCaml** — `.pre-commit-config.yaml`:

```yaml
repos:
  - repo: local
    hooks:
      - id: dune-fmt
        name: dune fmt
        entry: dune fmt
        language: system
        pass_filenames: false
      - id: dune-build
        name: dune build
        entry: dune build
        language: system
        pass_filenames: false
      - id: dune-test
        name: dune runtest
        entry: dune runtest
        language: system
        pass_filenames: false
```

## Verify

- `fd -d 2 -t f '\.husky|\.pre-commit-config\.yaml|lefthook\.yml'` shows the expected file.
- The hook is executable.
- Run a no-op commit (`git commit --allow-empty -m "chore: verify hooks"`) — every gate must run and pass.

## Commit

`chore: install pre-commit hooks (<tool>)`. The commit itself trips the new hook — first-class smoke test.

Versions

RepositoryScoreLicence
This page · OutlineDriven/odin-codex-plugin100Apache-2.0
mattpocock/skills100MIT
devcxl/mattpocock-skills-zh100MIT
vinvcn/mattpocock-skills-zh-cn100MIT
wenwuzhidao/mattpocock-skills-zh100MIT
stevesolun/ctx100MIT

Database snapshot: 13.11.2026 · package version 89aa6ff65328 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100git-hooks-husky-pre-commit-lintstaged
    Use this skill when enforcing linting, formatting, and unit tests before commit creation using Husky and lint-staged.
  • 100husky-and-hooks
    Use this skill when the user says 'git hooks', 'husky', 'lint-staged', 'pre-commit hook', 'commit-msg hook', 'commitlint', 'pre-push', 'lefthook', 'pre-commit framework', 'hooks not running', 'skip hooks', 'core.hooksPath'. Sets up and debugs client-side Git hooks: how hooks…
  • 100git-hooks-setup
    Use when setting up git hooks (pre-commit, commit-msg, pre-push) with husky or native hooks for linting, formatting, commit conventions, and secret scanning.
  • 95dx-git-hooks-setup
    Use when setting up pre-commit and pre-push git hooks on any project (JS/TS, Go, shell scripts, or mixed), auditing whether an existing hook setup meets minimum requirements, or adding new mandatory checks to existing hooks. Triggered by "set up commit hooks", "add pre-commit…
  • 100lefthook
    Fast Git hooks manager written in Go. Use when a user asks to set up Git hooks without Node.js dependency, run parallel pre-commit checks, or find a faster alternative to Husky.
  • 100lefthook
    This skill should be used when the user asks to "configure git hooks", "set up lefthook", "add a pre-commit hook", "create a lefthook config", "install git hooks", or mentions lefthook, .lefthook.yml, git hooks management, or hook enforcement in the context of Plexium or any project using Lefthook.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.