๐ŸŒ US-Proxy
class="wp-singular page-template page-template-page-guide page page-id-932437 wp-embed-responsive wp-theme-twentytwentyfour wp-child-theme-twentytwentyfour-child praison-paper">
On this page

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#

bash
# Full auto mode: stage, security check, commit, and push
praisonai commit -a

# Interactive mode
git add .
praisonai commit

Git Commit Helper

Usage#

bash
praisonai commit -a

This single command will:

  1. Auto-stage all changes (git add -A)
  2. Security scan for sensitive content (API keys, passwords, secrets)
  3. Generate AI commit message from diff
  4. Commit with the generated message
  5. 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#

bash
praisonai commit

Expected 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)#

bash
praisonai commit --push

This will generate the commit message, commit the changes, and push to the remote repository after confirmation.

Workflow#

  1. Stage Changes: Use git add to stage your changes
  2. Run Command: Execute praisonai commit
  3. Review Message: AI generates a commit message based on the diff
  4. Choose Action:
  5. y – Accept and commit
  6. e – Edit the message in your default editor
  7. n – Cancel

Commit Message Format#

The AI follows the Conventional Commits specification:

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

<optional body with more details>

Types#

TypeDescription
featA new feature
fixA bug fix
docsDocumentation changes
styleCode style changes (formatting, etc.)
refactorCode refactoring
testAdding or updating tests
choreMaintenance 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 flow

Options#

OptionDescription
-a, --autoFull auto mode: stage all, security check, commit, and push
--pushAutomatically push after committing (interactive mode)
--no-verifySkip 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-verify to proceed
bash
# 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-verify

Requirements#

  • 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#

bash
$ 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#

bash
$ praisonai commit
ERROR: Not in a git repository

Solution: 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:

bash
# 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 commit

Git Identity Configuration#

Configure custom git commit author for praisonai commit command.

Environment Variables#

Set these in your shell configuration:

bash
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:

bash
export PRAISONAI_GIT_USER_NAME="YourUsername"
export PRAISONAI_GIT_USER_EMAIL="YourUsername@users.noreply.github.com"

Verification#

After setting, commits will show your identity:

bash
praisonai commit -a
# Commits as: Your Name <your.email@example.com>

Custom Editor#

Set the EDITOR environment variable to use your preferred editor:

bash
export EDITOR=vim
praisonai commit
# Choose 'e' to edit with vim

Best Practices#

Review Before Accepting

Always review the generated message before accepting

Stage Related Changes

Stage related changes together for better commit messages

Small Commits

Make small, focused commits for clearer messages

Edit When Needed

Use the edit option to refine the message

Integration with Git Workflow#

bash
# 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 --push

Troubleshooting#

IssueSolution
Empty commit messageEnsure changes are staged and diff is not empty
API errorCheck your OpenAI API key is set
Editor not openingSet the EDITOR environment variable
Push failedCheck remote repository access and authentication
Security warning in auto modeFix sensitive content or use --no-verify
Auto mode abortedRemove sensitive files from staging or add to .gitignore
Commits show “PraisonAI” instead of my nameSet PRAISONAI_GIT_USER_NAME and PRAISONAI_GIT_USER_EMAIL env vars