Heimdal AI Analyze
Heimdal AI Analyze is a Ruby gem that adds a git pre-commit hook for AI-assisted review of your staged diff. Use git analyze to run the review before your commit; a normal git commit does not trigger analysis unless you opt in.
Sees every line. Judges every commit. No bad code crosses the Bifrost.
- RubyGems: rubygems.org/gems/heimdal_ai_analyze
- Source: github.com/ffarhhan/heimdal_ai_analyze
Installation
gem install heimdal_ai_analyze
With Bundler:
# Gemfile
gem "heimdal_ai_analyze", group: :development
bundle install
Requires Ruby ≥ 3.1.
How it works
You run
git analyze -m "message"— Agit commitalias that runs Heimdal’s review before your changes are committed.Staged changes only — Only files in the commit are analyzed; the rest of the tree is untouched.
Five dimensions — Security, duplication, complexity, style, and tests.
Severity — Issues are reported with location, explanation, and a suggested fix (critical, warning, info).
Result: Critical findings block the commit until addressed. With no critical issues, the commit can proceed; lower severities are advisory.
One-time setup (per repository)
Run from the repository root:
bundle exec heimdal-ai-analyze-install
# or, if the executable is on your PATH:
heimdal-ai-analyze-install
This links the gem’s pre-commit hook, registers the git analyze alias (ANALYZE=true git commit …), and stores the gem path in local git config. If an analysis binary is found, its path may be saved locally as well.
API key
The hook needs CURSOR_API_KEY whenever you run git analyze.
- This shell only:
export CURSOR_API_KEY="…"lasts for the current terminal session. - Every session: add that
exportto your shell profile (for example~/.zshrcor~/.bashrc), or keep the key in a repository-root.envfile and add.envto.gitignoreso it is never committed. The hook loads supported env files when it runs.
For additional options and examples, see templates/env.hook.example inside the installed gem (gem contents heimdal_ai_analyze or $(gem env gemdir)/gems/heimdal_ai_analyze-*).
Usage
git analyze -m "Your commit message" # review staged changes, then commit if allowed
License
MIT — see LICENSE.txt.