immamdouhaboammar/matts-skills-into-chatgpt/setup-pre-commit

Claude Code and agent skill by immamdouhaboammar/matts-skills-into-chatgpt

Trust tier 3
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"},{"type":"config","description":"Configuration overrides"}]
Source check pending

Checking that the SKILL.md file is still in the repository.

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.

Install

npx vskill@latest install immamdouhaboammar/matts-skills-into-chatgpt/setup-pre-commit

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

The same SKILL.md was published earlier as immamdouhaboammar/matts-skills-into-chatgpt/setup-pre-commit.

Setup Pre-Commit Hooks

Install and configure deterministic Git pre-commit quality gates using Husky, lint-staged, and Prettier, preserving existing repository package managers and build scripts.


Core Invariants

  1. Package Manager Fidelity: Detect and use the repository's native package manager (bun, pnpm, yarn, npm); do NOT introduce conflicting lockfiles.
  2. Staged-Only Formatting: Run Prettier strictly against staged files via lint-staged with --ignore-unknown --write to prevent un-staged code drift.
  3. Repository-Wide Typecheck & Test: Execute full typecheck and unit test passes inside .husky/pre-commit after lint-staged succeeds.
  4. Preserve Existing Configurations: If .prettierrc or existing Husky hooks exist, merge scripts safely without overwriting user rules.
  5. Mandatory Smoke-Test Commit: Verify the entire hook pipeline by staging all configuration changes and executing a verified test commit.

Architecture & Map of Content (MOC)

[ Git Commit Attempt ] ──► [ .husky/pre-commit Hook ]
│
┌───────────────────────────┼───────────────────────────┐
▼ ▼ ▼
[ lint-staged ] [ Typecheck Gate ] [ Unit Test Gate ]
- Prettier format - `npm run typecheck` - `npm run test`
- Staged files only - Full project types - Unit/Integration pass
ComponentResponsibilityConfiguration File
Husky EngineGit hook manager v9+.husky/pre-commit
lint-stagedRun formatters exclusively on staged changes.lintstagedrc
PrettierCode style standardization.prettierrc

Step-by-Step Procedure (TWI)

Step 1: Detect Package Manager & Check Existing Setup
  • Action: Detect the lockfile (bun.lockb $\rightarrow$ bun, pnpm-lock.yaml $\rightarrow$ pnpm, yarn.lock $\rightarrow$ yarn, else npm).
  • Key Point: Check if prettier, lint-staged, or husky are already installed.
  • Why: Reusing existing dependencies prevents package bloat and lockfile churn.
Step 2: Install DevDependencies & Initialize Husky
  • Action: Install husky, lint-staged, and prettier as devDependencies, then run npx husky init.
  • Key Point: Verify that "prepare": "husky" is added to package.json.
  • Inline Checklist:
  • [ ] Dependencies installed in devDependencies
  • [ ] .husky/ directory created
  • [ ] prepare script present in package.json
Step 3: Write .husky/pre-commit & .lintstagedrc
  • Action: Configure .husky/pre-commit:

``bash npx lint-staged npm run typecheck npm run test ` *(Adapting npm to the detected package manager, and omitting typecheck/test` if scripts are absent).*

  • Key Point: Create .lintstagedrc with {"*": "prettier --ignore-unknown --write"}.
  • Why: prettier --ignore-unknown safely ignores binaries and images while formatting all supported text formats.
Step 4: Smoke Test and Initial Commit
  • Action: Stage all created hook files and run git commit -m "Add pre-commit hooks (husky + lint-staged + prettier)".
  • Key Point: Confirm that the commit triggers the pre-commit hook and passes all stages.
  • Why: Live commit execution proves that hooks are executable and correctly configured.

Anti-Rationalization Guardrails

Tempting RationalizationBinding RuleEngineering Rationale
"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.
"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.
"Use npm commands in a pnpm or bun repository."Strictly match detected package manager commands.Mismatched package managers create duplicate lockfiles and broken installations.

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Extension points

  • hookPre/post lifecycle hooks
  • configConfiguration overrides

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/immamdouhaboammar/matts-skills-into-chatgpt/setup-pre-commit/badge)](https://verified-skill.com/skills/immamdouhaboammar/matts-skills-into-chatgpt/setup-pre-commit)

Something wrong with this skill or its page? Tell us.