Sub topic 7
Flagging breaking changes with ! and BREAKING CHANGE
This chapter assumes you can write a basic conventional commit (type, optional scope, description, body, footers). It also assumes you know that Semantic Versioning numbers have the form MAJOR.MINOR.PATCH. The chapter covers the two ways the Conventional Commits 1.0.0 specification marks a breaking change, how they differ, and where the marking goes wrong in practice.
What counts as a breaking change
A breaking change is a change that can make existing users' code or integrations stop working after they upgrade. Examples:
- Removing or renaming a public function, endpoint, command-line flag, or configuration key.
- Changing the type or meaning of a return value.
- Raising the minimum supported runtime version.
- Changing a default in a way that alters existing behavior.
The convention does not decide for you what counts as breaking. You decide that from your project's public interface. The convention gives you a standard way to record the decision so that people and tools can find it later.
Two rules from the specification shape everything else in this chapter:
- A breaking change can be part of a commit of any type. A
fix, arefactor, or aperfcommit can be breaking, not only afeat. - A breaking change correlates with a MAJOR version bump in Semantic Versioning, whatever the commit's type.
The two markers
You can flag a breaking change in the prefix, in a footer, or in both.
The ! marker in the prefix
Put ! immediately before the colon. If the commit has a scope, the ! goes after the closing parenthesis.
feat(api)!: remove the deprecated /v1/users endpointrefactor!: drop support for Node 16The ! is the quick form. When you use it, the specification allows you to leave out the BREAKING CHANGE: footer. In that case the commit description is used to describe the breaking change. This means the description must say what broke, not only what you did.
The BREAKING CHANGE footer
The footer form is a line starting with the exact token BREAKING CHANGE, then a colon, a space, and a description. It goes in the footer section, after a blank line that follows the body or the description.
feat(api): change the users endpoint to return paginated results
The /v2/users endpoint now returns an object with items and next_cursor
instead of a bare array.
BREAKING CHANGE: clients that read the response as an array must read
the items field instead.Three details are easy to get wrong:
- The token must be uppercase. Most parts of a conventional commit are not case sensitive, but
BREAKING CHANGEis the exception. BREAKING-CHANGEwith a hyphen is also valid and means the same thing. The specification says footer tokens use-in place of spaces, so it makes an exception for the two-wordBREAKING CHANGE.- The footer description can run over several lines. Use it to tell upgraders what to do, not only what happened.
Using both
You can combine the two forms, and the specification's own example does.
feat(api)!: remove the deprecated /v1/users endpoint
BREAKING CHANGE: clients must call /v2/users instead.Here the ! makes the break visible in a one-line git log --oneline. The footer carries the migration instructions, which are too long for the first line.
Choosing between them
| Situation | Suggested marker |
|---|---|
| The description alone explains the break, for example `feat!: remove the --legacy flag` | `!` only |
| Users need migration steps or a reason | `BREAKING CHANGE:` footer, plus `!` for visibility |
| The commit is a bug fix that must also change behavior | `fix!:` plus a footer explaining the new behavior |
| You want the break visible in `git log --oneline` | `!` |
| Your tooling only reads footers | Footer (check your tool's documentation) |
If you are unsure, use both. The cost is one extra line, and the footer text usually ends up in the changelog.
How the decision flows into a release
The marker overrides the type when the next version is computed. A fix! produces a MAJOR bump, not a PATCH bump.
The tool takes the highest bump any single commit demands. Ten feat commits and one fix! still produce one MAJOR bump.
There is one wrinkle. Versions below 1.0.0 follow looser rules under Semantic Versioning, because anything may change at any time. Some release tools therefore bump MINOR instead of MAJOR for breaking changes while the version is 0.x. This is a tool setting, not part of the Conventional Commits specification. Check what your tool does before you rely on either behavior.
Finding breaking changes in history
Because the markers are plain text, ordinary Git can find them. This is the payoff of the format.
# commits flagged with ! in the prefix
git log --oneline -E --grep='^[a-z]+(\([^)]*\))?!:'
# commits with a BREAKING CHANGE or BREAKING-CHANGE footer
git log --oneline -E --grep='^BREAKING[ -]CHANGE:'The first command matches a type, an optional scope in parentheses, and then !:. The second matches the footer token at the start of a line. To list breaking changes since the last tag, add a range such as v1.4.0..HEAD before the options.
Enforcing the markers
The commit-msg hook from the enforcement chapter already accepts !. Its pattern includes !? before the colon, so feat(api)!: ... passes. That hook checks only the first line, so it cannot tell whether a footer is well formed. A misspelled BREAKING CHANGES: or a lowercase breaking change: passes the hook without being recognized as a break.
A stricter check is possible without commitlint. This hook script looks for footer-like lines that nearly match the token and rejects them.
#!/bin/sh
# .git/hooks/commit-msg (must be executable)
# Reject near-miss breaking change footers.
msg_file="$1"
if grep -Ei '^breaking[ -]?changes?:' "$msg_file" \
| grep -Evq '^BREAKING[ -]CHANGE:'; then
echo "Footer token must be exactly 'BREAKING CHANGE:' or 'BREAKING-CHANGE:'." >&2
exit 1
fiThe first grep finds lines that look like an attempt. The second removes the correct spellings. If anything is left over, the commit is rejected. Note that BREAKING CHANGES: (with an S) is also caught, because ^BREAKING[ -]CHANGE: requires the colon right after CHANGE.
commitlint with @commitlint/config-conventional parses footers properly and recognizes the correct tokens. It also enforces a blank line before the footer, which matters for the next section.
Common mistakes
Footer without a blank line
A footer must be separated from the body by a blank line. Without it, a parser may treat the footer as more body text, and the break goes unnoticed.
feat(config): rename timeout to timeout_ms
BREAKING CHANGE: configs that set timeout must use timeout_msIn this message the footer line directly follows the description. Insert an empty line between them.
Marking the wrong commit
Mark the commit that introduces the break. If you remove an endpoint in one commit and write the explanation in a later docs commit, the release tool sees only the earlier commit with no marker. Put the marker on the commit that changes the behavior.
Marking too much
If every large change gets a !, the MAJOR version loses its meaning. Keep the marker for changes to the public interface. An internal rename that no user can observe is a refactor, not a break.
Lost markers in squash merges
When a pull request is squash-merged, many hosting platforms build the final commit message from the pull request title and the commit bodies. If the title lacks the ! and the footer is dropped, the break disappears from the history on the main branch, even though your original commits had it. Check the final squash message before you confirm the merge. The PR titles chapter covers this workflow in more detail.
Using the marker for deprecation
Deprecating something that still works is not a break. Mark the deprecation with a normal feat or docs commit, and flag the breaking change in the commit that finally removes it.
A worked example
You maintain a library with a function parse(text). You change it to take an options object and to throw on invalid input instead of returning null. Existing callers break in two ways.
fix(parser)!: throw ParseError on invalid input
parse() used to return null when the input was malformed, which hid
errors. It now throws ParseError. The second argument is now an options
object instead of a boolean strict flag.
BREAKING CHANGE: callers that checked for a null result must catch
ParseError. Replace parse(text, true) with parse(text, { strict: true }).
Refs: #517This commit uses the fix type because the intent is to correct hidden errors. The ! makes the break visible in git log --oneline. The footer gives callers both migration steps. A release tool reads the commit and calls for a MAJOR bump. The changelog gets a breaking-changes entry with the footer text.
Exercise
A teammate writes this commit and the release tool still produces only a PATCH release. Why, and how would you fix the message? fix(cli): rename --out to --output Breaking change: scripts that pass --out will fail.
Show answer
The message has two problems. First, there is no blank line between the description and the footer, so a parser may not see a footer at all. Second, the token is written as "Breaking change:", but BREAKING CHANGE must be uppercase, so the tool does not recognize it. Neither the ! marker nor a valid footer is present, so the tool treats this as an ordinary fix and bumps PATCH. A corrected message is: "fix(cli)!: rename --out to --output", then a blank line, then "BREAKING CHANGE: scripts that pass --out must pass --output instead."
Exercise
A release contains eight feat commits, three fix commits, and one refactor commit written as "refactor(core)!: remove the global registry". Which version bump does a conventional-commits-aware tool choose from 2.3.1, and why?
Show answer
It chooses a MAJOR bump, to 3.0.0. The ! marks the refactor commit as breaking, and a breaking change correlates with MAJOR whatever its type. The tool takes the highest bump demanded by any single commit, so the feat commits (MINOR) and fix commits (PATCH) do not change the result.