Commands
bc CLI reference — commit, check, fix, retry, doctor, and init
The bc binary (alias better-commit) provides interactive commits and validation using your commit.config.ts.
Command overview
| 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 |
bc stack | List the local commit stack and Change-Ids |
bc amend <target> | Amend a specific commit in the stack |
bc commit
Run the interactive commit flow. Prompts for type, scope, and subject based on config rules.
bc
bc commitWith aiSuggest configured, the CLI can propose a message from your staged diff before you confirm.
Staging behavior
If there are no staged files when running bc commit or bc retry, the CLI handles it adaptively:
- Clean repository: If there are no unstaged or staged changes, the CLI cancels early with
No changes to commit. - Small changes (≤ 10 files): Directly prompts you with an interactive multiselect menu where all unstaged files (including untracked files) are pre-selected. You can press Enter to stage all, or toggle selections to stage a subset.
- Large changes (> 10 files): Displays a menu first to choose between:
Stage all files (X files)Select files interactively...(shows the multiselect menu)Cancel
Options
| Option | Description |
|---|---|
--no-ai | Skip AI suggestions |
--dry-run | Preview the message without committing |
--hook <file> | Write message to a file (used by Git hooks; not for direct use) |
bc init
Create a starter commit.config.ts at the repository root.
bc init
bc init -q # non-interactive
bc init -q -f # overwrite existing config
bc init --hooks # also install Husky prepare-commit-msg hook| Option | Description |
|---|---|
-q, --quiet | Skip prompts |
-f, --force | Overwrite existing files (required with -q) |
--hooks | Install .husky/prepare-commit-msg |
Requires Husky for hooks: npm install -D husky && npx husky init
bc doctor
Verify your environment and configuration.
bc doctorChecks Node version, config discovery, resolved plugins, and available AI providers.
bc check
Validate commit messages using the same rules as the interactive flow.
bc check # validate last commit
bc check --edit # validate COMMIT_EDITMSG
bc check --from v1.0.0 --to HEAD # validate commit range| Option | Description |
|---|---|
-e, --edit | Validate the message in COMMIT_EDITMSG (commit-msg hook pattern) |
--from <ref> | Range start (requires --to) |
--to <ref> | Range end (requires --from) |
Use only one mode: default (last commit), --edit, or --from/--to together.
Examples
Validate the message being composed (useful in a commit-msg hook):
bc check --editValidate all commits since a tag:
bc check --from v1.0.0 --to HEADValidate commits between two refs:
bc check --from abc1234 --to def5678bc fix
Amend the last commit message interactively.
bc fix
bc fix --no-ai # skip AI when suggesting a new messagebc retry
Retry the last interactive commit from cache when a previous attempt was interrupted.
bc retrybc stack
List the local commits in the current branch stack starting from the detected base branch up to HEAD, showing their hashes, titles, and Change-Id footers.
bc stack
bc stack --base main| Option | Description |
|---|---|
--base <ref> | Base branch/commit to compare against (defaults to auto-detection) |
The CLI auto-detects the base branch by looking for the upstream tracking branch or common fallbacks (origin/main, origin/master, main, master).
bc amend
Amend a specific commit in the local stack using staged changes. It creates a fixup! commit and automatically runs a non-interactive Git autosquash rebase to merge the changes cleanly into the target commit while preserving its Change-Id footer.
bc amend 2
bc amend I8f9c0e2d
bc amend 323c58f| Option | Description |
|---|---|
--base <ref> | Base branch/commit to compare against (defaults to auto-detection) |
The <target> argument can be:
- A 1-based index from the bottom of the stack (e.g.
2to amend the second commit). - A Change-Id prefix or string (e.g.
I8f9c0e2d). - A commit SHA prefix (e.g.
323c58f).
If the rebase runs into merge conflicts, the CLI halts, explains the conflict, and leaves you in Git's normal rebase state where you can resolve files and run git rebase --continue.
Global 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 |
See CI and hooks for pipeline and Git hook integration.