interface-specification
Specify an internal interface — signatures, pre/postconditions, invariants, error taxonomy, idempotency, complexity bounds, ownership, stability, examples. Module-level / library-level. Not a network contract.
What this skill does
# Interface Specification
You specify a code-level interface (module API, library surface, port) so that implementers + callers agree on meaning, not just shape.
## Core rules
- **Types alone are not a contract** — add pre/postconditions
- **Errors are first-class** — every documented failure mode
- **Stability stated** — `stable` / `experimental` / `deprecated`
- **Examples mandatory** — at least one happy path + one edge
- **Ownership + lifetime** — who can call, when, how long references live
- **No fabricated behavior** — work from supplied semantics
- **Scope** — this is for code-level interfaces, not network APIs (see `api-contract-specification`)
## Input handling
| Dimension | Required | Default |
|---|---|---|
| **Interface name + owner component** | Yes | — |
| **Language + paradigm** | Yes | — |
| **Operations** | Yes | — |
| **Preferred stability target** | No | `stable` |
## Phase 1 — Setup
```
**Interface**: [name]
**Owning component**: [...]
**Language**: [TypeScript / Go / Python / ...]
**Stability target**: [stable / experimental / deprecated]
**Consumers**: [internal team / library users / plugin authors]
**Concurrency model**: [single-threaded / thread-safe / fiber]
**Async model**: [sync / Promise / async iterator / ...]
```
Ask render mode per `diagram-rendering` mixin and output path (default: `/documentation/[case]/interface-specification/[name]/`).
## Phase 2 — Interface surface
For each operation:
### Signature
```typescript
interface OrderRepository {
/**
* Persist or update an order aggregate.
*
* Preconditions:
* - `order.id` is non-empty
* - `order.version` equals the version this caller last loaded
*
* Postconditions:
* - On success, a subsequent `findById(order.id)` returns the saved order
* with `version + 1`
* - On conflict, throws `OptimisticLockError`; no state change
*
* Errors:
* - `OptimisticLockError` — version mismatch
* - `PersistenceError` — transient; retry may succeed
*
* Complexity: O(1) calls to the store; uses a single transaction.
* Concurrency: safe across goroutines / threads.
* Idempotent: yes, by (id, version).
*/
save(order: Order): Promise<Order>;
/**
* Load an order by id.
*
* Preconditions: `id` non-empty.
* Postconditions: returns the aggregate or null if not found.
* Errors: `PersistenceError` on transient store issues.
* Complexity: O(1) amortized.
*/
findById(id: OrderId): Promise<Order | null>;
}
```
### Parameter + return semantics
- Parameter ownership: passed by reference vs ownership transferred
- Return ownership: caller owns / may not mutate / must dispose
- Nullability + absence: null vs not-found vs error
### Invariants
Invariants that hold across operations:
- `save` never returns an `Order` with a smaller `version` than the input
- `findById(x)` is a pure read — no state mutation anywhere
## Phase 3 — Error taxonomy
| Error | Category | When | Recovery |
|---|---|---|---|
| `OptimisticLockError` | Conflict | Concurrent modify | Reload + retry at caller |
| `PersistenceError` | Transient | Store down / timeout | Retry with backoff |
| `ValidationError` | Programmer | Precondition violated | Fix the call |
| `NotFoundError` | Expected | Entity absent | Handle as business case |
Errors are part of the contract, not implementation detail.
Hand off broader strategy to `system-error-handling-strategy`.
## Phase 4 — Concurrency + threading
- Thread safety per operation (safe / unsafe / serialize externally)
- Re-entrancy (can it call itself?)
- Cancellation model (context / signal / Promise cancel)
- Blocking vs non-blocking
## Phase 5 — Performance + complexity
- Time complexity per operation
- Space complexity
- Bounded vs unbounded memory
- I/O amplification
- Latency class (CPU-bound / I/O-bound / network)
## Phase 6 — Lifetime + ownership
- Instance lifetime (per-request / per-connection / singleton)
- Who creates, who disposes
- Resource cleanup — explicit `close()` or RAII / `using`
- Cancellation + partial-failure cleanup
## Phase 7 — Stability guarantees
| Label | Meaning |
|---|---|
| **Stable** | Signature + semantics fixed; breaking change needs major version |
| **Experimental** | May change without major version; consumers accept risk |
| **Deprecated** | Scheduled for removal; alternative referenced |
| **Internal** | Not for outside callers; no guarantees |
Version bump rules tied to the interface's owning component. Hand off to `api-versioning-strategy` (for external network counterparts) or internal versioning policy.
## Phase 8 — Examples
### Happy path
```typescript
const order = await repo.findById(id);
if (!order) throw new NotFoundError(id);
order.markPaid();
const saved = await repo.save(order);
assert(saved.version === order.version + 1);
```
### Concurrent modify (conflict)
```typescript
try {
await repo.save(staleOrder);
} catch (e) {
if (e instanceof OptimisticLockError) {
const fresh = await repo.findById(staleOrder.id);
// merge, retry
} else throw e;
}
```
### Not found
```typescript
const order = await repo.findById('unknown');
assert(order === null); // not an error
```
At least one happy path + one edge + one failure example per non-trivial operation.
## Phase 9 — Testability
- Can this interface be mocked / stubbed? What's the test double shape?
- Behavior tests vs. state tests preferred?
- Fixtures needed
- Any nondeterminism requiring clocks / randomness ports?
## Phase 10 — Alternative designs considered
Short list, with one-line reject rationale:
- Returning `Result<T, E>` union instead of throwing — rejected: language idiom is exceptions; throwing keeps callers cleaner
- Passing `tx` handle explicitly — rejected: infra concern, hidden behind repo
## Phase 11 — Diagrams
### Collaboration
```mermaid
sequenceDiagram
Handler->>Repo: findById(id)
Repo-->>Handler: Order
Handler->>Handler: mutate aggregate
Handler->>Repo: save(order)
Repo-->>Handler: savedOrder (version+1)
```
### State / lifetime
```mermaid
stateDiagram-v2
[*] --> Instantiated
Instantiated --> Active : ready
Active --> Closed : close()
Closed --> [*]
```
## Phase 12 — Diagram rendering
Per `diagram-rendering` mixin.
## Phase 13 — Report assembly and approval
```markdown
# Interface Specification: [Name]
**Date**: [date]
**Owning component**: [...]
**Language**: [...]
**Stability**: [stable / experimental / deprecated]
## Scope
## Interface Surface
[Per operation: signature, pre/post, errors, complexity, concurrency]
## Invariants
## Error Taxonomy
## Concurrency + Threading
## Performance + Complexity
## Lifetime + Ownership
## Stability Guarantees
## Examples
## Testability
## Alternative Designs
## Diagrams
## Hand-offs
## Assumptions & Limitations
```
Present for user approval. Save only after confirmation.
## Assessment + planning rules
- Signatures + semantics, not types alone
- Errors documented as contract
- Stability label stated
- Examples: happy + edge + failure
- Concurrency + lifetime explicit
- No fabricated semantics
## Failure behavior
| Situation | Behavior |
|---|---|
| No operations listed | Interview mode (§7) |
| Types only (no semantics) | Prompt for pre/post + errors |
| Network API requested | Redirect to `api-contract-specification` |
| Too many operations | Recommend splitting interface (ISP) |
| Stability unstated | Default to `experimental` with note |
| mmdc failure | See `diagram-rendering` mixin |
| Implementation request | "Specification only; implementation is engineering." |
## Self-check
```
[] Signatures + pre/post per operation
[] Invariants
[] Error taxonomy in contract
[] Concurrency + lifetime
[] Complexity bounds
[] Stability guarantee
[] Examples for happy / edge / failure
[] Testability notes
[] Alternatives considered
[] Diagrams valid
[] No fabricated semantics
[] Report follows output contract
```
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.