TExcelTAD
Home › Release Engineering & CI/CD › Configuring git-cliff

Configuring git-cliff

The default cliff.toml is a good start, but every project ends up changing the same few things: the section names, which commits to hide, how to treat commits that aren't conventional, which tags count as releases, and links to the hosting service. This lesson writes a compact configuration from scratch so every line is accounted for.

The structure of cliff.toml

Table Controls
[changelog] the output: header, body (a Tera template rendered once per release), footer, trim, postprocessors (regex replacements on the final text)
[git] the input: conventional_commits, filter_unconventional, require_conventional, commit_preprocessors, commit_parsers (group/skip rules), protect_breaking_commits, tag_pattern, skip_tags, sort_commits
[bump] version computation: features_always_bump_minor, breaking_always_bump_major, initial_tag, custom regexes for major/minor bumps
[remote.github] (gitlab, gitea, bitbucket) owner/repo for fetching PR and contributor data from the API (needs the network and a token)

A Keep a Changelog configuration

This configuration produces Keep a Changelog sections, links each version to its diff, hides the release commits and dependency bumps, and puts breaking changes first:

bash · try it yourself
mkdir lib && cd lib && git init -q
c() { git commit -q --allow-empty -m "$1" "${@:2}"; }
cat > cliff.toml <<'TOML'
[changelog]
header = """
# Changelog\n
All notable changes to this project are documented here.\n
"""
body = """
{% if version -%}
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else -%}
## [Unreleased]
{% endif %}
{% for commit in commits | filter(attribute="breaking", value=true) -%}
- **Breaking:** {{ commit.breaking_description | default(value=commit.message) }}
{% endfor %}{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | striptags | trim }}
{% for commit in commits %}
- {% if commit.scope %}**{{ commit.scope }}:** {% endif %}{{ commit.message | upper_first }} ([{{ commit.id | truncate(length=7, end="") }}](<REPO>/commit/{{ commit.id }}))
{%- endfor %}
{% endfor %}
"""
footer = ""
trim = true
postprocessors = [{ pattern = '<REPO>', replace = "https://github.com/acme/lib" }]

[git]
conventional_commits = true
filter_unconventional = false
protect_breaking_commits = true
tag_pattern = "v[0-9].*"
commit_parsers = [
  { message = "^feat", group = "<!-- 0 -->Added" },
  { message = "^fix", group = "<!-- 1 -->Fixed" },
  { message = "^perf", group = "<!-- 2 -->Changed" },
  { message = "^[a-z]+(\\(.+\\))?!:", group = "<!-- 2 -->Changed" },
  { body = ".*security", group = "<!-- 3 -->Security" },
  { message = "^chore\\(release\\)", skip = true },
  { message = "^chore\\(deps\\)", skip = true },
  { message = "^(chore|ci|docs|test|refactor|style|build)", skip = true },
  { message = ".*", group = "<!-- 4 -->Other" },
]
sort_commits = "oldest"
TOML
c "feat: first release"; git tag -a v1.0.0 -m "1.0.0"
c "chore(release): 1.0.0"
c "fix(io): close files on error"
c "chore(deps): bump serde to 1.0.229"
c "feat(cli): add --json output"
c "refactor(api)!: rename Client to Session" -m "BREAKING CHANGE: Client is now called Session."
c "fix: reject paths outside the project" -m "This is a security fix for path traversal."
c "Update the logo"
git tag -a nightly-1 -m "nightly"
git-cliff --tag v2.0.0
# Changelog

All notable changes to this project are documented here.

## [2.0.0] - 2026-10-23

- **Breaking:** Client is now called Session.

### Added

