Setup Pre-Commit Hooks
Set up Husky pre-commit hooks with lint-staged (Prettier), type checking, and tests.
What This Sets Up
- Husky pre-commit hook
- lint-staged running Prettier on all staged files
- Prettier config
- typecheck and test scripts in the pre-commit hook
Steps
- Detect package manager
- Install dependencies: husky lint-staged prettier
- Initialize Husky: npx husky init
- Create .husky/pre-commit
- Create .lintstagedrc
- Create .prettierrc (if missing)
- Verify
- Commit
Credit
This skill is based on the work of Matt Pocock (@mattpocock). Original source: mattpocock/skills. Licensed under MIT.
How to use?
1. Download
Go to the AGENT KD SKILL gallery and find this skill card. Click Download to save the SKILL.md file to your computer.
2. Install
Copy the downloaded SKILL.md into your agent's skills directory:
| Agent | Path |
|---|---|
| opencode | ~/.config/opencode/skills//SKILL.md |
| Claude Code | ~/.claude/skills//SKILL.md |
| Codex CLI | ~/.codex/skills//SKILL.md |
| Cursor | ~/.cursor/skills//SKILL.md |
| Gemini CLI | ~/.gemini/skills//SKILL.md |
Example for opencode:
ash mkdir -p ~/.config/opencode/skills/<skill-name> cp SKILL.md ~/.config/opencode/skills/<skill-name>/SKILL.md
3. Use
Restart your agent session. The skill will auto-load based on its description. You can also invoke it explicitly by typing @ in your agent.
4. Verify
Ask your agent something related to the skill's purpose. If it responds using the skill's instructions, you're all set.