AgentStack
SKILL verified Apache-2.0 Self-run

Setup Pre Commit

skill-officialunofficial-skills-setup-pre-commit · by officialunofficial

Add a Husky pre-commit hook backed by lint-staged (Prettier), plus type checking and tests, to the current repo. Use when the user wants pre-commit hooks, wants to set up Husky or lint-staged, or wants Prettier, typecheck, and tests to run at commit time.

No reviews yet
0 installs
14 views
0.0% view→install

Install

$ agentstack add skill-officialunofficial-skills-setup-pre-commit

✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

Are you the author of Setup Pre Commit? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Set up pre-commit hooks

What you end up with

  • A Husky pre-commit hook
  • lint-staged running Prettier over the staged files
  • A Prettier config, if the repo lacks one
  • typecheck and test scripts invoked from the hook

Steps

1. Detect the package manager

Look for a lockfile: package-lock.json (npm), pnpm-lock.yaml (pnpm), yarn.lock (yarn), or bun.lockb (bun). Use whichever is present, and fall back to npm when none is clear.

2. Install the dev dependencies

Add as devDependencies:

husky lint-staged prettier

3. Initialize Husky

npx husky init

This creates the .husky/ directory and adds a prepare: "husky" script to package.json.

4. Write .husky/pre-commit

Husky v9+ needs no shebang:

npx lint-staged
npm run typecheck
npm run test

Adapt it: swap npm for the detected package manager. If package.json has no typecheck or test script, drop the matching line and tell the user it was left out.

5. Write .lintstagedrc

{
  "*": "prettier --ignore-unknown --write"
}

6. Write .prettierrc, only if none exists

Skip this when the repo already has a Prettier config. Otherwise use these defaults:

{
  "useTabs": false,
  "tabWidth": 2,
  "printWidth": 80,
  "singleQuote": false,
  "trailingComma": "es5",
  "semi": true,
  "arrowParens": "always"
}

7. Confirm the setup

  • [ ] .husky/pre-commit exists and is executable
  • [ ] .lintstagedrc exists
  • [ ] package.json has "prepare": "husky"
  • [ ] A Prettier config is present
  • [ ] npx lint-staged runs cleanly

8. Commit

Stage everything you created or changed and commit with: Add pre-commit hooks (husky + lint-staged + prettier). The commit itself flows through the new hook, which doubles as the first smoke test.

Notes

  • Husky v9+ hook files do not take a shebang.
  • prettier --ignore-unknown passes over files Prettier cannot parse, such as images.
  • The hook runs lint-staged first — fast, staged-only — before the full typecheck and tests.

Source & license

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

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

Reviews

No reviews yet — be the first.

Versions

  • v0.1.0 Imported from the upstream source.