Choosing a Deprecation Policy for Your Library: Options and a Recommendation

Sooner or later every package has to remove something. Without a written policy, each removal becomes an argument, and users cannot plan. This paper sets out the problem, compares four policy shapes and recommends a default that suits most small and medium libraries.

1. The problem

Users need two things that pull against each other: stability, so their code keeps working, and progress, so the library can fix design mistakes. A deprecation policy is a promise about how much warning users get before a public API disappears. Without one, authors either never remove anything and the API grows forever, or remove things abruptly and lose users' trust. Both outcomes are common.

2. Background

Semantic Versioning 2.0.0 already contains the core rule: when you deprecate functionality, you should release a minor version that marks it as deprecated, and remove it only in a later major version. The spec deliberately says nothing about how long the gap should be. Ecosystems add mechanisms on top: npm deprecate attaches a message to published versions, Python's warnings module provides DeprecationWarning, Go uses a // Deprecated: doc comment that tooling recognises, and Rust has the #[deprecated] attribute. The mechanics are solved. The policy is what is missing.

3. Options

OptionRuleStrengthWeakness
A. Next majorAnything deprecated in 3.x may be removed in 4.0Simple; matches the specIf majors are frequent, warning time can be very short
B. Minimum timeDeprecations stay for at least a stated period before removalPredictable for users who plan upgrades on a calendarTies releases to dates; awkward for slow-moving projects
C. Minimum releasesDeprecations stay for at least N minor releasesIndependent of the calendarMeaningless if releases are rare or bunched together
D. CombinedRemoval only in a major, and only after both a minimum period and at least one minor release carrying the warningProtects users in fast and slow projects alikeSlightly more bookkeeping

4. Recommendation

Adopt option D, with numbers you can actually honour. A reasonable illustrative starting point for a volunteer-run library is: removal only in a major version, after the warning has shipped in at least one minor release and has been public for a period you choose and state, such as six months. Then write it down in a DEPRECATION.md or a README section:

## Deprecation policy
- Deprecated APIs emit a runtime warning and are marked in the docs.
- They are removed only in a major release.
- Removal happens no sooner than one minor release and six months
  after the deprecation was first published.
- Each deprecation notice names the replacement.

Three supporting practices make any policy work: always name the replacement in the warning text; record each deprecation and each removal in the changelog under its own heading; and provide a codemod or migration snippet for anything widely used.

5. When to break the policy

Security fixes are the main exception. If an API cannot be made safe, removing or changing it faster is justified, but say so explicitly in the release notes and the advisory. For the implementation details, see our training unit on deprecation warnings and the essay on package deprecation policy.