VisGuidesGit Hooks

Git Hooks

Set up and manage git hooks with vis for your team

Git Hooks

vis provides built-in git hook management as a lightweight alternative to tools like husky.

Getting Started

Installing Hooks

vis hook install

This configures core.hooksPath to point to your hooks directory (.vis-hooks by default).

Creating a Hook

Create executable scripts in the hooks directory:

echo '#!/bin/sh
pnpm run lint-staged' > .vis-hooks/pre-commit

chmod +x .vis-hooks/pre-commit

Commit the Hooks Directory

Add the hooks directory to version control so the entire team shares the same hooks:

git add .vis-hooks/
git commit -m "chore: add git hooks"

Migrating from Husky

If your project currently uses husky, vis can automatically migrate your hooks:

vis hook migrate

The migration:

  1. Detects your husky directory (.husky or .husky/_)
  2. Copies all hook scripts to the vis hooks directory
  3. Prompts for confirmation before making changes
  4. Removes the husky directory after migration

Disabling Hooks

Temporarily disable hooks using the environment variable:

VIS_GIT_HOOKS=0 git commit -m "skip hooks"

For debugging hook issues:

VIS_GIT_HOOKS=2 git commit -m "debug hooks"

Common Hook Recipes

Lint Staged Files

#!/bin/sh
# .vis-hooks/pre-commit
pnpm run lint-staged

Validate Commit Messages

#!/bin/sh
# .vis-hooks/commit-msg
pnpm run commitlint --edit "$1"

Run Type Checks Before Push

#!/bin/sh
# .vis-hooks/pre-push
pnpm run typecheck

Check Dependencies Before Commit

#!/bin/sh
# .vis-hooks/pre-commit
vis check --exit-code --format minimal || {
  echo "Outdated dependencies detected. Run 'vis check' for details."
  exit 1
}

Uninstalling

To remove vis hooks and reset git's core.hooksPath:

vis hook uninstall
Support

Contribute to our work and keep us going

Community is the heart of open source. The success of our packages wouldn't be possible without the incredible contributions of users, testers, and developers who collaborate with us every day.Want to get involved? Here are some tips on how you can make a meaningful impact on our open source projects.

Ready to help us out?

Be sure to check out the package's contribution guidelines first. They'll walk you through the process on how to properly submit an issue or pull request to our repositories.

Submit a pull request

Found something to improve? Fork the repo, make your changes, and open a PR. We review every contribution and provide feedback to help you get merged.

Good first issues

Simple issues suited for people new to open source development, and often a good place to start working on a package.
View good first issues