Commit Style Guide

Oct 20, 2021
Oct 25, 2021

This style guide is the collection of precise rulesets that makes reviewing the Git commit messages and project history easier for everyone.

We encourage everyone from veterans to newcomers to follow through and read this guide before proceeding to contribute in any of the N3N project.

Commit Messages

This message structure is inspired from the Conventional Commits format. General for commit writing and specifications are presented in next section.

Message Structure

This message structure contains three relevant parts:

  1. Commit message header: the first line of any commit, mandatory for all projects.
  2. Commit message body: the description of the commit, necessary when there are lot of unrelated changes in a particular commit.
  3. Commit message footer: the footer of the commit, generally contains the signer's name and reference tags
<type>(scope): <description> [optional issue tags]
<optional body>
<optional footer(s)>

Commit Message Header


<type>(<scope>): <short summary> [<issue tags>]
  β”‚       β”‚             β”‚             β”‚
  β”‚       β”‚             β”‚             └─⫸ Issue tags can be in multiple numbers
  β”‚       β”‚             β”‚
  β”‚       β”‚             └─⫸ Summary in present tense. Not capitalized. No period at the end.
  β”‚       β”‚
  β”‚       └─⫸ Commit Scope: containing folder of the file that needs to be changed. This is mandatory
  └─⫸ Commit Type: new|fix|doc|imp|upd|fmt|chk|ext

Below this paragraph, all the different types have been explained with examples to get the gist of how to write better commits.

Commit Types

  1. fix: a commit of type fix patches a bug in your codebase (this correlates with PATCH in Semantic Versioning).
  2. new: a commit of type new introduces a new feature to the codebase (this correlates with MINOR in Semantic Versioning).
  3. BREAKING CHANGE: a commit that has a footer BREAKING CHANGE:, or appends a ! after the type/scope, introduces a breaking API change (correlating with MAJOR in Semantic Versioning). A BREAKING CHANGE can be part of commits of any type.
  4. doc: a commit of type doc identifies change in documentation of any part of the codebase.
  5. fmt: a commit of type fmt identifies formatting or styling change of the program (no changes in codebase when formatting is done).
  6. upd: a commit of type upd refactors production codebase (no changes in bugfix nor adds new features).
  7. imp: a commit of type imp improves performance of existing features and applies optimizations in codebase.
  8. chk: a commit of type chk adds missing test checks or fixes existing unit tests.
  9. ext: a commit of type ext identifies extra changes that affect helper scripts or external dependencies.
  10. bld: a commit of type bld changes to CI system, configurations, files and its scripts.

For example, below you can see the variety of types that are used to classify commit actions.

ext(yarn): add package.json with necessary dev deps
fmt(mizui): prettify all sass files inside mizui
upd(core)!: rename classes `hidden` and `shown` to `hide` and `show`
fix(defaults): fix content styling with formatting of other objects
imp(comps): integrate muse in cards along with tag components
new(comps): add mizui styled checkbox component

These are self explainatory commits, giving you an overview of actions occurring here.

Commit Scope

The scope, in general should be the name of the parent directory the file subject to changes is contained within. This implies to show the changes the file belonging to its location (as perceived by the person reading the changelog generated from commit messages).

For example, below you can see underlined scopes that defines the commit location.

fix(defaults): fix content styling with formatting of other objects
imp(comps): integrate muse in cards along with tag components
imp(mizui): update `font-family` vars with change in few things down the road

To elaborate,

  1. defaults defines the directory defaults in which changes were made
  2. comps defines the directory comps where the changes in components were made
  3. mizui is the project name which refers to whole scope of project, referring to multiple changes made in various scopes of the codebase.

Commit Summary

Use the summary field to provide a succinct description of the change:

For example, below you can see a sample commit that summarizes the details of changes made.

imp(app): add user specific application components
fix(defaults): focus outline showing at unprecedented viewports
imp(comps): integrate muse in cards along with tag components

Note that, the sentences are descriptive on their own having first words in present tense, none of the words are capitalized and no period is used in end.

Commit Issue Tag

Use commit tags to refer the particular issue that was resolved using the changes in this commit. Do note that:

Commit Message Body

Just as in the summary, use the imperative, present tense: "fix" not "fixed" nor "fixes".

Explain the motivation for the change in the commit message body. This commit message should explain why you are making the change. You can include a comparison of the previous behavior with the new behavior in order to illustrate the impact of the change.

The footer can contain information about breaking changes and deprecations and is also the place to reference GitHub issues, Jira tickets, and other PRs that this commit closes or is related to. For example:

BREAKING CHANGE: <breaking change summary>
<breaking change description + migration instructions>
Fixes #<issue number>


DEPRECATED: <what is deprecated>
<deprecation description + recommended update path>
Closes #<pr number>

Breaking Change section should start with the phrase "BREAKING CHANGE: " followed by a summary of the breaking change, a blank line, and a detailed description of the breaking change that also includes migration instructions.

Similarly, a Deprecation section should start with "DEPRECATED: " followed by a short description of what is deprecated, a blank line, and a detailed description of the deprecation that also mentions the recommended update path.

Revert Commits

If the commit reverts a previous commit, it should begin with revert: , followed by the header of the reverted commit.

The content of the commit message body should contain:


The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

  1. Commits MUST be prefixed with a type, which consists of a noun, feat, fix, etc., followed by the OPTIONAL scope, OPTIONAL !, and REQUIRED terminal colon and space.
  2. The type feat MUST be used when a commit adds a new feature to your application or library.
  3. The type fix MUST be used when a commit represents a bug fix for your application.
  4. A scope MAY be provided after a type. A scope MUST consist of a noun describing a section of the codebase surrounded by parenthesis, e.g., fix(parser):
  5. A description MUST immediately follow the colon and space after the type/scope prefix. The description is a short summary of the code changes, e.g., fix: array parsing issue when multiple spaces were contained in string.
  6. A longer commit body MAY be provided after the short description, providing additional contextual information about the code changes. The body MUST begin one blank line after the description.
  7. A commit body is free-form and MAY consist of any number of newline separated paragraphs.
  8. One or more footers MAY be provided one blank line after the body. Each footer MUST consist of a word token, followed by either a :<space> or <space># separator, followed by a string value (this is inspired by the git trailer convention).
  9. A footer’s token MUST use - in place of whitespace characters, e.g., Acked-by (this helps differentiate the footer section from a multi-paragraph body). An exception is made for BREAKING CHANGE, which MAY also be used as a token.
  10. A footer’s value MAY contain spaces and newlines, and parsing MUST terminate when the next valid footer token/separator pair is observed.
  11. Breaking changes MUST be indicated in the type/scope prefix of a commit, or as an entry in the footer.
  12. If included as a footer, a breaking change MUST consist of the uppercase text BREAKING CHANGE, followed by a colon, space, and description, e.g., BREAKING CHANGE: environment variables now take precedence over config files.
  13. If included in the type/scope prefix, breaking changes MUST be indicated by a ! immediately before the :. If ! is used, BREAKING CHANGE: MAY be omitted from the footer section, and the commit description SHALL be used to describe the breaking change.
  14. Types other than feat and fix MAY be used in your commit messages, e.g., docs: updated ref docs.
  15. The units of information that make up Conventional Commits MUST NOT be treated as case sensitive by implementors, with the exception of BREAKING CHANGE which MUST be uppercase.
  16. BREAKING-CHANGE MUST be synonymous with BREAKING CHANGE, when used as a token in a footer.