Interactive Git Commit Message CLI

1.12.0 · active · verified Wed Apr 22

czg is an interactive command-line interface (CLI) tool designed to streamline the process of generating standardized Git commit messages, primarily adhering to the Conventional Commits specification. Currently at version 1.12.0, the package maintains an active release cadence with frequent updates. It functions as a lightweight, zero-dependency wrapper for Commitizen, leveraging the core features and extensive customization options of `cz-git`. Key differentiators include its interactive prompts, support for AI-generated commit messages via OpenAI integration, and seamless compatibility with `commitlint` for message validation. It aims to simplify commit consistency across projects, making it a valuable tool for TypeScript and Node.js development environments.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to install and run the `czg` CLI tool, including how to invoke it directly, through an npm script, with a custom configuration file, and utilize its OpenAI integration for AI-generated commit messages.

{
  "scripts": {
    "commit": "czg"
  },
  "config": {
    "commitizen": {
      "path": "cz-git"
    }
  }
}

// To use it interactively:
npx czg

// Or if configured in package.json:
npm run commit

// Example with custom config file:
npx czg --config './.cz-config.js'

// Example using AI to generate commit message (requires OPENAI_API_KEY environment variable)
process.env.OPENAI_API_KEY ??= 'sk-your-openai-api-key'; // For local testing, ensure you set this
npx czg ai -M="gpt-4o-mini"

// Example .cz-config.js for programmatic configuration (using defineConfig from czg)
// /** @type {import('czg').UserConfig} */
// const config = defineConfig({
//   rules: {
//     'type-enum': [
//       2,
//       'always',
//       [
//         'feat', 'fix', 'docs', 'style', 'refactor', 'perf', 'test', 'build', 'ci', 'chore', 'revert', 'wip'
//       ]
//     ],
//     'scope-enum': [
//       2,
//       'always',
//       [
//         'core', 'components', 'utils', 'config', 'deps', 'release'
//       ]
//     ]
//   },
//   prompt: {
//     scopes: ['core', 'components', 'utils', 'config', 'deps', 'release']
//   }
// })
// module.exports = config;

view raw JSON →