Skip to content

Repository files navigation

Standard Commit

A practical guide for setting up a Conventional Commits workflow with Husky, Commitlint and Commitizen.

license

Why?

Instead of configuring Husky, Commitlint, Commitizen and Release Please individually, this guide shows how to combine them into a complete Conventional Commits workflow.

Example

feat(auth): add OAuth login

fix(api): prevent duplicate requests

docs(readme): improve installation guide

Features

  • Validate commit messages against the Conventional Commits specification.
  • Create commit messages interactively with Commitizen.
  • Automate releases and CHANGELOG.md generation.
  • Keep version numbers in sync with your release history.

Installation

1. Install Dependencies

Install the necessary dependencies locally:

yarn add --dev husky @commitlint/cli @commitlint/config-conventional cz-conventional-changelog

2. Install Commitizen globally

Install Commitizen globally to enable standardized commit message formatting:

sudo yarn global add commitizen

3. Update package.json

Update your project's package.json file to configure Commitizen:

{
  ...

  "config": {
    "commitizen": {
        "path": "./node_modules/cz-conventional-changelog",
        "disableScopeLowerCase": true
    }
  },

  ...
}

4. Configure Commitlint

Create a commitlint.config.js file in your project root directory to configure Commitlint:

module.exports = {
  extends: ["@commitlint/config-conventional"],
  rules: {
    "scope-case": [0],
  },
};

5. Set up Husky

npx husky init

6. Set up Release Please

Automate release management with Release Please:

Deploy release-please with GitHub Action by creating a .github/workflows/release-please.yml file with these contents:

on:
  push:
    branches:
      - main
name: release-please
jobs:
  release-please:
    runs-on: ubuntu-latest
    steps:
      - uses: google-github-actions/release-please-action@v3
        with:
          release-type: node
          package-name: release-please-action

Make sure you have the correct Workflow permissions on your repository (Settings > Actions > General):

Workflow permissions

Usage

Standard Commit simplifies the process of writing standardized commit messages:

Commitizen template

Using Commitizen

Instead of git commit, use git cz to open a wizard and generate a standardized commit message:

git add .
git cz
git push --follow-tags

Normal commit command

You can still use git commit ... but the commit will fail if the commit message is not properly formatted.

git add .
git commit -m "feat(blog): add comment section"
git push --follow-tags

Built with

Contributing

Want to contribute? All contributions are welcome. Read the contributing guide.

Questions

Questions, suggestions and bug reports are welcome. Feel free to open an issue.

License

This project is licensed under the MIT License. See the LICENSE file for details

About

Guidelines to standardize commit messages

Topics

Resources

Contributing

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages