agentleFS
Microsoft AzureKnown publisherAzure/azure-container-networking/.github/skills/acn-go-http-api-contracts/SKILL.md

acn-go-http-api-contracts

Skill437 starsChanged 49 days agoMITView on GitHub

HTTP and REST contract design for Azure/azure-container-networking. Use when designing or reviewing HTTP handlers, routes, request/response types, query parameters, and action semantics. Trigger on GET handlers with bodies, PUT vs PATCH questions, action-heavy URL designs, redundant wrapper responses, or APIs that split a single resource operation across mismatched request shapes.

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 6 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Prefer HTTP status over extra app error-code layers: when the HTTP contract already expresses the state.

    line 45
  2. Very specific:

    If POSTing to /resource/{id} does not create or replace the whole resource, the API is lying about its contract.

    line 87
  3. Distinctive:

    If the body is really about a mapping between resources, model the mapping explicitly.

    line 108
  4. Distinctive:

    Use each part of the request for what it is good at:

    line 112
  5. Distinctive:

    Do not require a body when the input is just selectors that fit naturally in query params.

    line 129
  6. Distinctive:

    When HTTP already expresses the error class, use it.

    line 133
  7. Distinctive:

    Avoid broad pass-through wrappers or responses that exist only to restate HTTP status in another format.

    line 172

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Persona: You are a Go API reviewer who treats HTTP shape as contract design, not routing trivia. A resource path, method, and payload must describe the same operation. If the URL says one thing and the body says another, the API is wrong.

Modes:

  • Write mode — designing new HTTP APIs or reshaping handlers. Prefer resource-shaped URLs, typed request/response bodies, and method semantics that match the operation.
  • Review mode — reviewing handlers, route wiring, and request/response contracts. Flag GET bodies, action-shaped URLs, redundant wrapper responses, and operations whose semantics belong in a different method or path.
  • Audit mode — auditing an HTTP surface. Split work across: (1) URL/resource shape, (2) method/idempotency, (3) request/response contract clarity.

Repo-specific skill. This captures repeated HTTP/API guidance from rbtr's ACN review history.

Go HTTP/API Contracts

HTTP method, URL, query parameters, and body must all describe the same resource operation. Do not force callers to reverse-engineer your intent from mismatched pieces.

Use when

  • adding or reviewing HTTP handlers or routes
  • choosing between GET / POST / PUT / PATCH
  • designing request/response structs
  • deciding whether something belongs in path, query, or body
  • simplifying REST/controller handler surfaces

Do not use when

  • the change is internal-only and not exposed through HTTP
  • the issue is only transport/client plumbing, not API contract shape

Core Principles

  1. GET has no body — use query parameters for filtering and selection.
  2. Choose PUT vs PATCH by semantics — PUT replaces a resource representation; PATCH mutates part of it; POST performs creation or action semantics.
  3. Use resource-shaped URLs — the path should identify the resource being operated on, not smuggle domain actions into arbitrary endpoints.
  4. Prefer HTTP status over extra app error-code layers when the HTTP contract already expresses the state.
  5. One typed request/response surface per operation — avoid redundant wrapper responses and mismatched body/path semantics.

No GET Bodies

// ❌ BAD — GET with body
GET /ibdevices
{
  "state": "assigned"
}

// ✅ GOOD — GET with query filters
GET /ibdevices?state=assigned
GET /ibdevices?state=unassigned
GET /ibdevices?by-pod=namespace%2Fname

GET retrieves a representation. If the caller is selecting or filtering, use query parameters.

PUT vs PATCH vs POST

Choose the method based on what the operation means:

MethodUse forExample
GETread a resource or collectionGET /ibdevices?state=assigned
PUTreplace a full resource representation, idempotentlyPUT /nodes/{id}/status
PATCHpartial mutation of an existing resourcePATCH /pods/{id}
POSTcreate a resource or invoke an action endpointPOST /ibdevices:assign?...
// ❌ BAD — POST on a resource path that does not mean create/replace
POST /ibdevices/{id}
{
  "pod": "ns/name"
}

// ✅ GOOD — action is explicit when it is not whole-resource replacement
POST /ibdevices:assign?ibdevs=mac1,mac2&pod=ns%2Fname

If POSTing to /resource/{id} does not create or replace the whole resource, the API is lying about its contract.

Resource-Shaped URLs

The path should identify the thing being operated on.

// ❌ BAD — path and payload describe different resources
POST /ibdevices/{mac}
{
  "pod": "ns/name",
  "devices": ["mac1", "mac2"]
}

// ✅ GOOD — collection plus filter/action surfaces
GET  /ibdevices/{mac}
GET  /ibdevices?state=assigned
GET  /ibdevices?by-pod=ns%2Fname
POST /ibdevices:assign?ibdevs=mac1,mac2&pod=ns%2Fname

If the body is really about a mapping between resources, model the mapping explicitly. Do not pretend the request is “about” one thing while the payload mutates another.

Path vs Query vs Body

Use each part of the request for what it is good at:

  • Path — identifies the resource
  • Query — selects, filters, or scopes the operation
  • Body — supplies representation or mutation payload when the method semantics require one
// ✅ GOOD — query carries the selection set
POST /ibdevices:assign?ibdevs=mac1,mac2&pod=ns%2Fname

// ✅ GOOD — body carries the representation being replaced
PUT /nodenetworkconfigs/{name}
{
  "spec": { ... }
}

Do not require a body when the input is just selectors that fit naturally in query params.

Prefer HTTP Status Over Redundant App Error Layers

When HTTP already expresses the error class, use it.

// ❌ BAD — HTTP 200 plus app-layer errorCode for a missing resource
{
  "errorCode": "DeviceNotFound",
  "message": "device not found"
}

// ✅ GOOD — HTTP status carries the contract
HTTP/1.1 404 Not Found
{
  "message": "device not found"
}

409 Conflict, 404 Not Found, 400 Bad Request, and friends already communicate most API contract failures. Avoid layering an extra parallel contract unless it is truly required across transports.

Simplify Handler Surfaces

Handlers should read like: decode → validate → operate → encode.

// ✅ GOOD — typed request/response surface per operation
type AssignIBDevicesRequest struct {
    Pod     string   `json:"pod"`
    Devices []string `json:"devices"`
}

func (s *Server) assignIBDevices(w http.ResponseWriter, r *http.Request) {
    var req AssignIBDevicesRequest
    if err := decode(r, &req); err != nil {
        http.Error(w, "invalid request", http.StatusBadRequest)
        return
    }
    // validate -> operate -> encode
}

Avoid broad pass-through wrappers or responses that exist only to restate HTTP status in another format.

Common Mistakes

MistakeFix
GET request with a bodyUse query parameters
POST on /resource/{id} for a non-create/non-replace actionUse action endpoint or the correct method
URL path identifies one resource while body mutates anotherModel the actual resource/mapping explicitly
Query-worthy selectors placed in JSON bodyPut selectors in query params
Returning HTTP 200 with app-layer not-found/conflict codeUse HTTP 404/409/etc.
Handler response wrapped only to repeat statusReturn one typed response shape or plain HTTP error
Splitting one logical operation across mismatched path/body shapesDesign one coherent typed request/response surface

Cross-References

  • → See acn-go-control-plane-contracts for typed public response/status contracts and CRD/API surface hygiene
  • → See acn-go-interfaces-dependencies for simplifying handler surfaces and migration shims
  • → See acn-go-errors-logging for boundary error handling and concise API-facing messages
  • → See acn-go-design-boundaries for keeping business behavior out of transport-specific plumbing

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.