setup-pre-commitlisted
Install: claude install-skill ArieGoldkin/claude-forge
# Setup Pre-Commit Hooks
## What This Sets Up
- **Husky** pre-commit hook
- **lint-staged** running a formatter on staged files
- **Formatter config** — Prettier OR Biome (choose by ecosystem)
- **typecheck** and **test** scripts in the pre-commit hook
## Steps
### 1. Detect package manager
Check for `package-lock.json` (npm), `pnpm-lock.yaml` (pnpm), `yarn.lock` (yarn), `bun.lockb` (bun). Use whichever is present. Default to npm if unclear.
### 2. Detect formatter preference
Inspect existing config OR ask the user:
- `biome.json` / `biome.jsonc` present → use Biome
- `.prettierrc*` / `prettier.config.*` present → use Prettier
- Neither → ask: **"Prettier (broader ecosystem) or Biome (faster, all-in-one)?"**
### 3. Install dependencies
For **Prettier**:
```
husky lint-staged prettier
```
For **Biome**:
```
husky lint-staged @biomejs/biome
```
Use the detected package manager (`npm install -D`, `pnpm add -D`, `yarn add -D`, `bun add -D`).
### 4. Initialize Husky
```bash
npx husky init
```
Creates `.husky/` and adds `prepare: "husky"` to `package.json`.
### 5. Create `.husky/pre-commit`
No shebang needed for Husky v9+:
```
npx lint-staged
npm run typecheck
npm run test
```
**Adapt**: replace `npm` with the detected package manager. If the repo lacks a `typecheck` or `test` script in `package.json`, omit those lines and tell the user (don't silently fail-shut).
### 6. Create `.lintstagedrc`
For **Prettier**:
```json
{
"*": "prettier --ignore-unknown --w