Using CommitAI
Generate clean commit messages powered by AI—based on your actual git diff.
1. Stage Your Changes
CommitAI analyzes your staged changes. You must stage files before running the command:
git add .
2. Generate Commit Messages
Run the following command in your project:
commitai commit
CommitAI reads your git diff, sends it to the API, and presents you with 3 clean commit suggestions.
Example Output
🚀 Generating AI-powered commit message... 💡 Commit Suggestions: 1. fix(api): improve error msg when token is missing 2. fix(api): improve error message when token is missing. Helps with debugging. 3. fix(api): improve error messaging for missing authentication token to aid debugging. ✔ Select your commit message: fix(api): improve error msg when token is missing [main 3765f23] fix(api): improve error msg when token is missing 1 file changed, 2 insertions(+), 2 deletions(-)
The CLI automatically commits the selected message.
How It Works Behind the Scenes
- • CLI reads your staged git diff.
- • Sends diff + file list to CommitAI backend.
- • Backend generates structured JSON commit messages.
- • You choose one message in the terminal.
- • CLI runs: git commit -m "..."
Tip: Use git add -p for partial staging to get cleaner, more focused commit messages.