| name | better-commit |
| description | Use better-commit CLI for TypeScript-first conventional commits. Run `bc` or `bc commit` interactively. Configure via root `commit.config.ts` with `defineConfig` and plugins from `@better-commit/cli/config`. |
| tags | ["cli","commit","conventional-commits","ai"] |
better-commit
Interactive conventional commits with optional AI, driven by commit.config.ts (plugins, resolved rules). Validates with bc check using the same rules as the interactive flow.
When to use
- Creating commits in
type(scope): subject form with allowed types/scopes from config
- Generating messages from staged diff (with
aiSuggest plugin)
- Amending the last message (
bc fix)
- Validating messages (
bc check, including COMMIT_EDITMSG or a ref range)
- Bootstrapping config (
bc init → commit.config.ts)
Commands
| Command | Description |
|---|
bc / bc commit | Interactive commit (default) |
bc init | Create commit.config.ts |
bc doctor | Verify config loads, list plugins, providers |
bc check | Validate last commit (or --edit / --from–--to) |
bc fix | Amend last commit message |
bc retry | Retry commit from cache |
Options
| Option | Commands | Description |
|---|
--no-ai | commit, fix | Skip AI |
--dry-run | commit | Preview message only |
-q, --quiet | init | Skip prompts |
--hooks | init | Install Husky hooks |
-e, --edit | check | Validate COMMIT_EDITMSG |
--from / --to | check | Validate commit range |
Configuration
Use commit.config.ts at the repo root (see bc init). Import helpers from @better-commit/cli/config:
import {
aiSuggest,
conventionalCommits,
defineConfig,
} from "@better-commit/cli/config";
export default defineConfig({
plugins: [
conventionalCommits({ types: ["feat", "fix", "docs", "chore"] }),
aiSuggest({ provider: "auto" }),
],
});
Omit aiSuggest for offline-only / manual commits.
Environment
BETTER_COMMIT_NO_AI=1 — disable AI even if aiSuggest is configured
BETTER_COMMIT_CURSOR_AUTO_APPROVE=1 — auto-approve Cursor ACP tool permissions (default: prompt user)
Git hooks
To integrate better-commit with your Git hooks:
bc init --hooks
Example .husky/prepare-commit-msg:
#!/usr/bin/env sh
[ -n "$BETTER_COMMIT_SKIP_HOOK" ] && exit 0
[ "$2" = "merge" ] || [ "$2" = "squash" ] && exit 0
export GIT_EDITOR=cat
exec < /dev/tty > /dev/tty 2>&1 bc commit --hook "$1"
The --hook flag is for Git hooks only — use bc or bc commit directly for the normal workflow.
Security
- Diffs are sanitized before AI calls
- Prefer local
@better-commit/cli install for reproducible config loading