> ## Documentation Index
> Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Full auto mode: stage, security check, commit, and push
praisonai commit -a

# Interactive mode
git add .
praisonai commit
```

<img src="https://mintcdn.com/praisonai/SX0Y8_-DRBjzOTnt/docs/cli/commit-git-commit-helper.gif?s=045abce1255e54b3f3c9e2ebddb563e3" alt="Git Commit Helper" width="1497" height="1104" data-path="docs/cli/commit-git-commit-helper.gif" />

## Usage

### Full Auto Mode (Recommended)

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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!
```

<Warning>
  If sensitive content is detected in auto mode, the commit will be **automatically aborted** for safety. Use `--no-verify` to skip security checks (not recommended).
</Warning>

### Interactive Mode

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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**:
   * `y` - Accept and commit
   * `e` - Edit the message in your default editor
   * `n` - Cancel

## Commit Message Format

The AI follows the [Conventional Commits](https://www.conventionalcommits.org/) 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 flow
```

## Options

| 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

<AccordionGroup>
  <Accordion title="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`)
  </Accordion>

  <Accordion title="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...`)
  </Accordion>

  <Accordion title="Passwords & Private Keys">
    * Passwords (`password`, `passwd`, `pwd`)
    * Database passwords (`db_password`)
    * Private keys (PEM, RSA, DSA, EC, OPENSSH, PGP)
  </Accordion>

  <Accordion title="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`
  </Accordion>
</AccordionGroup>

### 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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# 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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
$ 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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
$ 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

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
OPENAI_MODEL_NAME=gpt-4o praisonai commit
```

### Git Identity Configuration

Configure custom git commit author for `praisonai commit` command.

#### Environment Variables

Set these in your shell configuration:

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai commit -a
# Commits as: Your Name <your.email@example.com>
```

<Info>
  For detailed git identity configuration across all PraisonAI services, see [Git Identity Configuration](/cli/git-identity).
</Info>

### Custom Editor

Set the `EDITOR` environment variable to use your preferred editor:

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
export EDITOR=vim
praisonai commit
# Choose 'e' to edit with vim
```

## Best Practices

<CardGroup cols={2}>
  <Card title="Review Before Accepting" icon="eye">
    Always review the generated message before accepting
  </Card>

  <Card title="Stage Related Changes" icon="layer-group">
    Stage related changes together for better commit messages
  </Card>

  <Card title="Small Commits" icon="minimize">
    Make small, focused commits for clearer messages
  </Card>

  <Card title="Edit When Needed" icon="pen">
    Use the edit option to refine the message
  </Card>
</CardGroup>

## Integration with Git Workflow

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# 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

| 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](/cli/git-identity) - Configure commit author identity
* [CLI Overview](/cli/cli) - PraisonAI CLI documentation
* [Planning](/cli/planning) - AI planning mode
