Api and interface design

From drvoss/everything-copilot-cli · View interactive version

Api and interface design is an AI agent skill from the GitHub repository drvoss/everything-copilot-cli. Use when defining a public API, CLI, webhook, or SDK surface — lock the contract first so compatibility, validation, and versioning stay intentional instead of accidental

How to use this skill

Skill file

API and Interface Design

Define the contract before the implementation. This skill is for public or cross-team interfaces

where downstream consumers can depend on every observable behavior, including the ones you did not

mean to promise.

When to Use

When NOT to Use

| Instead of api-and-interface-design | Use |

|-------------------------------------|-----|

| Internal implementation design inside one module | spec-driven-development |

| Writing user-facing docs for a finished API | api-documentation |

| Retiring or replacing an old interface | deprecation-and-migration |

| Narrow bug fixes with no contract change | do the fix directly |

Workflow

1. Identify the real contract boundary

Write down:

If the consumer or stability target is unclear, you are not ready to implement.

2. Draft the contract before code

Create a contract document or spec section before touching implementation:

## Interface Contract: createWidget

**Interface type**: REST API / CLI / SDK / webhook
**Consumers**: Internal services + external customers
**Stability**: stable / beta / experimental

### Inputs
- Method / command / function name:
- Required parameters:
- Optional parameters:
- Validation rules:

### Outputs
- Success shape:
- Error shape:
- Ordering / pagination guarantees:

### Invariants
- [Behavior that must remain true]

### Non-Goals
- [What this interface deliberately does not promise]

3. Run a Hyrum's Law review

For every observable behavior, ask:

Common accidental contracts:

4. Design validation at the trust boundary

Validation should happen where untrusted input enters the system:

Do not scatter the same runtime validation through every internal layer. Define:

5. Choose the compatibility strategy

| Change type | Default strategy |

|-------------|------------------|

| Additive field | Make optional first; define default behavior |

| Renamed field | Add new field, deprecate old one, keep overlap window |

| Semantic change | Version the interface or add a new endpoint/flag |

| Removed capability | Publish a migration path before removal |

If you cannot explain the migration path in two or three sentences, the change is not ready.

6. Hand off to implementation planning

Once the contract is stable:

  1. Feed it into spec-driven-development
  2. Identify tests that prove the contract
  3. Implement the smallest slice that honors the contract exactly

Audit mode — checking a surface that already shipped

When the interface exists and the question is "is this contract actually good?", audit it from evidence

instead of redesigning it. Stay read-only unless asked to fix.

  1. Write a one-line scope receipt before reading code, so the audit cannot quietly widen:

Scope: audit; surfaces: <commands/exports/config>; excludes: <UI, docs prose, private internals>

  1. Run safe probes against a local build:

with stdout redirected to a new temporary file outside the worktree to see non-TTY output;

read it, then delete it. Use --dry-run where it exists; never trigger a real mutation to test

the experience.

lifecycle scripts — read them first, or probe a disposable checkout.

  1. Check the developer-facing contract: consistent naming and argument order, one predictable return

shape, errors that say what failed and how to fix it, and exit codes a script or agent can branch on.

  1. Stop when each behavior is proven, disproven, private, or out of scope. Report findings tied to the

probe that showed them.

Adapted from the dx-audit skill in mblode/agent-skills (MIT).

Example

## Interface Contract: `copilot skill install`

**Interface type**: CLI
**Consumers**: Developers using Copilot CLI
**Stability**: beta

### Inputs
- Command: `copilot skill install <url-or-path>`
- Optional flags: `--dry-run`, `--force`
- Validation rules:
  - URL must be HTTPS or GitHub shorthand
  - Local path must contain a valid skill directory

### Outputs
- Exit code `0`: install succeeded
- Exit code `1`: validation failure
- Exit code `2`: network or fetch failure

### Invariants
- Installed skill is validated before being written
- `--dry-run` never mutates the filesystem

### Non-Goals
- Private repository authentication
- Version pinning

Common Mistakes

| Mistake | Fix |

|---------|-----|

| Letting implementation details leak into the contract | Document only consumer-visible behavior |

| Treating every internal helper as a public interface | Limit this skill to external or cross-team boundaries |

| Adding validation everywhere "just in case" | Validate once at the boundary, then trust the normalized input |

| Delaying breaking-change planning until after coding | Choose the migration strategy before implementation |

Verification

See Also

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.