# Setup Pre Commit

> Use when setting up pre-commit automation in a JavaScript or TypeScript repo. Covers Husky, lint-staged, formatter setup, package-manager-aware hook commands, and keeping commit-time checks realistic.

- **Type:** Skill
- **Install:** `agentstack add skill-andrewsrigom-agent-skills-setup-pre-commit`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [andrewsrigom](https://agentstack.voostack.com/s/andrewsrigom)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [andrewsrigom](https://github.com/andrewsrigom)
- **Source:** https://github.com/andrewsrigom/agent-skills/tree/main/engineering/setup-pre-commit
- **Website:** https://andrewsrigom.github.io/agent-skills/

## Install

```sh
agentstack add skill-andrewsrigom-agent-skills-setup-pre-commit
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Setup Pre-Commit

Use this skill when the user wants commit-time checks without overloading the hook.

## Scope

- Husky setup
- lint-staged configuration
- Prettier or existing formatter integration
- package-manager-aware hook commands
- choosing what belongs in pre-commit versus CI

## Default path

1. Detect the package manager and current scripts.
2. Install the minimum hook dependencies.
3. Initialize Husky if the repo does not already use it.
4. Configure `lint-staged` for staged-file formatting or linting.
5. Keep the pre-commit hook fast:
   - staged formatting or linting first
   - lightweight checks second
   - heavy suites in CI unless the repo explicitly wants them locally
6. Verify the hook against the current scripts instead of inventing missing commands.

## When to deviate

- Keep the hook even smaller when the repo already struggles with slow local tooling.
- Add more checks only if the repo already runs them reliably and the team explicitly wants them before commit.
- Skip formatter or lint changes if the repo already has a working hook stack that only needs a small fix.

## Guardrails

- Do not add `typecheck` or `test` to the hook if the repo does not already support them cleanly.
- Prefer staged-file checks over whole-repo checks in pre-commit.
- Keep the hook deterministic and package-manager-aware.
- Do not introduce a formatter config if the repo already has one.

## Avoid

- turning pre-commit into a slow mini-CI pipeline
- inventing scripts the repo does not actually have
- running whole-repo checks when staged-file checks are enough
- overwriting an existing formatter setup without reason

## Verification checklist

- the package manager and current scripts were detected first
- hook commands are fast enough for normal commit flow
- checks operate on staged files where possible
- CI-only work stays out of pre-commit unless explicitly desired
- the hook matches the repo's real tooling, not imagined tooling

## Output Shape

When answering with this skill, prefer:

- packages to install
- files to create or update
- exact hook content
- what should stay in CI instead

## Good Triggers

- pre-commit, Husky, lint-staged, commit hooks, run formatter on commit

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [andrewsrigom](https://github.com/andrewsrigom)
- **Source:** [andrewsrigom/agent-skills](https://github.com/andrewsrigom/agent-skills)
- **License:** MIT
- **Homepage:** https://andrewsrigom.github.io/agent-skills/

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-andrewsrigom-agent-skills-setup-pre-commit
- Seller: https://agentstack.voostack.com/s/andrewsrigom
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
