Ten Habits That Keep an Internal Shared Library Healthy
Internal libraries rarely die from one bad decision. They decay slowly: a helper added for one team, a version nobody bumped, a function everyone is scared to touch. These are the habits I would put in place on day one if I inherited a shared library inside a company, written as opinions rather than rules.
Why internal packages deserve public-package discipline
There is a common belief that an internal package can skip the ceremony that open source projects follow because "we can just talk to the consumers". In practice, the consumers are spread across teams with their own deadlines, and the conversation never happens until something breaks in production. The cheapest fix is to treat colleagues exactly like strangers on a public registry: they read your version number, your changelog and your README, and that is all they have.
The ten habits
- Name an owner, not a channel. A named person or rotation decides what gets merged. "Everyone owns it" means nobody reviews the API.
- Version it like it is public. Use semantic versioning honestly. A breaking change in a shared library is still a major release, even if only three repositories import it.
- Publish to a registry, not a Git branch. Consuming a library from a branch or a commit hash makes upgrades invisible. A private registry gives you real version numbers and a history of what shipped.
- Keep a changelog people actually read. One short entry per release, grouped by added, changed, deprecated and removed. The Keep a Changelog format is a fine default.
- Write a scope statement. Two sentences in the README on what belongs in the library and what does not. It turns "can you add my helper?" into a quick yes or no.
- Deprecate before you delete. Mark old functions, log a warning in development builds, and give consumers at least one minor release of overlap.
- Test the published artifact. Unit tests on the source tree are not enough; install the built package in a throwaway project in CI.
- Pin the toolchain. Record the supported runtime versions so a consumer on an older runtime gets a clear error instead of a confusing stack trace.
- Audit consumers once a quarter. Search your organisation's repositories for which versions are in use. Old majors that nobody uses can be retired; old majors that everyone uses tell you an upgrade is too painful.
- Say no to features without an owner. If a contributor will not maintain the code they add, it probably belongs in their own repository.
A small example of a scope statement
Here is an illustrative README fragment for a hypothetical internal package called @acme-internal/http-utils:
## Scope
This package contains retry, timeout and auth-header helpers for
outbound HTTP calls. It does not contain API clients for specific
services, logging setup, or anything that depends on a framework.
Owner: platform rotation (see CODEOWNERS).
That block costs nothing to write, yet it settles a surprising number of review debates before they start.
Where teams usually slip
The habit that erodes first is almost always versioning. Someone ships a "small" behaviour change as a patch because the API signature did not change, and a downstream service starts timing out. Signatures are only part of the contract; defaults, error types and timing are part of it too. If you are unsure whether something counts as breaking, the semver.org specification is short enough to reread, and the glossary on this site covers the terms.
The second habit to slip is the quarterly audit, mostly because it is boring. Automate the search if you can, and put the result in the changelog or the README so the next owner inherits the picture rather than a guess.