Generate interface

From Kevin-Liu-01/Agent-Machines · View interactive version

Generate interface is an AI agent skill from the GitHub repository Kevin-Liu-01/Agent-Machines. Define or refactor subsystem interfaces into small, explicit contracts with clear ownership, narrow scope, stable semantics, and README-first documentation. Use when designing a new API, collapsing ad hoc module boundaries into a few coherent interfaces, hardening internal contracts, or rewriting su

How to use this skill

Skill file

Generate Interface

Design interfaces the way durable systems do:

The target is an interface that feels old in the best way:

Think Unix and Linux, not app-framework churn.

This skill is for interface hardening, not generic architecture prose.

Core rule

Reduce a subsystem until a reader can answer these questions quickly:

  1. What are the primary interfaces?
  2. Who calls each one?
  3. Who owns each write path?
  4. What is authoritative?
  5. What is compatibility-only or debug-only?
  6. What is explicitly out of scope?

If the answer requires reading five modules and guessing, the interface is not done.

If the behavior of the subsystem is mostly encoded in ad hoc helper functions

and not in a small set of named interfaces, the design is not done.

Output shape

Prefer this hierarchy:

  1. subsystem README.md
  2. local module docstrings
  3. code

Do not create a new top-level taxonomy document unless the user explicitly wants one.

The default move is to consolidate interface definitions into the correct subsystem README.md files.

The user should be able to understand the subsystem by reading:

  1. README.md
  2. module docstrings
  3. code

and nothing else.

When to use

Use this skill when the user asks for things like:

Typical triggers:

Design principles

1. Interfaces describe authority

Every interface must say:

If two interfaces claim authority over the same operation or field, pick one. The other is either:

Ambiguous authority is not a documentation problem. It is an interface bug.

2. Contract first, transport second

Do not confuse:

with the interface itself.

Multiple transports can implement one interface. One transport can also expose multiple interfaces. Name the interface by responsibility, not by wire format.

Do not let implementation detail harden into architecture accidentally.

3. README-first documentation

A good subsystem README.md should let a new engineer answer:

Do not dump global architecture into every README. Give each README one job.

The README is the manual for the subsystem. It should define the contract,

boundaries, ownership, and compatibility story, not just list folders.

4. Linux-docs style

Aim for:

Avoid:

Prefer text that reads like a subsystem maintainer wrote it for the next

maintainer, not like a platform team wrote it for a launch review.

5. Narrow, durable interfaces

Good interface names survive implementation changes:

Bad interface names mirror folder layout or current wiring accidents:

Good interface names should survive a rewrite of transports, frameworks,

directories, and helper packages.

6. Compose interfaces, do not compose helper soup

The right way to combine complexity is:

The wrong way is:

If the system currently composes through ad hoc functions, collapse those

behaviors behind a smaller number of named interfaces.

7. The interface must do exactly what it says

Do not tolerate:

Every interface description should be executable as a mental model.

Workflow

Step 1: Inventory actual surfaces

Find the real surfaces:

Write them down as concrete resources and operations, not abstractions yet.

Also inventory:

Step 2: Group by coherent responsibility

Partition surfaces into a small number of interfaces.

A good interface groups operations that:

Do not force “three” if four is cleaner. Do not keep seven if three is cleaner.

The number of interfaces is not the goal. Coherent cuts are the goal.

Step 3: Classify each surface

For every endpoint / service / CRD path, classify it as one of:

Definitions:

If a surface does not fit one of those categories cleanly, the design is not

settled yet.

Step 4: Define ownership

For each resource or state subtree, define:

Prefer small tables.

Example:

| Area | Writer | Meaning |
| --- | --- | --- |
| `spec` | controlplane API | desired lifecycle and resource intent |
| `status.runtime` | host-agent | observed runtime facts from the compute host |
| `status.summary` | controlplane controller | public lifecycle projection |

Step 5: Put the contract into the right README

Default locations:

Also update local package docs and type comments so they agree with the README.

Step 6: Remove or demote strays

After the contract is written:

If code and docs disagree, code wins for current truth, then docs are corrected.

If the code reveals the interface is wrong, fix the interface, not just the prose.

Required sections for a subsystem interface README

Use this template.

# <Subsystem>

One sentence describing what this subsystem does.

## Scope

What this subsystem owns.
What it does not own.

## Interface boundary

- primary interface(s)
- neighboring systems
- authoritative contract
- compatibility/debug/operational split

## Ownership

Small tables for spec/status/runtime/projection ownership if applicable.

## Surface

Routes, services, resources, or protocol entry points.

## Semantics

What each major operation guarantees.
What it refuses.
What is synchronous, asynchronous, or eventually consistent.

## Compatibility and debug

What is transitional, what is debug-only, and what should eventually be deleted.

## References

Links to the neighboring subsystem README, proto, or type definitions.

Optional sections when useful:

Docstring pattern

Top-level module docs should say which interface the module implements.

Examples:

//! ConnectRPC service implementations for the host-agent.
//!
//! This module is the authoritative Host Runtime API: the controlplane-to-host
//! contract for lifecycle, health, migration, release, and artifact operations.
// Workspace is the durable declarative envelope around the Host Runtime API.
// Spec carries controlplane intent; status combines controller-authored
// projection with host-agent-authored runtime fact.

Cutover rules

When refactoring an existing system:

  1. Do not introduce a new abstraction layer unless it removes a real one.
  2. New features land only on the authoritative interface.
  3. Compatibility surfaces must be labeled as such.
  4. Debug surfaces must not be described as architecture.
  5. Prefer deletion over shims.
  6. Prefer moving behavior behind a real interface over adding one more helper.

Anti-patterns

Bad: one interface document plus stale subsystem READMEs

The subsystem README must stand on its own. Do not make readers hop through a taxonomy doc to understand the boundary.

Bad: folder-shaped interfaces

Do not define interfaces by current file organization.

Bad: transport-shaped interfaces

Do not define “the WebSocket API” or “the protobuf API” unless transport is actually the product boundary.

Bad: mixed authority

If one README says controlplane owns preview status and another says host-agent owns it, the interface is broken.

Bad: architecture spill

Do not turn every README into a full system architecture essay. Put enough context to understand the boundary, then stop.

Bad: interface inflation

Do not create five tiny interfaces where one coherent subsystem contract would do.

Bad: helper accretion

Do not preserve ad hoc helper layers just because they already exist. If they

encode part of the real contract, pull that behavior upward into the interface.

Completion checklist

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.