Files
vac-optimizer/.agents/skills/setup-pre-commit/SKILL.md
T
2026-09-25 10:00:00 +02:00

26 lines
2.2 KiB
Markdown

---
name: setup-pre-commit
description: 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.
---
# Setup Pre-Commit Hooks
Extend the repository's existing commit checks with the requested coverage. Inspect package locations, `packageManager`, lockfiles (including `bun.lock` and `bun.lockb`), scripts, hook configuration, formatter configuration, and lint-staged rules before changing anything.
In this repository the JavaScript package is under `frontend/`, while `.husky/pre-commit` and `.lintstagedrc.mjs` live at the root. There is no root package to initialize. Preserve the existing backend Java formatter rule.
## Configure
- Reuse installed Husky, lint-staged, and formatter tooling. Install only missing dependencies needed for the requested checks, in the owning package with its configured package manager.
- Merge existing `prepare` scripts and hook commands; do not run an initializer over working configuration or replace unrelated checks.
- Extend the existing lint-staged configuration rather than creating a competing file. Keep staged-file tasks scoped to their inputs and preserve language-specific commands.
- Reuse the existing formatter configuration. Create defaults only when no applicable configuration exists.
- For requested type checks or tests, call existing package scripts from the correct directory. Use their non-watch mode and retain failing exit statuses. Report missing scripts rather than inventing commands.
- Keep installation and execution compatible with the installed Husky version; inspect its local documentation if needed.
## Verify
Check the resulting paths, configuration syntax, and executable hook permissions. Run the requested commands on task-owned changes or an isolated fixture. Do not run a rewriting staged-file check over unrelated user changes merely as a smoke test.
Review the scoped diff. Commit only if the user requested it, staging just the hook-setup files and preserving unrelated staged work. Otherwise hand off the verified changes. Report which checks ran and any tooling or permission limitation.