@lxgicstudios/ai-commit
v1.0.0
Published
Generate conventional commit messages from staged git changes. Detects scope from file paths, supports feat/fix/chore/refactor/docs types.
Maintainers
Readme
@lxgicstudios/ai-commit
Generate conventional commit messages from staged git changes. Zero dependencies.
Features
- Analyzes
git diff --stagedto detect commit type automatically - Detects scope from file paths (e.g., changes in
src/auth/-> scopeauth) - Supports all Conventional Commits types: feat, fix, chore, refactor, docs, style, test, ci, perf
- Dry-run mode to preview without committing
- Amend mode to rewrite the last commit message
- Breaking change support with
BREAKING CHANGEfooter - JSON output for CI/CD integration
- Zero external dependencies - uses only Node.js builtins
Installation
Run directly with npx:
npx @lxgicstudios/ai-commitOr install globally:
npm install -g @lxgicstudios/ai-commitUsage
Stage your changes, then run:
git add -A
npx @lxgicstudios/ai-commitOptions
| Option | Description | Default |
|--------|-------------|---------|
| --type <type> | Override commit type (feat, fix, chore, etc.) | Auto-detected |
| --scope <scope> | Override commit scope | Auto-detected |
| --breaking | Mark as breaking change | false |
| --dry-run | Preview message without committing | false |
| --amend | Rewrite the last commit message | false |
| --body <text> | Add a commit body | |
| --json | Output commit info as JSON | false |
| --help | Show help message | |
Commit Types
| Type | Description | When to use |
|------|-------------|-------------|
| feat | New feature | Adding new functionality |
| fix | Bug fix | Fixing broken behavior |
| docs | Documentation | README, comments, JSDoc |
| style | Code style | Formatting, semicolons, whitespace |
| refactor | Refactoring | Restructuring without changing behavior |
| chore | Maintenance | Dependencies, build, tooling |
| test | Tests | Adding or updating tests |
| ci | CI/CD | GitHub Actions, pipelines |
| perf | Performance | Optimizations |
Examples
# Auto-detect everything
npx @lxgicstudios/ai-commit
# Preview what it'd generate
npx @lxgicstudios/ai-commit --dry-run
# Force a specific type and scope
npx @lxgicstudios/ai-commit --type feat --scope auth
# Rewrite your last commit message
npx @lxgicstudios/ai-commit --amend
# Breaking change with body text
npx @lxgicstudios/ai-commit --breaking --body "Removed deprecated API endpoints"
# JSON output for scripts
npx @lxgicstudios/ai-commit --json --dry-runHow It Works
- Reads your staged git diff (
git diff --staged) - Analyzes file paths to detect scope (e.g.,
src/components/->components) - Scans diff content for patterns (fix keywords, new files, refactoring signals)
- Generates a Conventional Commits message:
type(scope): summary - Commits with the generated message (or previews in dry-run mode)
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/cool-feature) - Commit your changes (
git commit -m 'feat: add cool feature') - Push to the branch (
git push origin feature/cool-feature) - Open a Pull Request
License
MIT License. See LICENSE for details.
Built by LXGIC Studios
