When designing/adjusting API surfaces, ensure (1) consumers can clearly understand what they’re setting and what defaults apply, (2) implementation-only details don’t leak into public types, and (3) variant-specific behavior is routed through dedicated abstractions/resolvers rather than embedded special-cases.
Guidelines:
Example (options + explicit defaults + no internal leakage):
export interface AgentSessionOptions {
source?: "interactive" | "rpc" | "extension"; // public, documented
}
export function createAgentSession(opts: AgentSessionOptions = {}) {
const source = opts.source ?? "interactive";
// ...
}
// Avoid embedding provider-specific branching in unrelated call paths:
function resolveBaseUrl(model: { provider: string; baseUrl: string }) {
if (model.provider === "cloudflare") return resolveCloudflareBaseUrl(model);
return model.baseUrl;
}
Apply this checklist whenever you modify exported types, request/response shapes, client interfaces, or any public function signatures that other teams/code depends on.
Enter the URL of a public GitHub repository