How Well Designed Is Your Library's Public API?
A public API is everything a user can reach without importing a file you consider private: exported names, function signatures, option keys, error types, even the shape of returned objects. This self-assessment asks ten questions about that surface. Answer them with your package's entry point open in front of you, because the honest answer often differs from the remembered one.
Answer each question
Choose the option that best describes your package. Points are shown in brackets.
- Can you list every exported name from memory? Yes, and there are fewer than twenty [2] / Roughly [1] / No [0].
- Is the public surface declared in one place? A single index or an
exportsmap defines it [2] / Mostly, but deep imports work too [1] / Anything in the package can be imported [0]. - Do functions with more than three parameters take an options object? Always [2] / Some [1] / No, long positional lists [0].
- Do names describe what a thing does rather than how it is implemented? Yes [2] / Mixed [1] / Names mirror internal classes [0].
- Are errors distinguishable by code or type, not only by message text? Yes [2] / Some [1] / Users would have to parse strings [0].
- Do you have a test that fails when the exported surface changes? Yes, an API snapshot or type test [2] / Partly [1] / No [0].
- Are defaults safe, so that the shortest call does the least surprising thing? Yes [2] / Mostly [1] / The default is a footgun [0].
- Is there exactly one recommended way to do each common task? Yes [2] / Usually [1] / Several overlapping helpers [0].
- Are experimental features clearly marked or kept behind a separate entry point? Yes [2] / Marked in docs only [1] / Mixed in with stable ones [0].
- Could you remove an export today without a major version bump? No, because removal is always treated as breaking [2] / Unsure [1] / Yes, we do it in minors [0].
Scoring guide
| Total | Reading | Next step |
|---|---|---|
| 17 to 20 | Small, deliberate surface with guard rails | Document the stability policy so contributors keep it that way. |
| 10 to 16 | Workable but leaky in places | Questions 2 and 6 usually give the biggest return; close deep imports at the next major. |
| 0 to 9 | The surface is defined by accident | Inventory what users actually import before changing anything, so the cleanup does not surprise them. |
Why these questions
Questions 1, 2 and 8 are about size. Every export is a promise you have to keep under semantic versioning, so fewer exports means fewer promises. Questions 3, 4 and 7 are about the ergonomics of each promise: options objects let you add parameters later without breaking callers, and good names and defaults reduce support questions. Questions 5 and 9 are about letting users depend on the right things. Questions 6 and 10 test whether your process notices when the surface moves.
If question 10 was uncomfortable, the comparison of removing versus deprecating an API and the post on snapshotting the public API surface are good follow-ups. For a structured study route, the public API design course outline works through the same areas in more depth.
Your score is for your own use. It is a rough prompt for reflection rather than a measurement, and two careful maintainers could reasonably score the same library differently.