← Matt Skills CuratedCONTENT HISTORYWHAT CHANGED · RULE-BASED ANALYSIS
Update to Matt Skills Curated
Snapshot Sep 30, 2026 · 23:14 UTC · version 1.1.0
Collection source: not recorded for this historical snapshot.
First saved snapshot
No earlier snapshot is available to establish a change.
Compare saved observations
Download comparison JSONFull technical diff · 0 changed fields
Full snapshot data
{
"description": "Configure pre-commit quality checks with Husky and lint-staged while preserving package manager conventions. Use when setting up git pre-commit hooks, automated formatters, staged linters, or typecheck gates — even if the user says \"add pre-commit hooks\". Do NOT use for continuous integration (CI) pipeline setup.",
"included_files": [
{
"relative_path": "agents/openai.yaml",
"size_in_bytes": 99
}
],
"name": "setup-pre-commit",
"skill_md_contents": "---\nname: setup-pre-commit\ndescription: \"Configure pre-commit quality checks with Husky and lint-staged while preserving package manager conventions. Use when setting up git pre-commit hooks, automated formatters, staged linters, or typecheck gates — even if the user says \\\"add pre-commit hooks\\\". Do NOT use for continuous integration (CI) pipeline setup.\"\n---\n\n# Setup Pre-Commit Hooks\n\nInstall and configure deterministic Git pre-commit quality gates using Husky, `lint-staged`, and Prettier, preserving existing repository package managers and build scripts.\n\n---\n\n## Core Invariants\n\n1. **Package Manager Fidelity**: Detect and use the repository's native package manager (`bun`, `pnpm`, `yarn`, `npm`); do NOT introduce conflicting lockfiles.\n2. **Staged-Only Formatting**: Run Prettier strictly against staged files via `lint-staged` with `--ignore-unknown --write` to prevent un-staged code drift.\n3. **Repository-Wide Typecheck & Test**: Execute full typecheck and unit test passes inside `.husky/pre-commit` after `lint-staged` succeeds.\n4. **Preserve Existing Configurations**: If `.prettierrc` or existing Husky hooks exist, merge scripts safely without overwriting user rules.\n5. **Mandatory Smoke-Test Commit**: Verify the entire hook pipeline by staging all configuration changes and executing a verified test commit.\n\n---\n\n## Architecture & Map of Content (MOC)\n\n```\n[ Git Commit Attempt ] ──► [ .husky/pre-commit Hook ]\n │\n ┌───────────────────────────┼───────────────────────────┐\n ▼ ▼ ▼\n [ lint-staged ] [ Typecheck Gate ] [ Unit Test Gate ]\n - Prettier format - `npm run typecheck` - `npm run test`\n - Staged files only - Full project types - Unit/Integration pass\n```\n\n| Component | Responsibility | Configuration File |\n|---|---|---|\n| **Husky Engine** | Git hook manager v9+ | `.husky/pre-commit` |\n| **lint-staged** | Run formatters exclusively on staged changes | `.lintstagedrc` |\n| **Prettier** | Code style standardization | `.prettierrc` |\n\n---\n\n## Step-by-Step Procedure (TWI)\n\n### Step 1: Detect Package Manager & Check Existing Setup\n- **Action**: Detect the lockfile (`bun.lockb` $\\rightarrow$ bun, `pnpm-lock.yaml` $\\rightarrow$ pnpm, `yarn.lock` $\\rightarrow$ yarn, else npm).\n- **Key Point**: Check if `prettier`, `lint-staged`, or `husky` are already installed.\n- **Why**: Reusing existing dependencies prevents package bloat and lockfile churn.\n\n### Step 2: Install DevDependencies & Initialize Husky\n- **Action**: Install `husky`, `lint-staged`, and `prettier` as devDependencies, then run `npx husky init`.\n- **Key Point**: Verify that `\"prepare\": \"husky\"` is added to `package.json`.\n- **Inline Checklist**:\n - [ ] Dependencies installed in `devDependencies`\n - [ ] `.husky/` directory created\n - [ ] `prepare` script present in `package.json`\n\n### Step 3: Write `.husky/pre-commit` & `.lintstagedrc`\n- **Action**: Configure `.husky/pre-commit`:\n ```bash\n npx lint-staged\n npm run typecheck\n npm run test\n ```\n *(Adapting `npm` to the detected package manager, and omitting `typecheck`/`test` if scripts are absent).*\n- **Key Point**: Create `.lintstagedrc` with `{\"*\": \"prettier --ignore-unknown --write\"}`.\n- **Why**: `prettier --ignore-unknown` safely ignores binaries and images while formatting all supported text formats.\n\n### Step 4: Smoke Test and Initial Commit\n- **Action**: Stage all created hook files and run `git commit -m \"Add pre-commit hooks (husky + lint-staged + prettier)\"`.\n- **Key Point**: Confirm that the commit triggers the pre-commit hook and passes all stages.\n- **Why**: Live commit execution proves that hooks are executable and correctly configured.\n\n---\n\n## Anti-Rationalization Guardrails\n\n| Tempting Rationalization | Binding Rule | Engineering Rationale |\n|---|---|---|\n| *\"Run prettier across the whole repository on every commit.\"* | **Run Prettier strictly on staged files via `lint-staged`.** | Full-repo formatting on every commit slows developer workflows and pollutes diffs. |\n| *\"Skip the typecheck and test steps in pre-commit to make it faster.\"* | **Include typecheck and fast tests in pre-commit.** | Catching type errors locally before push prevents broken remote CI builds. |\n| *\"Use npm commands in a pnpm or bun repository.\"* | **Strictly match detected package manager commands.** | Mismatched package managers create duplicate lockfiles and broken installations. |\n\n"
}SHA-256 of public snapshot: b22dffa7b977feae6d4ed3cdd6d1526b96efb07bb7f0a138ac5d7a4b0b686c26