🧠 Commit Agent

A smart AI-powered Git commit message generator for Dart and Flutter projects.
It automatically analyzes your Git changes (git diff) and suggests a clean, concise, and meaningful commit message using OpenAI.


πŸš€ Features

βœ… Automatically stages and analyzes your code changes
βœ… Generates professional commit messages using OpenAI GPT models
βœ… Interactive CLI β€” choose commit type and confirm messages
βœ… Works on Windows, macOS, and Linux
βœ… No manual initialization required in CI/CD environments
βœ… Safe to use β€” requires explicit confirmation before committing


🧩 Getting Started

πŸ”§ Installation

Add this to your dev_dependencies in your pubspec.yaml:

dev_dependencies:
  commit_agent: ^1.0.0

Then run:

flutter pub get

βš™οΈ Running the Commit Agent

Now that CI/CD handles initialization, you only need to set your OpenAI API key and run the CLI command.

  1. Set your OpenAI API key as an environment variable

Linux / macOS:

export OPENAI_API_KEY="sk-your-key"

Windows PowerShell:

setx OPENAI_API_KEY "sk-your-key"
  1. Run the Commit Agent
dart run commit_agent

The agent will:

  1. Stage all changes (git add .)
  2. Ask for the commit type (e.g., FEAT, FIX, REFACTOR, DOCS, etc.)
  3. Optionally take your note
  4. Generate an AI-based commit message
  5. Ask for confirmation before committing and pushing πŸš€

🧰 Example Output

βœ… All changes staged.
Select commit type:
1. FEAT
2. FIX
3. CHORE
4. REFACTOR
5. DOCS
6. TEST
7. STYLE
8. BUG

Enter choice: 1
πŸ“ Optional note: Added login validation

🧠 Suggested commit message:
[FEAT] Improve login validation flow with error handling

Proceed? (y/n): y
πŸš€ Commit created & pushed successfully!

πŸ— CI/CD Integration

Since CI/CD pipelines now handle initialization, you don’t need to call initCommitAgent() manually. Just make sure the environment variable OPENAI_API_KEY is available in your CI/CD runner before running:

dart run commit_agent

🧾 License

This project is licensed under the MIT License β€” feel free to use it in personal and commercial projects.

Copyright (c) 2025 Rohan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.

πŸ§‘β€πŸ’» Author

Rohan Kumar Chaudhary (@rohan-165) πŸ“§ rohanchy165@gmail.com πŸ’» GitHub

πŸ’¬ β€œLet your commits tell a story β€” not just a change.”

Libraries

commit_agent
πŸ“¦ commit_agent