dart_husky 1.0.0 copy "dart_husky: ^1.0.0" to clipboard
dart_husky: ^1.0.0 copied to clipboard

A pure-Dart CLI tool to manage Git hooks (pre-commit, commit-msg, pre-push) in any Dart or Flutter project. Similar to husky and lefthook.

dart_husky

dart_husky #

Git hook manager for Dart & Flutter — no binaries, no fuss.

pub version pub points license dart

Pure Dart. Zero external dependencies. Works with Flutter, FVM, or bare Dart SDK.
Inspired by husky and lefthook.


Why dart_husky? #

Most git hook tools require installing a separate binary (Go, Node.js, etc.). dart_husky is pure Dart — if your team has Dart, they have everything they need.

✦ Pure Dart — no Go, no Node, no extra installs
✦ YAML config — familiar, readable, version-controlled
✦ Built-in conventional commits validation
✦ Sequential or parallel command execution
✦ Works with dart, flutter, and fvm

Installation #

Add to your pubspec.yaml:

dev_dependencies:
  dart_husky: ^1.0.0

Install dependencies and set up hooks:

dart pub get
dart run dart_husky install

That's it. Your hooks are live.


Configuration #

Create dart_husky.yaml in your project root:

pre-commit:
  commands:
    format:
      run: dart format --set-exit-if-changed .
    analyze:
      run: dart analyze

commit-msg:
  commands:
    conventional:
      preset: conventional

Supported Hooks #

Hook Triggered when...
pre-commit Before a commit is created
commit-msg After you write a commit message
pre-push Before pushing to remote
post-checkout After switching branches
pre-merge-commit Before a merge commit

Commands #

# Install hooks defined in dart_husky.yaml
dart run dart_husky install

# Remove all installed hooks
dart run dart_husky uninstall

# Manually trigger a hook
dart run dart_husky run pre-commit

# List configured hooks and install status
dart run dart_husky list

Conventional Commits #

Enable built-in conventional commits validation with one line:

commit-msg:
  commands:
    conventional:
      preset: conventional

Valid format:

<type>(<optional scope>): <subject>
Type When to use
feat A new feature
fix A bug fix
chore Maintenance, deps, tooling
docs Documentation only
style Formatting, whitespace
refactor Code change, no feature or fix
test Adding or fixing tests
build Build system changes
ci CI configuration
perf Performance improvement
revert Revert a previous commit

Examples:

git commit -m "feat(auth): add login screen"         ✅
git commit -m "fix: resolve null pointer exception"  ✅
git commit -m "feat!: breaking api change"           ✅
git commit -m "updated stuff"                        ❌

Parallel Execution #

Speed up slow hooks by running commands simultaneously:

pre-commit:
  parallel: true
  commands:
    format:
      run: dart format --set-exit-if-changed .
    analyze:
      run: dart analyze
    test:
      run: dart test

How It Works #

you run: git commit
         └── git checks .git/hooks/pre-commit
                  └── dart run dart_husky run pre-commit
                           └── reads dart_husky.yaml
                                    └── runs each command
                                             ├── all pass → commit created ✅
                                             └── any fail → commit blocked ❌

dart_husky install writes a small shell script into .git/hooks/ for each configured hook. The script detects whether to use dart or fvm dart automatically.

Contributing #

Contributions are welcome! Please make sure your commits follow the conventional commits format — dart_husky will enforce it. 😄


Made with 🎯 by @moulibheemaneti
MIT License

1
likes
0
points
--
downloads

Publisher

verified publishermoulibheemaneti.com

Weekly Downloads

A pure-Dart CLI tool to manage Git hooks (pre-commit, commit-msg, pre-push) in any Dart or Flutter project. Similar to husky and lefthook.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

args, path, yaml

More

Packages that depend on dart_husky