Semantic Versioning Explained
3.8.1 is a promise. Bump the first number when you break existing users, the second when you add something compatible, and the third when you fix something compatible. The promise only works if you define your public API clearly and treat any change that breaks it as a major release.
Semantic Versioning, specified at semver.org, is the convention almost every package registry assumes, even where it does not enforce it. Package managers build their default version ranges on top of it, which means the number you choose decides what millions of automated installs will or will not pick up. That makes it worth understanding precisely rather than approximately.
The three numbers
| Part | Bump it when | Example |
|---|---|---|
| MAJOR | You make an incompatible change to the public API | Removing a function, renaming an option, changing a return type |
| MINOR | You add functionality in a backwards-compatible way | A new optional parameter, a new exported helper |
| PATCH | You make backwards-compatible bug fixes | Correcting a wrong result without changing the signature |
When you bump one part, the parts to its right reset to zero: 3.8.1 becomes 3.9.0 or 4.0.0, never 4.8.1. Pre-release labels such as 4.0.0-rc.1 and build metadata such as +build.7 are optional extras described in the same specification.
Your public API is whatever you say it is
The specification requires you to declare a public API, and that declaration is where most of the real decisions live. For a JavaScript package it typically includes exported functions and classes, the entry points in your exports map, documented options and, for many users, the TypeScript types. For a Python package it is usually the names you document and anything not prefixed with an underscore. Write it down in the README: "anything not listed here is internal and may change in any release". Without that sentence, users will treat every reachable symbol as public.
How package managers read the number
npm's default caret range, ^3.8.1, accepts any later 3.x version but not 4.0.0. Cargo treats a bare version requirement the same way. That is why an accidental breaking change in a minor release is so disruptive: it is pulled in automatically by every project with a default range, with no human looking at it. Note that for versions below 1.0.0 the ranges are stricter, so ^0.3.2 does not accept 0.4.0.
Gray areas worth deciding in advance
- Dropping a runtime version (an old Node.js or Python release). Many projects treat this as major because it breaks installs for those users.
- Fixing a bug people rely on. If the "wrong" behaviour was documented or widely used, the fix is effectively breaking.
- Tightening types only. A stricter TypeScript signature can fail someone's build without changing runtime behaviour.
- Raising a dependency's minimum version, especially a peer dependency.
Pick a rule for each and record it next to your public API definition. The point is consistency, so users can predict what a given bump means for them.
Habits that keep the promise
Pair every release with a changelog entry, run your previous version's tests against the new code when you can, and consider tools that diff your exported API between releases. Above all, be willing to ship majors. A project that is afraid of 2.0.0 ends up hiding breaking changes in minors, and that is the one thing semantic versioning exists to prevent.