Skip to content

souvikree/commitgenie

Repository files navigation


 ██████╗ ██████╗ ███╗   ███╗███╗   ███╗██╗████████╗ ██████╗ ███████╗███╗   ██╗██╗███████╗
██╔════╝██╔═══██╗████╗ ████║████╗ ████║██║╚══██╔══╝██╔════╝ ██╔════╝████╗  ██║██║██╔════╝
██║     ██║   ██║██╔████╔██║██╔████╔██║██║   ██║   ██║  ███╗█████╗  ██╔██╗ ██║██║█████╗  
██║     ██║   ██║██║╚██╔╝██║██║╚██╔╝██║██║   ██║   ██║   ██║██╔══╝  ██║╚██╗██║██║██╔══╝  
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚═╝ ██║██║   ██║   ╚██████╔╝███████╗██║ ╚████║██║███████╗
 ╚═════╝ ╚═════╝ ╚═╝     ╚═╝╚═╝     ╚═╝╚═╝   ╚═╝    ╚═════╝ ╚══════╝╚═╝  ╚═══╝╚═╝╚══════╝

AI-powered Git commit messages. One command. No config required.


npm version  npm downloads  License: MIT  Node.js ≥16  TypeScript


Stop writing "fix stuff". Stop writing "update". Stop writing "changes". CommitGenie reads your staged diff and generates the right commit message — in one second.



How it works

git add .  →  commitgenie  →  AI reads your diff  →  you review  →  committed

CommitGenie reads git diff --cached, sends it to your chosen AI provider, and returns a structured Conventional Commit message. It scans for secrets before committing, remembers your past messages, and works in any language your team needs.


Install

npm install -g @ztv-main/commitgenie

Works immediately. No account. No API key. No config file.


Quick start

git add .
commitgenie
  CommitGenie
   Provider: free hosted

  Suggested commit message

  feat(auth): add JWT refresh token rotation

  Implements automatic token rotation on refresh to improve security.
  Tokens are now invalidated after single use.

  [y]  Commit with this message
  [e]  Edit message
  [r]  Regenerate
  [h]  Browse history  (3 previous messages)
  [x]  Cancel

Use arrow keys to navigate, Enter to select. That's it.


Features

AI commit generation

Reads git diff --cached and generates structured commit messages following Conventional Commits. Understands JavaScript, TypeScript, Python, Go, Rust, Java, and any other language.

Secret scanner

Automatically scans your staged diff for hardcoded secrets before every commit. Detects API keys, private keys, database URLs, passwords, tokens, and high-entropy strings.

Message history

The last 10 generated messages are saved locally. Use [h] in the menu to go back to a previous suggestion if you regenerated and didn't like the result.

Language support

Set "language": "fr" in your project config and commit messages will be written in French. Supports 20 languages. The type(scope): prefix always stays in English.

Git hook integration

commitgenie install sets up two hooks: a pre-commit secret scanner and a prepare-commit-msg AI generator. Run git commit and your editor opens with the message pre-filled.

PR descriptions

commitgenie pr reads all commits ahead of main and generates a structured pull request description — Summary, Changes, and Testing sections — ready to paste into GitHub.


AI providers

Provider Cost Setup Best for
Free hosted (default) Free — 20 req/day None Getting started
Groq Free tier console.groq.com Unlimited, fast
OpenAI Paid platform.openai.com GPT-4o quality
Anthropic Paid console.anthropic.com Claude models
Ollama Free ollama.com Fully offline

To switch providers or set your own key:

commitgenie setup

The wizard tests your key before saving it. Keys are stored in ~/.commitgenie with 0600 permissions (owner-only).


Project configuration

Run this in any repo to create a shared team config:

commitgenie init

This creates .commitgenie.json — commit it so your whole team shares the same settings:

{
  "ticketPrefix": "JIRA",     // auto-appends ticket from branch name → [JIRA-1234]
  "bodyAlways": false,         // always generate a commit body
  "language": "en",            // commit message language (en, fr, de, ja, zh, ...)
  "defaultScope": "api",       // override scope inference
  "customTypes": ["release"]   // add custom commit types
}

Ticket auto-linking — if your branch is feature/JIRA-1234-add-login, CommitGenie detects the ticket automatically:

feat(auth): add login page [JIRA-1234]

Secret scanner

The scanner runs automatically when you select [y] Commit with this message. It can also be run standalone:

commitgenie scan
  CommitGenie  scan

 !  2 potential secret(s) detected:

  1. OpenAI API Key — [HIGH]
     File: src/config.js — line 4
     Masked value: sk-123...5678

  2. Database URL (with creds) — [HIGH]
     File: src/db.js — line 12
     Masked value: postgr...mydb

  »  Fix: Move secrets to .env files and add .env to .gitignore

Detects: OpenAI, Anthropic, Groq, AWS, GitHub, Stripe, Google, Slack, SendGrid, Twilio API keys · RSA and EC private keys · Database URLs with credentials · Hardcoded passwords · JWT tokens · Bearer tokens · High-entropy strings

All results are logged to ~/.commitgenie-scan-log.json for audit history.


Git hooks

commitgenie install    # install hooks
commitgenie uninstall  # remove hooks

Two hooks are installed into .git/hooks/:

Hook What it does
pre-commit Scans staged files for secrets before every commit. Blocks if found.
prepare-commit-msg Generates an AI commit message and pre-fills your editor.

Workflow after install:

git add src/feature.ts
git commit
# → secrets scanned automatically
# → AI generates message silently  
# → editor opens with message pre-filled
# → review, save, close → committed

To bypass for a single commit:

git commit --no-verify

All commands

commitgenie              Generate a commit message for staged changes
commitgenie setup        Configure AI provider and API key
commitgenie init         Create .commitgenie.json for per-project settings
commitgenie install      Install git hooks (secret scan + AI message)
commitgenie uninstall    Remove git hooks
commitgenie pr           Generate a PR description from commits ahead of main
commitgenie scan         Scan staged changes for secrets
commitgenie help         Show all commands

Commit message format

CommitGenie follows Conventional Commits:

<type>(<scope>): <short description>

[optional body]
Type When
feat New feature
fix Bug fix
refactor Code restructured without behavior change
docs Documentation only
test Tests added or updated
chore Build, config, dependencies
perf Performance improvement

Real examples:

feat(auth): add JWT refresh token rotation
fix(api): handle null response from payment gateway
refactor(dashboard): extract chart into separate component
docs(readme): update installation instructions
chore(deps): upgrade typescript to v5
perf(query): add index on user email column

Security

Concern How it's handled
API key storage ~/.commitgenie written with 0600 permissions (owner-only)
Shell injection Commit messages passed via argument arrays, never interpolated into shell strings
Project config All .commitgenie.json fields are type-checked and sanitised before use
Ollama SSRF URL is validated to only allow localhost / 127.0.0.1
Hosted backend Real IP detection (x-real-ip), persistent rate limiting, input sanitisation, no internal errors exposed to callers
Your code Sent only to your configured provider — never stored, never logged by CommitGenie

Requirements

  • Node.js 16 or higher
  • Git

Contributing

Contributions are welcome. Please open an issue before submitting a pull request for significant changes.


License

MIT — © Souvik Ghosh


If CommitGenie saves you time, a star on GitHub goes a long way.

Packages

 
 
 

Contributors