Commitizen provides three main CLI commands for interactive commit creation and adapter management.
cz, git-cz)Interactive commit interface that prompts users through commit message creation using configured adapters.
/**
* Bootstrap function for git-cz CLI command
* @param environment - Optional environment configuration
* @param argv - Command line arguments (defaults to process.argv)
*/
function bootstrap(environment?: object, argv?: string[]): void;Usage Examples:
# Basic commit (after adapter is configured)
git add .
cz
# Commit with git flags
cz --allow-empty
# Retry last commit attempt
cz --retry
# Commit with staged files check
cz -a # or --allEnvironment Options:
interface GitCzEnvironment {
config?: CommitizenConfig; // Override loaded config
cliPath?: string; // Path to CLI installation
}commitizen)CLI for installing and managing commitizen adapters in projects.
/**
* Bootstrap function for commitizen management CLI
* @param environment - Optional environment configuration
* @param argv - Command line arguments (defaults to process.argv)
*/
function bootstrap(environment?: object, argv?: string[]): void;Usage Examples:
# Initialize adapter with npm
commitizen init cz-conventional-changelog --save-dev --save-exact
# Initialize with yarn
commitizen init cz-conventional-changelog --yarn --dev --exact
# Force install over existing adapter
commitizen init cz-conventional-changelog --force --save-dev
# Initialize with pnpm
commitizen init cz-conventional-changelog --pnpm --save-dev --save-exact
# Include commitizen as dependency
commitizen init cz-conventional-changelog --save-dev --include-commitizenCommitizen automatically chooses the appropriate strategy based on configuration and command context.
/**
* Git strategy for repositories without commitizen configuration
* @param rawGitArgs - Git command arguments
* @param environment - Environment configuration
*/
function gitStrategy(rawGitArgs: string[], environment: object): void;
/**
* Git-CZ strategy for repositories with commitizen configuration
* @param rawGitArgs - Git command arguments
* @param environment - Environment configuration
* @param adapterConfig - Loaded adapter configuration
*/
function gitCzStrategy(rawGitArgs: string[], environment: object, adapterConfig: CommitizenConfig): void;Parses arguments for the git-cz command.
/**
* Parse git-cz command arguments
* @param rawArgs - Raw command line arguments
* @returns Parsed arguments object
*/
function parse(rawArgs: string[]): ParsedGitCzArgs;
interface ParsedGitCzArgs {
_: string[]; // Positional arguments
'allow-empty'?: boolean;
a?: boolean; // --all flag
all?: boolean;
[key: string]: any; // Additional git flags
}Parses arguments for the commitizen management command.
/**
* Parse commitizen management command arguments
* @param rawArgs - Raw command line arguments
* @returns Parsed arguments object
*/
function parse(rawArgs: string[]): ParsedCommitizenArgs;
interface ParsedCommitizenArgs {
_: string[]; // Positional arguments (command, adapter name)
save?: boolean; // --save flag
'save-dev'?: boolean; // --save-dev flag
'save-exact'?: boolean; // --save-exact flag
force?: boolean; // --force flag
yarn?: boolean; // --yarn flag
dev?: boolean; // --dev flag (yarn)
exact?: boolean; // --exact flag (yarn)
pnpm?: boolean; // --pnpm flag
hook?: string; // --hook flag for git hooks
amend?: boolean; // --amend flag
[key: string]: any;
}CLI commands handle various error conditions:
--allow-empty is specified