/oss-skills:api-designfrom oss-skills
Guides designing public API surfaces for libraries and tools: export discipline, function signatures, naming, error design, deprecation strategies, and stability guarantees. Use before 1.0 releases or when reviewing exports.
Ships in oss-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The difference between an internal API and a public one is that you can fix an internal one on a Tuesday. Every public symbol is a promise you will be asked to keep for years.
Everything exported is a maintenance obligation. Everything private is free.
export { a, b } from './x' — never export *, which
silently promotes every future internal symbol into your public API._private, internal/ directories, #[doc(hidden)],
@internal. Users will still reach in; the marking is what makes it their problem
when it breaks.# TypeScript: see the real public surface
npx api-extractor run --local
# Python: what does `from pkg import *` actually give?
python -c "import pkg; print([s for s in dir(pkg) if not s.startswith('_')])"
# Rust
cargo public-api
# Go
go list -f '{{.Name}}: {{.GoFiles}}' ./...
Wire a public-API snapshot into CI. A diff in that snapshot forces a conscious decision at review time instead of an accidental breaking change at release time.
Arguments. More than three positional parameters, or any boolean parameter, means
switch to an options object / keyword arguments. connect(host, 5432, true, false) is
unreadable at the call site and impossible to extend without breaking.
// Bad — unextendable, unreadable at call site
connect('db.local', 5432, true, false, 30)
// Good — self-documenting, additive
connect({ host: 'db.local', port: 5432, tls: true, timeoutMs: 30_000 })
Defaults. Every option gets a sensible default. The zero-config path must work for the common case; configuration is for the exceptions. If your quickstart needs six options set, the defaults are wrong.
Return types. Consistent shapes. A function that returns T | undefined | T[]
depending on input forces every caller to write a type guard. Pick one.
Naming. Boring and predictable beats clever:
camelCase in JS, snake_case in Python/Rust, MixedCaps in Go)parseConfig), noun for accessors (config)getUserById not queryUserTableremove here and delete there.id, url, db). cfgMgr costs every
reader a lookup, forever.Error behavior is part of your contract, and it is the part users hit under stress.
Config error at config.yml:12 — 'timeout' must be a number, got "30s". Use 30000.catch. No returning null for "something broke".throw new Error('msg', { cause }), raise ... from e,
fmt.Errorf("...: %w", err). Stripping the cause destroys debuggability.Users will need behavior you did not anticipate. Decide deliberately how they get it, because if you provide no seam they will monkey-patch your internals and you will break them accidentally.
| Mechanism | Good for | Cost |
|---|---|---|
| Callbacks / hooks | Single well-known extension point | Ordering and error semantics get subtle |
| Plugin interface | Many independent extensions | Versioning the plugin contract |
| Middleware chain | Composable request/response pipelines | Debuggability suffers |
| Events | Observation, logging, metrics | Not suitable for control flow |
| Subclassing | Rarely the right answer | Every internal method becomes public API |
Prefer composition over inheritance in public APIs. Inheritance makes every protected member a compatibility obligation.
AbortSignal, context.Context,
CancellationToken. Retrofitting cancellation is a breaking change.import is unusable in a serverless function and
untestable everywhere.A CLI is an API where the users are humans and shell scripts, simultaneously.
<tool> <noun> <verb> for multi-command tools (git remote add, docker image ls).
Consistent, discoverable, extensible.--verbose with -v.--help at every level, with examples. Most users never open the docs site.--json. Machine-readable output turns your tool into a building block.
Also: detect whether stdout is a TTY and disable colors/spinners when piped.0 success, 1 general failure, 2 usage error. Scripts
depend on these.--yes/--force to skip in automation.Config precedence, highest to lowest — deviate from this and users will be confused
forever: CLI flag → environment variable → project config file → user config file →
built-in default. Document it, and provide a way to show the resolved config
(tool config show --explain).
State the contract explicitly in the README or docs. Users cannot infer it.
## Stability
- Everything exported from the package root is public API under semver.
- Anything under `internal/` or prefixed `_` may change in any release.
- `experimental_*` exports may change in minor releases.
- Node 20+ and Python 3.10+ supported; dropping a runtime is a major release.
Decide and document whether these count as breaking: adding a required config field (yes), changing an error message (no) vs an error type (yes), tightening input validation (usually yes in practice), changing output ordering (yes if unsorted output was documented as stable), and raising the minimum runtime version (yes).
Never delete without a deprecation cycle. The full sequence:
@deprecated / #[deprecated] / warnings.warn(DeprecationWarning),
with the replacement named in the message.jscodeshift, libcst, comby)./** @deprecated Use `createClient()` instead. Removed in v4.0.0. */
export function makeClient(opts: Options): Client {
warnOnce('makeClient() is deprecated; use createClient(). Removed in v4.0.0.');
return createClient(opts);
}
Questions worth asking on every new public symbol:
The best answer to a feature request is often a documentation page. The second best is an extension point. A new public function is third.
export * from the package root.render(true) — nobody knows what that does.mode: 'fast' | 'safe' beats mode: string.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub the-open-agent/oss-skills --plugin oss-skills18 skills in this plugin
/ci-pipelinesDesign continuous integration for an open-source repository. Use when setting up GitHub Actions from scratch, when CI is slow or flaky, when adding a build matrix across OS and language versions, when configuring caching, or when handling PRs from forks that need secrets. Covers workflow structure, concurrency and cancellation, caching strategy, required checks and branch protection, self-hosted runner risks, and keeping CI cheap. Also use for "our CI takes 40 minutes" or "why is CI failing on forks"./code-reviewReview a pull request the way a good open-source maintainer does. Use when reviewing an incoming PR, when the user asks "review this PR" or "is this ready to merge", when triaging a stale PR queue, or when writing review feedback to an external contributor. Covers what to check and in what order, severity levels, phrasing feedback so people come back, handling large or unwanted PRs, first-time contributors, AI-generated submissions, and closing PRs kindly. Complements the built-in /code-review command by adding the maintainer and community dimension./contributor-experienceTurn users into contributors and make their first PR succeed. Use when a project gets stars but no contributions, when first-time PRs stall or get abandoned, when writing or improving CONTRIBUTING.md, when setting up a dev environment that works on the first try, or when the user asks "how do I get contributors" or "why does nobody contribute". Covers the contribution funnel, good first issues, local setup, mentorship, recognition, and onboarding a contributor into a maintainer./dependency-hygieneManage a project's dependencies so they stay small, current, and safe. Use when deciding whether to add a dependency, auditing an existing dependency tree, configuring Dependabot or Renovate, dealing with upgrade churn or a flood of bot PRs, resolving version conflicts, choosing between dependency ranges and pinning, or removing an unmaintained dependency. Also use for "our install is huge", "too many Dependabot PRs", or before publishing a library that others will depend on./docs-architectureStructure and write project documentation beyond the README. Use when docs have sprawled into an unnavigable pile, when users keep asking questions the docs already answer, when choosing a docs site generator (Docusaurus, MkDocs, VitePress, mdBook, Sphinx), or when planning a docs information architecture. Covers the Diataxis framework (tutorial/how-to/reference/explanation), versioning docs across releases, API reference generation, doc testing, and migration guides. Also use for "write docs for this project" or "our docs are bad"./governance-and-sustainabilityKeep a project and its maintainers alive over years. Use when deciding how decisions get made, writing GOVERNANCE.md or a code of conduct enforcement process, adding or removing maintainers, handling burnout or stepping away, setting up funding (GitHub Sponsors, Open Collective, a foundation), handling a fork or a hostile takeover attempt, or archiving a project responsibly. Also use for scope disputes, entitled users, and saying no well.