Skip to content

Repository files navigation

Mamoru

Mamoru acts as a commit-msg hook that embeds a compiled dictionary of over 106,000 words to instantly catch and block typos before they enter your version control.

Crates.ioCrates.io Total DownloadsCrates.io


Installation

cargo install mamoru

Usage

Navigate to any Git repository and initialize the hook. This automatically configures Mamoru inside .git/hooks/commit-msg with the necessary executable permissions:

mamoru init
# If existing git hooks exist, use --force to overwrite it
mamoru init --force

Once installed, Mamoru intercepts your git commit commands automatically. If a commit contains unrecognized words, the hook safely aborts the commit and suggests corrections:

$ git commit -m "feat: implment algorimth update"
Commit blocked! Typos found in commit message:
• "implment" -> Did you mean: implement?"algorimth" -> Did you mean: algorithm?
error: Please fix the spelling errors above.

Handling False Positives

If Mamoru flags a valid word (like a company name, internal jargon, or a niche acronym), you can ignore it by creating a .mamoruignore file in the root of your repository. Simply add one word per line:

mycompanyname
mycustomacronym

Bypassing the Hook

If you are in a rush and need to completely bypass the spellchecker for a single commit (without skipping all of your other git hooks via --no-verify), you can use the MAMORU_SKIP environment variable:

MAMORU_SKIP=1 git commit -m "feat: fix bugz XYZ"

Unintall

To remove mamoru:

mamoru uninstall

🎈 Performance

Benchmarks gathered using hyperfine (testing full dictionary load and typo analysis).

$hyperfine-N-i--warmup10--min-runs10000"./target/release/mamoruchecktest_commit.txt"Time(mean±σ):2.5ms±0.3msRange(minmax):2.2ms5.8ms

When no typo were found.

Time(mean±σ):534.6µs±85.2µsRange(minmax):439.1µs1279.7µs

Acknowledgments

Mamoru's built-in dictionary is compiled from a blend of standard natural language and specialized developer jargon, heavily drawing from:

  • Linux system wordlists (via /usr/share/dict) for robust, everyday English.
  • cspell repositories for modern programming, DevOps, and open-source.

License

This project is licensed under the MIT license.

About

Git commit-msg hook that catches typos using FST and Levenshtein distance algorithms.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages