cmt: Write consistent git commit messages

[ bsd3, command-line-tools, library, program ] [ Propose Tags ]

Please see the README on GitHub at

[Skip to Readme]
Versions [faq],,,,,,
Dependencies attoparsec (>= && <0.14), base (>=4.7 && <5), classy-prelude (>=1.5.0 && <1.6), cmt, directory (>= && <1.4), filepath (>= && <1.5), process (>= && <1.7), terminal-size (>= && <0.4), text (>= && <1.3) [details]
License BSD-3-Clause
Copyright Small Hadron Collider / Mark Wales
Author Small Hadron Collider / Mark Wales
Category Command Line Tools
Home page
Bug tracker
Source repo head: git clone
Uploaded by smallhadroncollider at 2019-03-08T20:05:32Z
Distributions NixOS:
Executables cmt
Downloads 1905 total (6 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2019-03-08 [all 1 reports]


[Index] [Quick Jump]


Maintainer's Corner

For package maintainers and hackage trustees

Readme for cmt-

[back to package description]


Write consistent git commit messages


Binaries for Mac and Linux are available. Add the binary to a directory in your path (such as /usr/local/bin).


Requirements: Cabal

cabal install cmt

Make sure you run cabal update if you haven't run it recently.


Requirements: Stack

The following command will build cmt and then install it in ~/.local/bin:

stack build && stack install


Add a .cmt file to your project directory.

cmt # will show the options and then commit

If you're using the ${*} format option then:

cmt "blah blah blah" # this will go in ${*} place

If there are commit message you use frequently (such as "version bump"), you can setup predefined messages with aliases:

cmt -p vb # use the version bump message

If the commit returns with a non-zero status code, your previous commit message is stored in a .cmt.bkp file. You can re-run the commit when you're ready with:

cmt --prev


A .cmt file consist of two parts: the input parts and the output format.

For example, the AngularJS Commit Message Guidelines:

# The input parts
    # Shows a list of options
    "Type" = [
    "Scope" = % # Select from a list of staged files
    "Subject" = @ # Single line input
    "Body" = !@ # Multi-line input
    "Footer" = !@

# predefined messages
    vb = "chore (package.yaml): version bump"
    readme = "docs ( updated readme"

# The output format
# Takes the values provided from the input stage
# and interpolates them in
${Type} (${Scope}): ${Subject}



Input Parts

These are at the top of the .cmt file and surrounded by opening and closing curly braces. A consist of a name and a type:

  • @: single line input
  • !@: multi line input
  • %: select from a list of staged files
  • ["option 1", "option 2"]: list of options

Output Format

The output format consists of named input parts plus anything else you want.

You can accept a output called ${*}, which will add in whatever is passed to cmt as command line arguments.

For example:

# Input parts
# * input not needed, as comes from command-line
    "Scope" = %

# Scope from input and * from command-line
(${Scope}): ${*}

Then use with:

cmt "Blah blah blah"