AI Commit
Generate AI-powered git commit messages with security scanning
The commit command generates intelligent git commit messages based on your staged changes using AI, with built-in security scanning to prevent accidental exposure of sensitive data.
Quick Start
# Full auto mode: stage, security check, commit, and push
praisonai commit -a
# Interactive mode
git add .
praisonai commitUsage
Full Auto Mode (Recommended)
praisonai commit -aThis single command will:
- Auto-stage all changes (
git add -A) - Security scan for sensitive content (API keys, passwords, secrets)
- Generate AI commit message from diff
- Commit with the generated message
- Push to remote repository
Expected Output:
Auto-staging all changes...
Staged changes:
src/main.py | 15 +++++++++------
tests/test_main.py | 8 ++++++++
2 files changed, 17 insertions(+), 6 deletions(-)
Generating commit message...
Suggested commit message:
feat(main): add user authentication with JWT tokens
✅ Committed successfully!
✅ Pushed to remote!Interactive Mode
praisonai commitExpected Output:
Staged changes:
src/main.py | 15 +++++++++------
tests/test_main.py | 8 ++++++++
2 files changed, 17 insertions(+), 6 deletions(-)
Generating commit message...
Suggested commit message:
feat(main): add user authentication with JWT tokens
- Implement JWT token generation and validation
- Add login and logout endpoints
- Include unit tests for authentication flow
Options:
[y] Use this message and commit
[e] Edit the message
[n] Cancel
Your choice [y/e/n]: Commit and Push (Interactive)
praisonai commit --pushThis will generate the commit message, commit the changes, and push to the remote repository after confirmation.
Workflow
- Stage Changes: Use
git addto stage your changes - Run Command: Execute
praisonai commit - Review Message: AI generates a commit message based on the diff
- Choose Action:
y– Accept and commite– Edit the message in your default editorn– Cancel
Commit Message Format
The AI follows the Conventional Commits specification:
<type>(<scope>): <short description>
<optional body with more details>Types
| Type | Description |
|---|---|
feat | A new feature |
fix | A bug fix |
docs | Documentation changes |
style | Code style changes (formatting, etc.) |
refactor | Code refactoring |
test | Adding or updating tests |
chore | Maintenance tasks |
Examples
feat(auth): add user authentication with JWT tokens
fix(api): resolve null pointer exception in user lookup
docs(readme): update installation instructions
refactor(database): optimize query performance for large datasets
test(auth): add unit tests for login flowOptions
| Option | Description |
|---|---|
-a, --auto | Full auto mode: stage all, security check, commit, and push |
--push | Automatically push after committing (interactive mode) |
--no-verify | Skip security check (use with caution) |
Security Scanning
The commit command includes built-in security scanning to prevent accidental exposure of sensitive data.
Detected Patterns
API Keys & Tokens
- API keys (
api_key,apikey) - Secret keys (
secret_key,secretkey) - Access tokens (
access_token,accesstoken) - Auth tokens (
auth_token,authtoken) - Client secrets (
client_secret)
Cloud Provider Credentials
- AWS Access Key IDs (
AKIA...) - AWS Secret Access Keys
- GitHub Personal Access Tokens (
ghp_...) - GitHub OAuth Tokens (
gho_...) - GitLab Personal Access Tokens (
glpat-...) - Slack Tokens (
xox...)
Passwords & Private Keys
- Passwords (
password,passwd,pwd) - Database passwords (
db_password) - Private keys (PEM, RSA, DSA, EC, OPENSSH, PGP)
Sensitive Files
- Environment files:
.env,.env.local,.env.production,.env.development - SSH keys:
id_rsa,id_dsa,id_ecdsa,id_ed25519 - Certificates:
.pem,.key,.p12,.pfx,.jks,.keystore - Credentials:
credentials,secrets.json,secrets.yaml,.htpasswd,.netrc
Security Warning Example
⚠️ SECURITY WARNING: Sensitive content detected!
• API Key in diff: api_key = "sk-1234567890abcdefghij...
• Sensitive File in config/.env: .env
Options:
[c] Continue anyway (not recommended)
[a] Abort commit
[i] Ignore and add to .gitignore
Your choice [c/a/i]: Auto Mode Behavior
In auto mode (-a), if sensitive content is detected:
- The commit is automatically aborted
- No changes are pushed
- You must fix the issue or use
--no-verifyto proceed
# Auto mode aborts on security issues
praisonai commit -a
# Output: Auto mode aborted due to security concerns. Use --no-verify to skip.
# Skip security check (not recommended)
praisonai commit -a --no-verifyRequirements
- Git must be installed and available in PATH
- You must be in a git repository
- For interactive mode: changes must be staged with
git add - For auto mode (
-a): changes will be auto-staged
Error Handling
No Staged Changes
$ praisonai commit
No staged changes. Use 'git add' to stage files first, or use -a/--auto.Solution: Stage your changes with git add . or use praisonai commit -a for auto-staging
Not in Git Repository
$ praisonai commit
ERROR: Not in a git repositorySolution: Navigate to a git repository or initialize one with git init
Customization
Using a Different Model
praisonai commit honours the same LLM-selection cascade as every other CLI command. The first match wins:
# 1. CLI flag — recommended, overrides everything else
praisonai commit --llm claude-3-5-sonnet-latest
# 2. MODEL_NAME env var — inherits your usual PraisonAI model
MODEL_NAME=claude-3-5-sonnet-latest praisonai commit
# 3. OPENAI_MODEL_NAME env var — still works for OpenAI users
OPENAI_MODEL_NAME=gpt-4o praisonai commit
# 4. Fallback — gpt-4o-mini when nothing is set
praisonai commitGit Identity Configuration
Configure custom git commit author for praisonai commit command.
Environment Variables
Set these in your shell configuration:
export PRAISONAI_GIT_USER_NAME="Your Name"
export PRAISONAI_GIT_USER_EMAIL="your.email@example.com"GitHub Noreply Email
Use GitHub’s noreply email to protect your personal email:
export PRAISONAI_GIT_USER_NAME="YourUsername"
export PRAISONAI_GIT_USER_EMAIL="YourUsername@users.noreply.github.com"Verification
After setting, commits will show your identity:
praisonai commit -a
# Commits as: Your Name <your.email@example.com>Custom Editor
Set the EDITOR environment variable to use your preferred editor:
export EDITOR=vim
praisonai commit
# Choose 'e' to edit with vimBest Practices
Always review the generated message before accepting
Stage Related ChangesStage related changes together for better commit messages
Small CommitsMake small, focused commits for clearer messages
Edit When NeededUse the edit option to refine the message
Integration with Git Workflow
# Full auto workflow (recommended)
praisonai commit -a
# Interactive workflow
git add src/feature.py tests/test_feature.py
praisonai commit
git push
# Interactive with auto-push
git add .
praisonai commit --pushTroubleshooting
| Issue | Solution |
|---|---|
| Empty commit message | Ensure changes are staged and diff is not empty |
| API error | Check your OpenAI API key is set |
| Editor not opening | Set the EDITOR environment variable |
| Push failed | Check remote repository access and authentication |
| Security warning in auto mode | Fix sensitive content or use --no-verify |
| Auto mode aborted | Remove sensitive files from staging or add to .gitignore |
| Commits show “PraisonAI” instead of my name | Set PRAISONAI_GIT_USER_NAME and PRAISONAI_GIT_USER_EMAIL env vars |
Related
- Git Identity Configuration – Configure commit author identity
- CLI Overview – PraisonAI CLI documentation
- Planning – AI planning mode