immamdouhaboammar/matts-skills-into-chatgpt/setup-pre-commit
Claude Code and agent skill by immamdouhaboammar/matts-skills-into-chatgpt
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"},{"type":"config","description":"Configuration overrides"}]
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-commitSemi-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
- Package Manager Fidelity: Detect and use the repository's native package manager (
bun,pnpm,yarn,npm); do NOT introduce conflicting lockfiles. - Staged-Only Formatting: Run Prettier strictly against staged files via
lint-stagedwith--ignore-unknown --writeto prevent un-staged code drift. - Repository-Wide Typecheck & Test: Execute full typecheck and unit test passes inside
.husky/pre-commitafterlint-stagedsucceeds. - Preserve Existing Configurations: If
.prettierrcor existing Husky hooks exist, merge scripts safely without overwriting user rules. - 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)
| Component | Responsibility | Configuration File | |
|---|---|---|---|
| Husky Engine | Git hook manager v9+ | .husky/pre-commit | |
| lint-staged | Run formatters exclusively on staged changes | .lintstagedrc | |
| Prettier | Code 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, orhuskyare already installed. - Why: Reusing existing dependencies prevents package bloat and lockfile churn.
Step 2: Install DevDependencies & Initialize Husky
- Action: Install
husky,lint-staged, andprettieras devDependencies, then runnpx husky init. - Key Point: Verify that
"prepare": "husky"is added topackage.json. - Inline Checklist:
- [ ] Dependencies installed in
devDependencies - [ ]
.husky/directory created - [ ]
preparescript present inpackage.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
.lintstagedrcwith{"*": "prettier --ignore-unknown --write"}. - Why:
prettier --ignore-unknownsafely 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 Rationalization | Binding Rule | Engineering 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
- SKILL.md in the repositoryCheckingskills/setup-pre-commit/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Extension points
hookPre/post lifecycle hooksconfigConfiguration 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
[](https://verified-skill.com/skills/immamdouhaboammar/matts-skills-into-chatgpt/setup-pre-commit)