- **cli:** Add --json output ([d3e7490](https://github.com/acme/lib/commit/d3e74904998ef16b43ff497d157ab7976cb3910a))

### Fixed

- **io:** Close files on error ([3796eb8](https://github.com/acme/lib/commit/3796eb8920966f94502137ce6cfb760462b693b8))
- Reject paths outside the project ([e8e5e4f](https://github.com/acme/lib/commit/e8e5e4fe48fc5b5aadf292e5ad73a4ab1cd07b22))

### Changed

- **api:** Rename Client to Session ([6bd1957](https://github.com/acme/lib/commit/6bd19572a14a5c20c830bd37e3035e483dfe4a83))

### Other

- Update the logo ([6a6668d](https://github.com/acme/lib/commit/6a6668dd1cb401d763433553c46bc9cceff089c8))
## [1.0.0] - 2026-01-15


### Added

- First release ([d7c0aaa](https://github.com/acme/lib/commit/d7c0aaabd920fa49ed076c14aaa2fca837c37e59))

Line by line, what the configuration did:

  • group = "<!-- 0 -->Added": groups are sorted alphabetically by name, so the HTML comment is a sort key; striptags removes it when printing. This is the trick the default config uses too.
  • skip = true removed the release commit, the dependency bump and internal types. Parsers are tried in order and the first match wins, so specific rules go before general ones.
  • Breaking changes are listed twice: once at the top from breaking_description (the BREAKING CHANGE: footer text), and once in their group. The rule ^[a-z]+(\(.+\))?!: (backslashes doubled inside the TOML string) sits above the skip rules, so refactor(api)!: lands in "Changed" instead of being skipped with the other refactors.
  • protect_breaking_commits = true is the safety net for breaking commits no rule anticipated (say, a chore: with a BREAKING CHANGE: footer): skip rules can't remove them. Such a commit then has no group from the parsers and is shown under a group named after its type (chore), which looks odd but is far better than losing it.
  • body = ".*security" was meant to move the path-traversal fix to Security, but the output shows it under Fixed: ^fix comes first and the first matching parser wins. Move the body rule above ^fix if you want security fixes grouped separately.
  • filter_unconventional = false kept Update the logo (as "Other") instead of dropping it silently.
  • tag_pattern ignored nightly-1; without it the nightly tag would have become a release section.
  • postprocessors replaced <REPO> in the final text, so the template stays independent of the hosting URL.

Forcing conventional commits

Instead of guessing what an unconventional commit means, a release pipeline can refuse it. require_conventional = true makes git-cliff fail, which also fails CI:

bash · try it yourself
mkdir lib && cd lib && git init -q
git-cliff --init >/dev/null 2>&1
sed -i 's/^require_conventional = false/require_conventional = true/' cliff.toml
git commit -q --allow-empty -m "feat: first"
git commit -q --allow-empty -m "Quick fix before the demo"
git-cliff >/dev/null 2>err.txt
echo "exit code: $?"
sed 's/\x1b\[[0-9;]*m//g' err.txt
exit code: 1
ERROR git_cliff_core::process > Commit 6a63fbf is not conventional:
    | Quick fix before the demo
Error: UnconventionalCommitsError(1)

Inspecting the template's input

When a template does something unexpected, look at the data it receives. --context prints it as JSON; jq picks the interesting fields:

bash · try it yourself
mkdir lib && cd lib && git init -q
git commit -q --allow-empty -m "feat(api)!: drop v1 endpoints" -m "BREAKING CHANGE: use /v2." -m "Refs: #42"
git-cliff --context --unreleased 2>/dev/null | jq -c '.[0].commits[] | {id: .id[0:7], group, scope, message, breaking, breaking_description, footers}'
{"id":"315c146","group":"<!-- 0 -->🚀 Features","scope":"api","message":"drop v1 endpoints","breaking":true,"breaking_description":"use /v2.","footers":[{"token":"BREAKING CHANGE","separator":":","value":"use /v2.","breaking":true},{"token":"Refs","separator":":","value":"#42","breaking":false}]}

Every field you can use in the template (commit.scope, commit.breaking_description, commit.footers, version, previous.version, timestamp…) appears in this JSON. A pipeline can even save it, edit it, and render it later with --from-context.

Test yourself

Why do group names in the config look like <!-- 0 -->Added?

  1. Markdown requires comments
  2. Groups sort alphabetically; the comment is a hidden sort key removed with striptags
  3. It hides the group
  4. It is a Tera keyword

A refactor!: commit is skipped by your parsers. What keeps it in the changelog?

  1. filter_unconventional = false
  2. protect_breaking_commits = true
  3. trim = true
  4. tag_pattern

Two parsers match a commit: ^fix (first) and a body rule .*security (second). Which group does it get?

  1. Both
  2. The first matching parser's group: Fixed
  3. The last one: Security
  4. None