Documentation
Commit with your repository’s rules.
Commitprompt is a small interactive CLI. It reads the local Commitlint configuration, validates the finished message, and only commits after you confirm it.
Installation
Install Commitprompt. Conventional Commitlint rules are included, so no separate validation package or configuration is required.
pnpm add --save-dev @santi020k/commitpromptnpm install --save-dev @santi020k/commitpromptyarn add --dev @santi020k/commitpromptConfiguration
Configuration is optional. Commitprompt uses Conventional Commits rules by default. Add a repository configuration to customize them:
export default {
rules: {
// 0 disables a rule, 1 warns, and 2 rejects the message.
'header-max-length': [0],
'body-max-line-length': [0],
'footer-max-line-length': [0],
'type-enum': [2, 'always', ['feat', 'fix', 'release']]
}
}Then expose the neutral binary through your package scripts:
{
"scripts": {
"commit": "commitprompt"
}
}Commitlint rule tuples use 0 to disable a rule,1 for a warning, and 2 for an error. Commitprompt also passes through repository parser presets, plugins, ignores, default ignores, and help URLs when it validates a message.
Usage
- Stage the files that belong in the commit.
- Run your repository’s commit script.
- Describe the change with the focused prompts.
- Finish a multiline body with an empty line.
- Review the generated message and confirm.
git add src/
pnpm commitEditor AI commit generation
Configure an editor’s native commit-message generator to use Commitprompt’s Conventional Commit format in every project:
commitprompt setup zed
commitprompt setup vscodeEach command updates the editor’s global settings while preserving comments, model selection, and existing commit-message instructions. They are safe to run more than once. The VS Code integration configures GitHub Copilot’s commit-message generation instructions; Copilot must be enabled for its Source Control button to be available.
Commit format
The generated message follows the Conventional Commits structure:
type(scope)!: short description
Optional longer description.
BREAKING CHANGE: optional breaking change
Closes #123The type, subject, body, footer, and any repository-specific constraints are checked by Commitlint before confirmation.
Repository rules
A repository configuration takes precedence over Commitprompt’s included defaults. Custom types appear in the prompt, and a message that fails validation can be revised without restarting the CLI.
Git hooks
Commitprompt validates every message created through its own commit flow. It does not currently install Git hooks, so a commit created directly by Git or an editor does not pass through Commitprompt.
To enforce the same policy for every commit, configure Commitlint in your repository’s commit-msg hook. Apre-commit hook runs before the commit message exists and is better suited to staged-file checks.
Automation and AI tools
AI tools can discover the repository’s allowed types, read generation instructions, format structured answers, and validate the exact result without parsing terminal prompts or bypassing repository rules.
commitprompt instructions --json
commitprompt types --json
commitprompt format --json <<'JSON'
{
"type": "feat",
"scope": "cli",
"subject": "accept structured input",
"body": "",
"breaking": "",
"issues": ""
}
JSON
printf '%s\n' 'feat(cli): accept structured input' \
| commitprompt validate --jsonThe format and commit commands read a JSON object from stdin by default. Every field is a string; optional values use an empty string. Use --input <path> to read a file and --cwd <path> to target another repository.
Programmatic API
The same Git, prompt, formatting, and validation pieces are exported independently, so you can compose a custom flow without shelling out to the CLI.
import {
createCommitlintValidator,
createGitClient,
runCommitFlow
} from '@santi020k/commitprompt'
const validator = createCommitlintValidator(process.cwd())
await runCommitFlow({
error: console.error,
git: createGitClient(process.cwd()),
log: console.log,
prompt,
types: await validator.getTypes(),
validator
})runAutomationPowers structured format, validation, discovery, and explicitly confirmed commit operations.
runCommitFlowCoordinates staging checks, prompts, validation, confirmation, and commit creation.
formatCommitMessageFormats structured answers into a complete Conventional Commit message.
createCommitlintValidatorLoads repository rules or the included defaults and exposes validation and prompt types.
DEFAULT_COMMIT_TYPESProvides the built-in feat, fix, docs, refactor, test, and maintenance choices.
Requirements
- Node.js 22.18 or newer
- Git
- At least one staged change
Need the implementation details?
The source is small, typed, and organized by responsibility.