{"id":20386,"plugin_id":"plugins_6aa30aa10cf88191bb67ad3007e43fdc","kind":"skill","collection_source":null,"comparison_source":null,"observed_at":"2026-09-30T23:16:13.273Z","digest":"75a3877a838f55e6fbc17e5c6b4805b0bf4585d2c96495fd8cbcdf3e405305f6","against":null,"payload":{"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.","included_files":[{"relative_path":"agents/openai.yaml","size_in_bytes":99}],"skill_md_contents":"---\nname: setup-pre-commit\ndescription: 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.\ndisable-model-invocation: true\n---\n\n# Setup Pre-Commit Hooks\n\n## What This Sets Up\n\n- **Husky** pre-commit hook\n- **lint-staged** running Prettier on all staged files\n- **Prettier** config (if missing)\n- **typecheck** and **test** scripts in the pre-commit hook\n\n## Steps\n\n### 1. Detect package manager\n\nCheck for `package-lock.json` (npm), `pnpm-lock.yaml` (pnpm), `yarn.lock` (yarn), `bun.lockb` (bun). Use whichever is present. Default to npm if unclear.\n\n### 2. Install dependencies\n\nInstall as devDependencies:\n\n```\nhusky lint-staged prettier\n```\n\n### 3. Initialize Husky\n\n```bash\nnpx husky init\n```\n\nThis creates `.husky/` dir and adds `prepare: \"husky\"` to package.json.\n\n### 4. Create `.husky/pre-commit`\n\nWrite this file (no shebang needed for Husky v9+):\n\n```\nnpx lint-staged\nnpm run typecheck\nnpm run test\n```\n\n**Adapt**: Replace `npm` with detected package manager. If repo has no `typecheck` or `test` script in package.json, omit those lines and tell the user.\n\n### 5. Create `.lintstagedrc`\n\n```json\n{\n  \"*\": \"prettier --ignore-unknown --write\"\n}\n```\n\n### 6. Create `.prettierrc` (if missing)\n\nOnly create if no Prettier config exists. Use these defaults:\n\n```json\n{\n  \"useTabs\": false,\n  \"tabWidth\": 2,\n  \"printWidth\": 80,\n  \"singleQuote\": false,\n  \"trailingComma\": \"es5\",\n  \"semi\": true,\n  \"arrowParens\": \"always\"\n}\n```\n\n### 7. Verify\n\n- [ ] `.husky/pre-commit` exists and is executable\n- [ ] `.lintstagedrc` exists\n- [ ] `prepare` script in package.json is `\"husky\"`\n- [ ] `prettier` config exists\n- [ ] Run `npx lint-staged` to verify it works\n\n### 8. Commit\n\nStage all changed/created files and commit with message: `Add pre-commit hooks (husky + lint-staged + prettier)`\n\nThis will run through the new pre-commit hooks: a good smoke test that everything works.\n\n## Notes\n\n- Husky v9+ doesn't need shebangs in hook files\n- `prettier --ignore-unknown` skips files Prettier can't parse (images, etc.)\n- The pre-commit runs lint-staged first (fast, staged-only), then full typecheck and tests\n"},"changes":[],"summary":"First saved snapshot. No earlier version is available for comparison.","summary_kind":"deterministic","summary_metadata":{}}