1.0.1 โข Published 6 months ago
@chrissnoek/gen-ai-commit v1.0.1
aic โ AI Commit Messages
Generate meaningful git commit messages using OpenAI and your staged diff.
โจ Features
- ๐ฌ Uses OpenAI (GPT-3.5) to generate concise, present-tense commit messages
- ๐ง Detects and prefixes commit messages with a conventional commit type:
feat: new featurefix: bug fixdocs: documentation changesstyle: formatting only (no logic)refactor: code refactoring (no behavior change)test: adding or modifying testschore: tooling or maintenance
๐ Installation
Install globally via npm:
npm install -g aicโ๏ธ Setup
Before using aic, you must set your OpenAI API key:
- Create a
.envfile in the root of your project (or set an environment variable globally).
OPENAI_API_KEY=your-openai-api-key-hereMake sure this file is excluded from version control.
๐งช Usage
aicAfter running the command:
aicchecks for staged changes (git diff --cached).- It sends the diff to OpenAI.
- It shows you a suggested commit message.
- You confirm with
yor reject it.
Example Output
โ
Suggested commit message:
fix: handle null input in user validator
๐ค Do you want to use this commit message? (y/N):๐ ๏ธ How It Works
- Diff is extracted using
git diff --cached - Prompt is created and sent to the OpenAI Chat API
- AI categorizes and rewrites the commit message
- You approve or cancel
- Final commit is created with
git commit -mif confirmed
๐ Security Note
Your code diff is not stored anywhere. It is sent to OpenAI's API for the sole purpose of generating a commit message.
Make sure not to commit secrets or sensitive data to your staging area before using this tool.