api-design
БесплатноБез исполняемых скриптовНе проверенDesign stable, compatible public APIs using extend-only design principles. Manage API compatibility, wire compatibility, versioning, naming conventions…
от wshaddix★ 94 звезды на GitHubОб этом скилле
Public API Design and Compatibility
When to Use This Skill
Use this skill when:
- Designing public APIs for NuGet packages or libraries
- Making changes to existing public APIs
- Planning wire format changes for distributed systems
- Implementing versioning strategies
- Reviewing pull requests for breaking changes
The Three Types of Compatibility
| Type | Definition | Scope |
|---|---|---|
| API/Source | Code compiles against newer version | Public method signatures, types |
| Binary | Compiled code runs against newer version | Assembly layout, method tokens |
| Wire | Serialized data readable by other versions | Network protocols, persistence formats |
Breaking any of these creates upgrade friction for users.
Extend-Only Design
The foundation of stable APIs: never remove or modify, only extend.
Three Pillars
- Previous functionality is immutable - Once released, behavior and signatures are locked
- New functionality through new constructs - Add overloads, new types, opt-in features
- Removal only after deprecation period - Years, not releases
Benefits
- Old code continues working in new versions
- New and old pathways coexist
- Upgrades are non-breaking by default
- Users upgrade on their schedule
Naming Conventions for API Surface
Type Naming
| Type Kind | Suffix Pattern | Example |
|---|---|---|
| Base class | Base suffix only for abstract base types |
ValidatorBase |
| Interface | I prefix |
IWidgetFactory |
| Exception | Exception suffix |
WidgetNotFoundException |
| Attribute | Attribute suffix |
RequiredPermissionAttribute |
| Event args | EventArgs suffix |
WidgetCreatedEventArgs |
| Options/config | Options suffix |
WidgetServiceOptions |
| Builder | Builder suffix |
WidgetBuilder |
Method Naming
| Pattern | Convention | Example |
|---|---|---|
| Synchronous | Verb or verb phrase | Calculate(), GetWidget() |
| Asynchronous | Async suffix |
CalculateAsync(), GetWidgetAsync() |
| Boolean query | Is/Has/Can prefix |
IsValid(), HasPermission() |
| Try pattern | Try prefix, out parameter |
TryGetWidget(int id, out Widget widget) |
| Factory | Create prefix |
CreateWidget(), CreateWidgetAsync() |
| Conversion | To/From prefix |
ToDto(), FromEntity() |
Avoid Abbreviations in Public API
// WRONG -- abbreviations in public surface
public IReadOnlyList<TxnResult> GetRecentTxns(int cnt);
// CORRECT -- spelled out for clarity
public IReadOnlyList<TransactionResult> GetRecentTransactions(int count);
Parameter Ordering
Consistent parameter ordering reduces cognitive load.
Standard Order
- Target/subject -- the primary entity being operated on
- Required parameters -- essential inputs without defaults
- Optional parameters -- inputs with sensible defaults
- Cancellation token -- always last (convention enforced by CA1068)
public Task<Widget> GetWidgetAsync(
int widgetId, // 1. Target
WidgetOptions options, // 2. Required
bool includeHistory = false, // 3. Optional
CancellationToken cancellationToken = default); // 4. Always last
Overload Progression
// Simple -- sensible defaults
public Task<Widget> GetWidgetAsync(int widgetId,
CancellationToken cancellationToken = default)
=> GetWidgetAsync(widgetId, WidgetOptions.Default, cancellationToken);
// Detailed -- full control
public Task<Widget> GetWidgetAsync(int widgetId,
WidgetOptions options,
CancellationToken cancellationToken = default);
Return Type Selection
When to Return What
| Scenario | Return Type | Rationale |
|---|---|---|
| Single entity, always exists | Widget |
Throw if not found |
| Single entity, may not exist | Widget? |
Nullable communicates optionality |
| Collection, possibly empty | IReadOnlyList<Widget> |
Immutable, indexable, communicates no mutation |
| Streaming results | IAsyncEnumerable<Widget> |
Avoids buffering entire result set |
| Operation result with detail | Result<Widget> / discriminated union |
Rich error info without exceptions |
| Void with async | Task |
Never async void except event handlers |
| Frequently synchronous completion | ValueTask<Widget> |
Avoids Task allocation on cache hits |
Prefer IReadOnlyList Over IEnumerable
// WRONG -- caller does not know if result is materialized or lazy
public IEnumerable<Widget> GetWidgets();
// CORRECT -- signals materialized, indexable collection
public IReadOnlyList<Widget> GetWidgets();
// CORRECT -- signals streaming/lazy evaluation explicitly
public IAsyncEnumerable<Widget> GetWidgetsStreamAsync(
CancellationToken cancellationToken = default);
The Try Pattern
public bool TryGetWidget
Установить api-design в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл api-design?
Design stable, compatible public APIs using extend-only design principles. Manage API compatibility, wire compatibility, versioning, naming conventions, parameter ordering, and return types for NuGet packages and distributed systems. Use when designing public APIs for NuGet packages or libraries, making changes to existing public APIs, planning wire format changes for distributed systems, or reviewing pull requests for breaking changes.
Как установить скилл api-design?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл api-design запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic